incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: stdcxx building problem on the gcc 3.2.2/Linux RedHat9
Date Fri, 30 Jun 2006 16:37:02 GMT
Farid Zaripov wrote:
>   When I build the tests ld fails with error:
> 
> /usr/src/Incubator/stdcxx/trunk/build/rwtest/librwtest.a(printf.o)(.text+0x37dd): 
> In function `_rw_fmttm(FmtSpec const&, Buffer&, tm const*)':
> : undefined reference to `__rw::__rw_memattr(void const*, unsigned, int)'

FYI, it's good to show the complete command line. Here are some
of the errors I get:

$ make 21.string.replace
gcc -pedantic -nostdinc++ -g  -W -Wall -Wcast-qual -Winline -Wshadow 
-Wwrite-strings -Wno-long-long  -I/build/sebor/stdcxx/include/ansi 
-D_RWSTDDEBUG    -D_RWSTD_USE_CONFIG -I/build/sebor/stdcxx/include 
-I/build/sebor/stdcxx-gcc-4.1.0-11s/include 
-I/build/sebor/stdcxx/../rwtest -I/build/sebor/stdcxx/../rwtest/include 
-I/build/sebor/stdcxx/tests/include 
-L/build/sebor/stdcxx-gcc-4.1.0-11s/rwtest -lrwtest11s 
-L/build/sebor/stdcxx-gcc-4.1.0-11s/lib -lstd11s 
/build/sebor/stdcxx/tests/strings/21.string.replace.cpp 
/build/sebor/stdcxx-gcc-4.1.0-11s/lib/libstd11s.a 
/build/sebor/stdcxx-gcc-4.1.0-11s/rwtest/librwtest11s.a  -lsupc++ -lm -o 
21.string.replace
/build/sebor/stdcxx-gcc-4.1.0-11s/rwtest/librwtest11s.a(printf.o): In 
function `__static_initialization_and_destruction_0':
/build/sebor/stdcxx/include/iostream:39: undefined reference to 
`std::ios_base::Init::Init()'
/build/sebor/stdcxx/include/iostream:39: undefined reference to 
`std::ios_base::Init::~Init()'
/build/sebor/stdcxx-gcc-4.1.0-11s/rwtest/librwtest11s.a(printf.o): In 
function `_rw_fmtstr(FmtSpec const&, Buffer&, char const*, unsigned int)':
/build/sebor/stdcxx/tests/src/printf.cpp:2284: undefined reference to 
`__rw::__rw_memattr(void const*, unsigned int, int)'
...
collect2: ld returned 1 exit status
make: *** [21.string.replace] Error 1

> 
>   I discovered that ld looks through libraries in that order in which 
> they are specified in a command line. __rw_memattr is referenced in 
> librwtest.a and defined in libstd.a. For successful linking libstd.a 
> should be after librwtest.a.

Correct. All UNIX linkers work the way you describe. I don't think
the problem is with the rule below though (that rule only sets up
the dependencies of each target, it doesn't determine their order
on the command line). I believe the problem you are describing is
caused by the invocation of the implicit rule for (some of) the
tests instead of the explicit one defined in our makefiles. The
implicit rule compiles and links the target in one shot and puts
the test library in the wrong place, causing the unsat you mention.
Disabiling the implicit rules (using -r) allows the explicit ones
to be evaluated and the tests to link successfully:

$ make 21.string.replace -r
gcc -c -I/build/sebor/stdcxx/include/ansi -D_RWSTDDEBUG 
-D_RWSTD_USE_CONFIG -I/build/sebor/stdcxx/include 
-I/build/sebor/stdcxx-gcc-4.1.0-11s/include 
-I/build/sebor/stdcxx/../rwtest -I/build/sebor/stdcxx/../rwtest/include 
-I/build/sebor/stdcxx/tests/include  -pedantic -nostdinc++ -g  -W -Wall 
-Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long 
/build/sebor/stdcxx/tests/strings/21.string.replace.cpp
gcc 21.string.replace.o -o 21.string.replace 
-L/build/sebor/stdcxx-gcc-4.1.0-11s/rwtest -lrwtest11s 
-L/build/sebor/stdcxx-gcc-4.1.0-11s/lib -lstd11s  -lsupc++ -lm
rm 21.string.replace.o

It would be good to look into what's causing the implicit rules
to override the explicit ones. I suspoect it has something to do
with the location of the source files since moving the test to
the CWD solves it:

$ mv /build/sebor/stdcxx/tests/strings/21_string_replace.cpp 
21.string.replace.cpp && make 21.string.replace
gcc -c -I/build/sebor/stdcxx/include/ansi -D_RWSTDDEBUG 
-D_RWSTD_USE_CONFIG -I/build/sebor/stdcxx/include 
-I/build/sebor/stdcxx-gcc-4.1.0-11s/include 
-I/build/sebor/stdcxx/../rwtest -I/build/sebor/stdcxx/../rwtest/include 
-I/build/sebor/stdcxx/tests/include  -pedantic -nostdinc++ -g  -W -Wall 
-Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long 
21.string.replace.cpp
gcc 21.string.replace.o -o 21.string.replace 
-L/build/sebor/stdcxx-gcc-4.1.0-11s/rwtest -lrwtest11s 
-L/build/sebor/stdcxx-gcc-4.1.0-11s/lib -lstd11s  -lsupc++ -lm

In any event, could you please open an issue in Jira for this
and cross-reference this thread (by pasting a link to the archive
into the issue)?

Thanks
Martin

Mime
View raw message