www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - creating a .so with gdc

reply Carlos Santander <csantander619 gmail.com> writes:
Can somebody explain for the n-th time how to create a .so with GDC? Here's
what 
I'm getting:

$ gdc -fshared -Wl,-soname,libfoo.so -o libfoo.so foo.o
/usr/bin/ld: unknown flag: -soname
collect2: ld returned 1 exit status

That's on Mac OS X. How about also setting up a wiki page so it's easy to find?

-- 
Carlos Santander Bernal
May 03 2007
parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Carlos Santander wrote:

 Can somebody explain for the n-th time how to create a .so with GDC? 
 Here's what I'm getting:
 
 $ gdc -fshared -Wl,-soname,libfoo.so -o libfoo.so foo.o
 /usr/bin/ld: unknown flag: -soname
 collect2: ld returned 1 exit status
 
 That's on Mac OS X. How about also setting up a wiki page so it's easy 
 to find?
I haven't created a shared library with GDC, but the shared (.so) files on other platforms are known as either dynamiclib or bundle on Mac OS X. Dynamic libraries are for linking to and bundles for loading at runtime, for instance program plugins and modules for Perl or Python are bundles. Using -soname should be equivalent to -install_name on Mac OS X. See: http://developer.apple.com/documentation/developertools/gcc-4.0.1/gcc/Darwin-Options.html $ gcc -dynamiclib -Wl,-install_name,libfoo.dylib -o libfoo.dylib foo.o But my GDC says cc1d: error: unrecognized command line option "-fshared" --anders
May 04 2007
parent reply Carlos Santander <csantander619 gmail.com> writes:
Anders F Björklund escribió:
 Carlos Santander wrote:
 
 Can somebody explain for the n-th time how to create a .so with GDC? 
 Here's what I'm getting:

 $ gdc -fshared -Wl,-soname,libfoo.so -o libfoo.so foo.o
 /usr/bin/ld: unknown flag: -soname
 collect2: ld returned 1 exit status

 That's on Mac OS X. How about also setting up a wiki page so it's easy 
 to find?
I haven't created a shared library with GDC, but the shared (.so) files on other platforms are known as either dynamiclib or bundle on Mac OS X. Dynamic libraries are for linking to and bundles for loading at runtime, for instance program plugins and modules for Perl or Python are bundles. Using -soname should be equivalent to -install_name on Mac OS X. See: http://developer.apple.com/documentation/developertools/gcc-4.0.1/gcc Darwin-Options.html $ gcc -dynamiclib -Wl,-install_name,libfoo.dylib -o libfoo.dylib foo.o But my GDC says cc1d: error: unrecognized command line option "-fshared" --anders
Weird... /usr/bin/ld: -i argument: nstall_name must have a ':' between its symbol names -- Carlos Santander Bernal
May 04 2007
parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Carlos Santander wrote:

 $ gcc -dynamiclib -Wl,-install_name,libfoo.dylib -o libfoo.dylib foo.o
 But my GDC says cc1d: error: unrecognized command line option "-fshared"
Weird... /usr/bin/ld: -i argument: nstall_name must have a ':' between its symbol
Which compiler are you using ? (I'm using the regular Mac OS X 10.4 one) --anders
May 04 2007
parent reply Carlos Santander <csantander619 gmail.com> writes:
Anders F Björklund escribió:
 Carlos Santander wrote:
 
 $ gcc -dynamiclib -Wl,-install_name,libfoo.dylib -o libfoo.dylib foo.o
 But my GDC says cc1d: error: unrecognized command line option "-fshared"
Weird... /usr/bin/ld: -i argument: nstall_name must have a ':' between its symbol
Which compiler are you using ? (I'm using the regular Mac OS X 10.4 one) --anders
$ gdc -v Using built-in specs. Target: powerpc-apple-darwin8.8.0 Configured with: ../gcc-4.1.1/configure --disable-multilib --enable-languages=c,d Thread model: posix gcc version 4.1.1 20060524 ( (gdc 0.23, using dmd 1.007)) $ gcc -v Using built-in specs. Target: powerpc-apple-darwin8 Configured with: /private/var/tmp/gcc/gcc-5247.obj~4/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --build=powerpc-apple-darwin8 --host=powerpc-apple-darwin8 --target=powerpc-apple-darwin8 Thread model: posix gcc version 4.0.1 (Apple Computer, Inc. build 5247) $ ld -v Apple Computer, Inc. version cctools-590.18.obj~10 -- Carlos Santander Bernal
May 04 2007
parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Carlos Santander wrote:

 Which compiler are you using ? (I'm using the regular Mac OS X 10.4 one)
$ gdc -v Using built-in specs. Target: powerpc-apple-darwin8.8.0 Configured with: ../gcc-4.1.1/configure --disable-multilib --enable-languages=c,d Thread model: posix gcc version 4.1.1 20060524 ( (gdc 0.23, using dmd 1.007))
OK, if you are using the FSF version of GCC it probably doesn't know about the various linker flags for Darwin - those are Apple specials. $ gdc -v ... gcc version 4.0.1 (Apple Computer, Inc. build 5363) (gdc 0.23, using dmd 1.007) $ gcc -v ... gcc version 4.0.1 (Apple Computer, Inc. build 5367) Apple hasn't released the source codes to Xcode 2.4.1 just yet, that's why the difference in the build numbers (gcc-5363 was from Xcode 2.4) --anders
May 04 2007
parent Carlos Santander <csantander619 gmail.com> writes:
Anders F Björklund escribió:
 
 OK, if you are using the FSF version of GCC it probably doesn't know 
 about the various linker flags for Darwin - those are Apple specials.
 
 $ gdc -v
 ....
 gcc version 4.0.1 (Apple Computer, Inc. build 5363) (gdc 0.23, using dmd 
 1.007)
 
 $ gcc -v
 ....
 gcc version 4.0.1 (Apple Computer, Inc. build 5367)
 
 Apple hasn't released the source codes to Xcode 2.4.1 just yet, that's
 why the difference in the build numbers (gcc-5363 was from Xcode 2.4)
 
 --anders
I downloaded Apple's version: gcc version 4.0.1 (Apple Computer, Inc. build 5341) (gdc 0.23, using dmd 1.007) But I get the same thing: /usr/bin/ld: -i argument: nstall_name must have a ':' between its symbol names And I guess that makes sense because it's ld that's failing, not gcc. $ /usr/bin/ld -v Apple Computer, Inc. version cctools-590.18.obj~10 -- Carlos Santander Bernal
May 04 2007