http://sourceware.org/bugzilla/show_bug.cgi?id=12662
Summary: Unable to link with shared object (without lib prefix) or in different path Product: binutils Version: 2.17 Status: NEW Severity: normal Priority: P2 Component: ld AssignedTo: unassig...@sources.redhat.com ReportedBy: tarunactiv...@yahoo.com I am using RHEL 5 on z/OS . 2.6.18-128.el5 #1 SMP Wed Dec 17 11:45:02 EST 2008 s390x s390x s390x GNU/Linux GNU ld version 2.17.50.0.6-9.el5 20061020 I need to link with shared object files not having the lib prefix, that are added to the LD_LIBRARY_PATH . I am trying to achieve the following while linking: 1. Use shared object libraries not having the lib-prefix in the name. 2. Use libraries listed in different path ( present in LD_LIBRARY_PATH ) 3. Final output should be able to pickup the library from the LD_LIBRARY_PATH Solution 1: Link using the full path to library, This works even with non standard naming i.e. without the lib prefix , however, the link is hard coded in the exe. ( This can be confirmed from ldd exename ) , which works only when the libraries are in the same path. /usr/bin/g++ -v -o /tmp/conserv ./conserv.o /path/to/aaaa.so /path/to/bbbb.so /path/to/cccc.so -lpthread -L/usr/lib64 -lc -lncurses -ldl Solution 2: Link with the shared-object in the current folder Here, the exe will look for the library in the same folder. We need the libraries to be picked up from the LIBPATH/LD_LIBRARY_PATH /usr/bin/g++ -v -o /tmp/conserv ./conserv.o aaaa.so bbbb.so cccc.so -lpthread -L/usr/lib64 -lc -lncurses -ldl Solution 3: Rename libraries to "libxxxx" form Here, the linker will pick up the libs as specifid by -lxxxx ( where libxxxx is the shared object name ), and the path is specified in LIBPATH/LD_LIBRARY_PATH rename Libs to lib* /usr/bin/g++ -v -o /tmp/conserv ./conserv.o -laaaa -lbbbb -lcccc -lpthread -L/usr/lib64 -lc -lncurses -ldl However, this works only if the libs are renamed as libxxxx.so . The macro -l: does not seem to work with the non standard naming of shared objects. http://stackoverflow.com/questions/207069/how-to-link-using-gcc-without-l-and-without-hardcoding-path Is this version specific? How do we link with shared objects, without the lib-prefix , and without having the shared-object in the same path? -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils