comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: GCC 4.8.1 for Mac OS X
Date: Sun, 21 Jul 2013 12:55:05 +0100
Date: 2013-07-21T12:55:05+01:00	[thread overview]
Message-ID: <lymwpgt9eu.fsf@pushface.org> (raw)
In-Reply-To: a944c0c4-cff4-4318-9b73-ecd208967b99@googlegroups.com

Michael Rohan <michael@zanyblue.com> writes:

> Not sure if this is simply a setup issue on my MacBook (this is the first Mac
> system I've worked on) but when I try to build an application I run
> into a linker issue:
>
> $ make
> gnatmake -p -XOS=unix -XTYPE=static -XBUILD=Debug -aP../../lib/gnat
> -aP../../src -P zbmcompile
> gnatbind -x /Users/mrohan/zb/zanyblue/src/obj/zbmcompile-main.ali
> gnatlink /Users/mrohan/zb/zanyblue/src/obj/zbmcompile-main.ali -g
> /Users/mrohan/zb/zanyblue/lib/zanyblue/libzanyblue.a
> -Wl,-rpath,/opt/gcc-4.8.1/lib/gcc/x86_64-apple-darwin12/4.8.1/adalib/
> -o /Users/mrohan/zb/zanyblue/bin/zbmcompile
> ld: unknown option: -R
> collect2: error: ld returned 1 exit status
> gnatlink: error when calling /opt/gcc-4.8.1/bin/gcc
> gnatmake: *** link failed.
> make: *** [all] Error 4
>
> I assume I need GNU ld, it seems I don't currently have it:
>
> $ ld -v
> @(#)PROGRAM:ld  PROJECT:ld64-136
> configured to support archs: armv6 armv7 armv7s i386 x86_64
> LTO support using: LLVM version 3.2svn, from Apple Clang 4.2 (build 425.0.28)
>
> Apologies if this is a basic question.

Not at all!

I tried your gnatmake command above with zanyblue-1.1.0b (after having
run make from src/), first with -largs -Wl,-v to show the actual command
passed to ld (which showd the -R) and then with -largs -v to give a full
report of the gnatlink command; which gave, near the end,

   ...-Wl,-R,$ORIGIN/../lib...

so I grepped for ORIGIN from src/, which gave (along with some files in
src/obj/)

  ./mkfile/conf.mk:# ld.so runtime path "$ORIGIN/../lib", i.e., load shared libraries from

  ./os/unix/zanyblue-os-ld_run_path.ads:   pragma Linker_Options ("-Wl,-R,$ORIGIN/../lib");

Just looking at the last, it says

   package ZanyBlue.OS.Ld_Run_Path is

      pragma Warnings (Off, ZanyBlue.OS.Ld_Run_Path);
      pragma Linker_Options ("-Wl,-R,$ORIGIN/../lib");
      --  Embed the ls.do runtime shared library path "../lib" relative to the
      --  executable.

   end ZanyBlue.OS.Ld_Run_Path;

(I think that comment should say ld.so, not ls.do!) -- and the thing is,
that's not how you embed .dylib runtime paths in the executable on Mac
OS X.

(a) build your .dylibs using gprbuild, not gnatmake, because gnatmake
    doesn't know how to embed runtime paths in .dylibs;

(b) install your .dylibs to the proper place;

(c) link against them.

(I should say, I can't give you the full reasoning behind this, but it
works!)



  parent reply	other threads:[~2013-07-21 11:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-07 18:37 GCC 4.8.1 for Mac OS X Simon Wright
2013-07-07 22:02 ` Bill Findlay
2013-07-08  7:25   ` Simon Wright
2013-07-08 17:57     ` Bill Findlay
2013-07-08 20:06 ` Felix Krause
2013-07-08 22:37   ` Simon Wright
2013-07-09 15:31     ` Felix Krause
2013-07-09 19:35       ` Simon Wright
2013-07-17 19:57 ` Felix Krause
2013-07-17 21:00   ` Simon Wright
2013-07-18 20:23     ` Simon Wright
2013-07-21  0:59 ` Michael Rohan
2013-07-21  1:06   ` Bill Findlay
2013-07-21  1:19     ` Michael Rohan
2013-07-21  3:57     ` Dennis Lee Bieber
2013-07-21 11:55   ` Simon Wright [this message]
2013-07-21 18:01     ` Michael Rohan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox