This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: How do I add missing stdc functions to libstdc++-v3?
On 2012-03-12, at 9:19 PM, Jonathan Wakely wrote:
> On 13 March 2012 00:14, Vaugha Brewchuk wrote:
>> I have done a bit more experimenting and have made small progress. I tried linking abi_check manually while adding an object including strdup(). As a result, my original error message changed from:
>>
>> /bin/ld: Undefined symbols:
>> access(char const*, int)
>> ___gxx_personality_sj0
>> ___cxa_call_unexpected
>> strxfrm(char*, char const*, unsigned long)
>> strdup(char*)
>> write(int, void const*, unsigned long)
>> _strdup
>>
>> to:
>>
>> /bin/ld: Undefined symbols:
>> access(char const*, int)
>> ___gxx_personality_sj0
>> ___cxa_call_unexpected
>> strxfrm(char*, char const*, unsigned long)
>> strdup(char*)
>> write(int, void const*, unsigned long)
>>
>> So the actual linker error relating to missing "_strdup" disappeared, but the error with "strdup(char*)" remained. I then edited my system headers to add the missing definitions for access(), strxfrm(), strdup() and write() and rebuilt gcc-3.2.3 from scratch (it takes around 20 hours on a 68040!). Subsequent manual linking of abi_check only complained about two missing symbols:
>>
>> /bin/ld: Undefined symbols:
>> ___gxx_personality_sj0
>> ___cxa_call_unexpected
>>
>> Could someone please indicate to me at what point in gcc configuration (or build) the system headers are scanned for presence or absence of functions? Where do I tweak the gcc source to be able to define these missing functions without the need for editing my system headers? I tried to search the sources and the build directories, but was not successful in finding anything obviously related.
>>
>> Finally, how and where are the missing two symbols "___gxx_personality_sj0" and "___cxa_call_unexpected" normally generated? And again, where in the code do I need to start looking to define a workaround?
>
> They should be defined by gcc itself, in libsupc++.so, you shouldn't
> have to do anything.
>
> How are you linking abi_check? What exact command?
>
> I think the problem is how you're linking, not missing features of the OS.
You were absolutely correct regarding the linking phase.
I am using the exact same command as the Makefile with the all-target-libstdc++-v3 target:
/Storage2/gcc-3.2.3-bld/gcc/g++ -shared-libgcc -B/Storage2/gcc-3.2.3-bld/gcc/ -nostdinc++ -B/usr/local/m68k-next-nextstep3/bin/ -B/usr/local/m68k-next-nextstep3/lib/ -isystem /usr/local/m68k-next-nextstep3/include -g -O2 -o abi_check abi_check.o -L/Storage2/gcc-3.2.3-bld/m68k-next-nextstep3/libstdc++-v3/src -L/Storage2/gcc-3.2.3-bld/m68k-next-nextstep3/libstdc++-v3/src/.libs -lm
With verbose output enabled, the command produces the following output:
Reading specs from /Storage2/gcc-3.2.3-bld/gcc/specs
Configured with: ../gcc-3.2.3/configure --prefix=/usr/local --enable-languages=c,objc,c++,f77 --disable-shared --disable-threads --enable-cpp --enable-obsolete m68k-next-nextstep3
Thread model: single
gcc version 3.2.3
/Storage2/gcc-3.2.3-bld/gcc/collect2 -o abi_check -lcrt0.o -L/Storage2/gcc-3.2.3-bld/m68k-next-nextstep3/libstdc++-v3/src -L/Storage2/gcc-3.2.3-bld/m68k-next-nextstep3/libstdc++-v3/src/.libs -L/Storage2/gcc-3.2.3-bld/gcc -L/usr/local/lib/gcc-lib/m68k-next-nextstep3/3.2.3 -L/usr/local/lib/gcc-lib/m68k-next-nextstep3/3.2.3/../../.. abi_check.o -lstdc++ -lm -lgcc -lsys_s -lgcc
/bin/ld: Undefined symbols:
access(char const*, int)
___gxx_personality_sj0
strdup(char const*)
___cxa_call_unexpected
_strdup
strxfrm(char*, char const*, unsigned long)
collect2: ld returned 1 exit status
Following your suggestions and looking at the above output, it is obvious that there is no -lsupc++ command passed-on to collect2. I manually added -lsupc++ to the above command and both of the missing symbols have been imported by the linker! I am now one step closer to getting abi_check linked - thank you!
Now the question is why does g++ not try to link with libsupc++.a? I will dig through the configuration, but as always any pointers would be very much appreciated.
And of course I still get this even with all the symbols resolved by the linker:
/bin/ld: Undefined symbols:
access(char const*, int)
strdup(char const*)
strxfrm(char*, char const*, unsigned long)
collect2: ld returned 1 exit status
Thank you once again!