ld refuses to link.

Greg Davey mailforroot@turbodiesel360.cjb.net
Thu Jun 12 17:46:00 GMT 2003


I am currently learning c++ and have run into a mildly annoying
problem.  When I use the sun compiler,  everything compiles and links
nicely.  When I use g++ and the gnu linker, I just get undefined
reference errors.  Now, I have noticed that the sun compiler invokes
it's linker with the -u and -R[object file] options, but I do not know
how to have the gnu compiler "automagically" do this.  More
specifically, when I take this code to another machine, how do I have a
makefile resolve these dependencies.  Any help would be appreciated.  I
have included three files:
gnucompile.txt    [console output when I use g++]
suncompile.txt    [console output when I use the sun compiler]
fixme.tar.gz         [code I am trying to compile]

program versions:
gcc= 3.2.3
binutils= 2.13.2.1

Thank you for any advice/help anyone could give me.

Greg Davey
gbdavey@acsu.buffalo.edu




I sent this e-mail to redhat and got the following reply.  If anyone could help me with my problem I would greatly appreciate it.

Thank you,
Greg Davey



Reply received from nickc@redhat.com

>Hi Greg,
>
>> I am currently learning c++ and have run into a mildly annoying
>> problem.  When I use the sun compiler,  everything compiles and
>>links
>> nicely.  When I use g++ and the gnu linker, I just get undefined
>> reference errors.
>
>This looks more like a g++ problem (1) than a linker problem.  You
>will probably be better off sending your query to the:
>
>     gcc-help@gcc.gnu.org
>
>list.
>
>Cheers
>        Nick
>
>(1) with instantiation of templates.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: fixme.tar.gz
Type: application/x-compressed-tar
Size: 3874 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20030612/368c66ee/attachment.bin>
-------------- next part --------------
[greg@davey-world fixme]$ g++ -v -Wno-deprecated ListDictionary.cc main.cc supply.cc
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/specs
Configured with: ../gcc-3.2.3/configure --prefix=/usr --program-suffix=-3.2.3 --enable-threads
Thread model: posix
gcc version 3.2.3
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=3 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ ListDictionary.cc -D__GNUG__=3 -D__EXCEPTIONS -quiet -dumpbase ListDictionary.cc -Wno-deprecated -version -o /home/greg/tmp/cckY8OMt.s
GNU CPP version 3.2.3 (cpplib) (i386 Linux/ELF)
GNU C++ version 3.2.3 (i686-pc-linux-gnu)
        compiled by GNU C version 3.2.3.
ignoring nonexistent directory "/usr/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/3.2.3
 /usr/include/c++/3.2.3/i686-pc-linux-gnu
 /usr/include/c++/3.2.3/backward
 /usr/local/include
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../../../i686-pc-linux-gnu/bin/as -V -Qy -o /home/greg/tmp/ccx5G38U.o /home/greg/tmp/cckY8OMt.s
GNU assembler version 2.13.2.1 (i686-pc-linux-gnu) using BFD version 2.13.2.1
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=3 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ main.cc -D__GNUG__=3 -D__EXCEPTIONS -quiet -dumpbase main.cc -Wno-deprecated -version -o /home/greg/tmp/cckY8OMt.s
GNU CPP version 3.2.3 (cpplib) (i386 Linux/ELF)
GNU C++ version 3.2.3 (i686-pc-linux-gnu)
        compiled by GNU C version 3.2.3.
ignoring nonexistent directory "/usr/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/3.2.3
 /usr/include/c++/3.2.3/i686-pc-linux-gnu
 /usr/include/c++/3.2.3/backward
 /usr/local/include
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../../../i686-pc-linux-gnu/bin/as -V -Qy -o /home/greg/tmp/ccVjyhzU.o /home/greg/tmp/cckY8OMt.s
GNU assembler version 2.13.2.1 (i686-pc-linux-gnu) using BFD version 2.13.2.1
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=3 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ supply.cc -D__GNUG__=3 -D__EXCEPTIONS -quiet -dumpbase supply.cc -Wno-deprecated -version -o /home/greg/tmp/cckY8OMt.s
GNU CPP version 3.2.3 (cpplib) (i386 Linux/ELF)
GNU C++ version 3.2.3 (i686-pc-linux-gnu)
        compiled by GNU C version 3.2.3.
ignoring nonexistent directory "/usr/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/3.2.3
 /usr/include/c++/3.2.3/i686-pc-linux-gnu
 /usr/include/c++/3.2.3/backward
 /usr/local/include
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../../../i686-pc-linux-gnu/bin/as -V -Qy -o /home/greg/tmp/ccjI6O71.o /home/greg/tmp/cckY8OMt.s
GNU assembler version 2.13.2.1 (i686-pc-linux-gnu) using BFD version 2.13.2.1
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../../crt1.o /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../../crti.o /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/crtbegin.o -L/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3 -L/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../../../i686-pc-linux-gnu/lib -L/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../.. /home/greg/tmp/ccx5G38U.o /home/greg/tmp/ccVjyhzU.o /home/greg/tmp/ccjI6O71.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/crtend.o /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../../crtn.o
/home/greg/tmp/ccVjyhzU.o: In function `garbageCollect()':
/home/greg/tmp/ccVjyhzU.o(.text+0xf): undefined reference to `void deallocateDictionary<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int>(Dictionary<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int>*)'
/home/greg/tmp/ccVjyhzU.o: In function `__static_initialization_and_destruction_0(int, int)':
/home/greg/tmp/ccVjyhzU.o(.text+0x72b): undefined reference to `Dictionary<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int>* allocateDictionary<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int>(bool, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int)'
collect2: ld returned 1 exit status
-------------- next part --------------
yeager {~/cse250/PP1} > CC -v main.cc supply.cc ListDictionary.cc
###     command line files and options (expanded):
### -v main.cc supply.cc ListDictionary.cc
### CC: Note: LM_LICENSE_FILE = /util/licenses/licenses.dat:/util/licenses/ioffice.dat:/util/licenses/matlab-eng.dat:/util/licenses/matlab-cit.dat
### CC: Note: NLSPATH = /opt/SUNWspro/bin/../WS6U2/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/opt/SUNWspro/bin/../WS6U2/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat
main.cc:
/opt/SUNWspro/bin/../WS6U2/bin/ccfe -y-o -ymain.o -y-fbe -y/opt/SUNWspro/bin/../WS6U2/bin/fbe -y-xarch=generic -y-verbose -O0 -ptf /tmp/20179%1.%2 -ptx /opt/SUNWspro/bin/../WS6U2/bin/CC -ptk "-v " -D__SunOS_5_8 -D__SUNPRO_CC=0x530 -Dunix -Dsun -Dsparc -D__sparc -D__unix -D__sun -D__BUILTIN_VA_ARG_INCR -D__SVR4 -D__SUNPRO_CC_COMPAT=5 -I-xbuiltin -instlib=/opt/SUNWspro/WS6U2/lib/libCstd.a -I/opt/SUNWspro/WS6U2/include/CC/Cstd -I/opt/SUNWspro/WS6U2/include/CC -I/opt/SUNWspro/WS6U2/include/CC/rw7 -I/opt/SUNWspro/WS6U2/include/cc -D__SUN_PREFETCH main.cc -s /tmp/ccfe.20179.0.s
rm /tmp/ccfe.20179.0.s
supply.cc:
/opt/SUNWspro/bin/../WS6U2/bin/ccfe -y-o -ysupply.o -y-fbe -y/opt/SUNWspro/bin/../WS6U2/bin/fbe -y-xarch=generic -y-verbose -O0 -ptf /tmp/20179%1.%2 -ptx /opt/SUNWspro/bin/../WS6U2/bin/CC -ptk "-v " -D__SunOS_5_8 -D__SUNPRO_CC=0x530 -Dunix -Dsun -Dsparc -D__sparc -D__unix -D__sun -D__BUILTIN_VA_ARG_INCR -D__SVR4 -D__SUNPRO_CC_COMPAT=5 -I-xbuiltin -instlib=/opt/SUNWspro/WS6U2/lib/libCstd.a -I/opt/SUNWspro/WS6U2/include/CC/Cstd -I/opt/SUNWspro/WS6U2/include/CC -I/opt/SUNWspro/WS6U2/include/CC/rw7 -I/opt/SUNWspro/WS6U2/include/cc -D__SUN_PREFETCH supply.cc -s /tmp/ccfe.20179.1.s
rm /tmp/ccfe.20179.1.s
ListDictionary.cc:
/opt/SUNWspro/bin/../WS6U2/bin/ccfe -y-o -yListDictionary.o -y-fbe -y/opt/SUNWspro/bin/../WS6U2/bin/fbe -y-xarch=generic -y-verbose -O0 -ptf /tmp/20179%1.%2 -ptx /opt/SUNWspro/bin/../WS6U2/bin/CC -ptk "-v " -D__SunOS_5_8 -D__SUNPRO_CC=0x530 -Dunix -Dsun -Dsparc -D__sparc -D__unix -D__sun -D__BUILTIN_VA_ARG_INCR -D__SVR4 -D__SUNPRO_CC_COMPAT=5 -I-xbuiltin -instlib=/opt/SUNWspro/WS6U2/lib/libCstd.a -I/opt/SUNWspro/WS6U2/include/CC/Cstd -I/opt/SUNWspro/WS6U2/include/CC -I/opt/SUNWspro/WS6U2/include/CC/rw7 -I/opt/SUNWspro/WS6U2/include/cc -D__SUN_PREFETCH ListDictionary.cc -s /tmp/ccfe.20179.2.s
rm /tmp/ccfe.20179.2.s
/opt/SUNWspro/bin/../WS6U2/bin/CClink -ptk "-v  -xildoff " -ptx /opt/SUNWspro/bin/../WS6U2/bin/CC main.o supply.o ListDictionary.o -o a.out
### CC: Note: LD_LIBRARY_PATH = (null)
### CC: Note: LD_RUN_PATH     = (null)
### CC: Note: LD_OPTIONS = (null)
/usr/ccs/bin/ld -u __1cH__CimplKcplus_init6F_v_ -R/opt/SUNWspro/lib/rw7:/opt/SUNWspro/lib:/opt/SUNWspro/lib:/usr/ccs/lib:/usr/lib -o a.out /opt/SUNWspro/WS6U2/lib/crti.o /opt/SUNWspro/WS6U2/lib/crt1.o /opt/SUNWspro/WS6U2/lib/values-xa.o -Y P,/opt/SUNWspro/lib/rw7:/opt/SUNWspro/lib:/opt/SUNWspro/WS6U2/lib/rw7:/opt/SUNWspro/WS6U2/lib:/usr/ccs/lib:/usr/lib /home/cendue/gbdavey/cse250/PP1/SunWS_cache/CC_obj_K/KZs7iornbwtOm5LgRs_3.o /home/cendue/gbdavey/cse250/PP1/SunWS_cache/CC_obj_E/EQpdvcixeQptp8r_gUkm.o /home/cendue/gbdavey/cse250/PP1/SunWS_cache/CC_obj_H/He8BCVLC0L44JHLUfGQW.o /home/cendue/gbdavey/cse250/PP1/SunWS_cache/CC_obj_O/OZa9KXv4-Lf05aGHa-aj.o /home/cendue/gbdavey/cse250/PP1/SunWS_cache/CC_obj_Y/YEWjXt_1XIs-y9-GEVrw.o /home/cendue/gbdavey/cse250/PP1/SunWS_cache/CC_obj_z/zvZ8nTMxP0felR-1te7j.o /home/cendue/gbdavey/cse250/PP1/SunWS_cache/CC_obj_0/0P864na5Hlr56m2GWIxX.o /home/cendue/gbdavey/cse250/PP1/SunWS_cache/CC_obj_l/lbcwEi9sGOnQkhxaPkre.o /home/cendue/gbdavey/cse250/PP1/SunWS_cache/CC_obj_e/eGKOkGnsek3u4_99UqTE.o /home/cendue/gbdavey/cse250/PP1/SunWS_cache/CC_obj_6/6uGWwifsWGxcOPjZsbdj.o /home/cendue/gbdavey/cse250/PP1/SunWS_cache/CC_obj_m/m-nM29VjWyEZ_pZH7vZR.o main.o supply.o ListDictionary.o -lCstd -lCrun -lm -lw -lcx -lc /opt/SUNWspro/WS6U2/lib/crtn.o >&/tmp/ld.20187.0.err
/opt/SUNWspro/bin/../WS6U2/bin/c++filt -stderr </tmp/ld.20187.0.err
rm /tmp/ld.20187.0.err
yeager {~/cse250/PP1} >


More information about the Gcc-help mailing list