I think the problem is gcc isn't passing the -Bstatic and -Bdynamic 
options to ld. Wl takes a comma separated list of options so the

-Wl,--whole-archive -Bstatic

passes --whole-archive to ld but not the -Bstatic. The -B option adds 
directories to the path gcc uses to find parts of the compiler.

Try

-Wl,--whole-archive,-Bstatic

and

-Wl,--no-whole-archive,-Bdynamic

to switch back to shared libraries.

I'm not sure you even need the --whole-archive and --no-whole-archive 
options, -Wl-Bstatic and -Wl-Bdynamic are probably sufficient.



Yura Vishnevskiy wrote:
> Linking finishes without errors.
> Here is the command line of linking stage and ld debug output:
> 
> /usr/bin/gcc  -g -O0 -m32 -march=i686 
> -I/export/home/yura/Projects/MYPROJ/dev/trunk/build/solaris-gcc-x86-i686/Debug/apr/include
>  
> -I/export/home/yura/Projects/MYPROJ/dev/trunk/build/solaris-gcc-x86-i686/Debug/apr-util/include
>  -D_LARGEFILE64_SOURCE  -fPIC 
> -L/export/home/yura/Projects/MYPROJ/dev/trunk/build/solaris-gcc-x86-i686/Debug/apr/lib
>  
> -L/export/home/yura/Projects/MYPROJ/dev/trunk/build/solaris-gcc-x86-i686/Debug/apr-util/lib
>  
> -L/export/home/yura/Projects/MYPROJ/dev/trunk/build/solaris-gcc-x86-i686/Debug/expat/lib
>  -Wl,--whole-archive -Bstatic -lapr-1 -laprutil-1 -lexpat -Bdynamic 
> -Wl,--no-whole-archive -lm -lpthread  -ldl -lrt -lcrypt 
> CMakeFiles/myproj.dir/cmd.o CMakeFiles/myproj.dir/atoms.o 
> CMakeFiles/myproj.dir/base.o CMakeFiles/myproj.dir/buildno.o 
> CMakeFiles/myproj.dir/d2i.o CMakeFiles/myproj.dir/debug.o 
> CMakeFiles/myproj.dir/dynamic.o CMakeFiles/myproj.dir/gf.o 
> CMakeFiles/myproj.dir/gint.o CMakeFiles/myproj.dir/gprm.o 
> CMakeFiles/myproj.dir/gterm.o CMakeFiles/myproj.d
ir
>  /images.o CMakeFiles/myproj.dir/input.o CMakeFiles/myproj.dir/math.o 
> CMakeFiles/myproj.dir/mgi.o CMakeFiles/myproj.dir/minimize.o 
> CMakeFiles/myproj.dir/mol.o CMakeFiles/myproj.dir/resprn.o 
> CMakeFiles/myproj.dir/search.o CMakeFiles/myproj.dir/sector.o 
> CMakeFiles/myproj.dir/standart.o CMakeFiles/myproj.dir/symmetry.o 
> CMakeFiles/myproj.dir/thermo.o CMakeFiles/myproj.dir/ucore.o 
> CMakeFiles/myproj.dir/myproj.o CMakeFiles/myproj.dir/myprojmpi.o 
> CMakeFiles/myproj.dir/utiles.o CMakeFiles/myproj.dir/vibr.o 
> CMakeFiles/myproj.dir/wedge.o CMakeFiles/myproj.dir/zmat.o 
> CMakeFiles/myproj.dir/ukl/ukl_cpu.o CMakeFiles/myproj.dir/ukl/ukl_dllist.o 
> CMakeFiles/myproj.dir/ukl/ukl_trie.o CMakeFiles/myproj.dir/ukl/ukl_object.o 
> CMakeFiles/myproj.dir/ukl/ukl_world.o CMakeFiles/myproj.dir/ukl/ukl_io.o 
> CMakeFiles/myproj.dir/ukl/ukl_session.o CMakeFiles/myproj.dir/ukl/ukl_parse.o 
> CMakeFiles/myproj.dir/ukl/ukl_log.o CMakeFiles/myproj.dir/ukl/ukl_error.o 
> CMakeFiles/myproj.dir/ukl/ukl_server.o CMakeFiles
/m
>  yproj.dir/ukl/ukl_other.o CMakeFiles/myproj.dir/ukl/ukl_string.o 
> CMakeFiles/myproj.dir/ukl/ukl_time.o CMakeFiles/myproj.dir/ukl/ukl_machine.o 
> CMakeFiles/myproj.dir/ukl/ukl_memory.o  -o myproj  
> debug: 
> debug: file=/usr/lib/crt1.o  [ ET_REL ]
> debug: 
> debug: file=/usr/lib/crti.o  [ ET_REL ]
> debug: 
> debug: file=/usr/lib/values-Xa.o  [ ET_REL ]
> debug: 
> debug: file=/usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/crtbegin.o  [ ET_REL ]
> debug: 
> debug: 
> file=/export/home/yura/Projects/MYPROJ/dev/trunk/build/solaris-gcc-x86-i686/Debug/apr/lib/libapr-1.so
>   [ ET_DYN ]
> debug: 
> debug: 
> file=/export/home/yura/Projects/MYPROJ/dev/trunk/build/solaris-gcc-x86-i686/Debug/apr-util/lib/libaprutil-1.so
>   [ ET_DYN ]
> debug: 
> debug: 
> file=/export/home/yura/Projects/MYPROJ/dev/trunk/build/solaris-gcc-x86-i686/Debug/expat/lib/libexpat.so
>   [ ET_DYN ]
> debug: 
> debug: file=/lib/libm.so  [ ET_DYN ]
> debug: 
> debug: file=/lib/libpthread.so  [ ET_DYN ]
> debug: 
> debug: file=/lib/libdl.so  [ ET_DYN ]
> debug: 
> debug: file=/lib/librt.so  [ ET_DYN ]
> debug: 
> debug: file=/usr/lib/libcrypt.so  [ ET_DYN ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/cmd.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/atoms.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/base.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/buildno.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/d2i.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/debug.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/dynamic.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/gf.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/gint.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/gprm.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/gterm.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/images.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/input.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/math.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/mgi.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/minimize.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/mol.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/resprn.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/search.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/sector.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/standart.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/symmetry.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/thermo.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/ucore.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/myproj.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/myprojmpi.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/utiles.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/vibr.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/wedge.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/zmat.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/ukl/ukl_cpu.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/ukl/ukl_dllist.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/ukl/ukl_trie.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/ukl/ukl_object.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/ukl/ukl_world.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/ukl/ukl_io.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/ukl/ukl_session.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/ukl/ukl_parse.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/ukl/ukl_log.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/ukl/ukl_error.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/ukl/ukl_server.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/ukl/ukl_other.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/ukl/ukl_string.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/ukl/ukl_time.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/ukl/ukl_machine.o  [ ET_REL ]
> debug: 
> debug: file=CMakeFiles/myproj.dir/ukl/ukl_memory.o  [ ET_REL ]
> debug: 
> debug: file=/usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/libgcc.a  [ archive ] 
> debug: 
> debug: file=/usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/libgcc.a(_divdi3.o)  [ 
> ET_REL ]
> debug: 
> debug: file=/usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/libgcc.a(_moddi3.o)  [ 
> ET_REL ]
> debug: 
> debug: file=/usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/libgcc.a(_udivdi3.o)  
> [ ET_REL ]
> debug: 
> debug: file=/usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/libgcc.a  [ archive ] 
> (again)
> debug: 
> debug: file=/usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/libgcc_eh.a  [ archive 
> ] 
> debug: 
> debug: file=/lib/libc.so  [ ET_DYN ]
> debug: file=/usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/libgcc.a;  reusing: 
> originally processed as /usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/libgcc.a
> debug: 
> debug: file=/usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/libgcc.a  [ archive ] 
> debug: file=/usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/libgcc_eh.a;  reusing: 
> originally processed as /usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/libgcc_eh.a
> debug: 
> debug: file=/usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/libgcc_eh.a  [ archive 
> ] 
> debug: 
> debug: file=/usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/crtend.o  [ ET_REL ]
> debug: 
> debug: file=/usr/lib/crtn.o  [ ET_REL ]
> debug: 
> debug: file=/lib/libsendfile.so.1  [ ET_DYN ]
> debug: 
> debug: file=/lib/libsocket.so.1  [ ET_DYN ]
> debug: 
> debug: file=/lib/libnsl.so.1  [ ET_DYN ]
> debug: 
> debug: file=/usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/../../../libgcc_s.so.1 
>  [ ET_DYN ]
> debug: 
> debug: file=/lib/libgen.so.1  [ ET_DYN ]
> debug: 
> debug: file=/lib/libmp.so.2  [ ET_DYN ]
> debug: 
> debug: file=/lib/libmd.so.1  [ ET_DYN ]
> debug: 
> debug: file=/lib/libscf.so.1  [ ET_DYN ]
> debug: 
> debug: file=/lib/libuutil.so.1  [ ET_DYN ]
> debug:
> 
> In my custom dirs apr/lib, aprutil/lib and expat/lib I have both shared and 
> static libs and it seems that linker prefers shared libs.


-- 
Andrew Walton
Software Engineer
ISV Engineering
Sun Microsystems

Reply via email to