Re: Make mjpegtools build with LDFLAGS=-Wl, -z, defs

Fabian Greffrath <[email protected]> Fri, 28 Mar 2008 14:51:04 +0100
Newsgroups gmane.comp.video.mjpeg.devel
Message-ID <[email protected]>
Hi Steven,

let's have a look at how 'make' is failing in mpeg2enc/ if ./configure 
has been run with LDFLAGS="-Wl, -z, defs":

-8<---------------------------------

$ make

[...]

if /bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. 
-I. -I.. -I.. -I../utils    -march=athlon-4 -mno-sse2 -mtune=athlon-4 
-Wall -g -O2 -pthread  -MT seqencoder.lo -MD -MP -MF 
".deps/seqencoder.Tpo" -c -o seqencoder.lo seqencoder.cc; \
	then mv -f ".deps/seqencoder.Tpo" ".deps/seqencoder.Plo"; else rm -f 
".deps/seqencoder.Tpo"; exit 1; fi
  g++ -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I../utils -march=athlon-4 
-mno-sse2 -mtune=athlon-4 -Wall -g -O2 -pthread -MT seqencoder.lo -MD 
-MP -MF .deps/seqencoder.Tpo -c seqencoder.cc  -fPIC -DPIC -o 
.libs/seqencoder.o
  g++ -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I../utils -march=athlon-4 
-mno-sse2 -mtune=athlon-4 -Wall -g -O2 -pthread -MT seqencoder.lo -MD 
-MP -MF .deps/seqencoder.Tpo -c seqencoder.cc -o seqencoder.o 
 >/dev/null 2>&1

[...]

/bin/sh ../libtool --tag=CXX --mode=link g++  -march=athlon-4 
-mno-sse2 -mtune=athlon-4 -Wall -g -O2 -pthread   -Wl,-z,defs -o 
libmpeg2encpp.la -rpath /usr/local/lib  -version-info 1:1:1 -release 
1.9  conform.lo elemstrmwriter.lo encoderparams.lo macroblock.lo 
motionest.lo mpeg2coder.lo mpeg2encoptions.lo imageplanes.lo 
mpeg2encoder.lo picture.lo picturereader.lo predict.lo putpic.lo 
streamstate.lo seqencoder.lo quantize.lo ratectl.lo stats.lo 
synchrolib.lo tables.lo transfrm.lo fdct.lo idct.lo predict_ref.lo 
quantize_ref.lo transfrm_ref.lo fdct_x86.lo fdct_mmx.lo idct_mmx.lo 
quant_mmx.lo predict_mmx.lo predcomp_mmx.lo predcomp_mmxe.lo 
predict_x86.lo quantize_x86.lo transfrm_x86.lo ontheflyratectl.lo 
pass2ratectl.lo pass1ratectl.lo rate_complexity_model.lo 
../utils/libmjpegutils.la -lm

g++ -shared -nostdlib 
/usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../lib/crti.o 
/usr/lib/gcc/i486-linux-gnu/4.2.3/crtbeginS.o  .libs/conform.o 
.libs/elemstrmwriter.o .libs/encoderparams.o .libs/macroblock.o 
.libs/motionest.o .libs/mpeg2coder.o .libs/mpeg2encoptions.o 
.libs/imageplanes.o .libs/mpeg2encoder.o .libs/picture.o 
.libs/picturereader.o .libs/predict.o .libs/putpic.o 
.libs/streamstate.o .libs/seqencoder.o .libs/quantize.o 
.libs/ratectl.o .libs/stats.o .libs/synchrolib.o .libs/tables.o 
.libs/transfrm.o .libs/fdct.o .libs/idct.o .libs/predict_ref.o 
.libs/quantize_ref.o .libs/transfrm_ref.o .libs/fdct_x86.o 
.libs/fdct_mmx.o .libs/idct_mmx.o .libs/quant_mmx.o 
.libs/predict_mmx.o .libs/predcomp_mmx.o .libs/predcomp_mmxe.o 
.libs/predict_x86.o .libs/quantize_x86.o .libs/transfrm_x86.o 
.libs/ontheflyratectl.o .libs/pass2ratectl.o .libs/pass1ratectl.o 
.libs/rate_complexity_model.o  -Wl,--rpath 
-Wl,/home/fabian/temp/mjpegtools-1.9.0rc3/utils/.libs 
../utils/.libs/libmjpegutils.so -L/usr/lib/gcc/i486-linux-gnu/4.2.3 
-L/usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../lib -L/lib/../lib 
-L/usr/lib/../lib -L/usr/lib/gcc/i486-linux-gnu/4.2.3/../../.. 
-lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/i486-linux-gnu/4.2.3/crtendS.o 
/usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../lib/crtn.o 
-march=athlon-4 -mno-sse2 -mtune=athlon-4 -pthread -Wl,-z -Wl,defs 
-Wl,-soname -Wl,libmpeg2encpp-1.9.so.0 -o .libs/libmpeg2encpp-1.9.so.0.1.1
.libs/seqencoder.o: In function `Despatcher::Init(unsigned int)':
/home/fabian/temp/mjpegtools-1.9.0rc3/mpeg2enc/seqencoder.cc:144: 
undefined reference to `pthread_attr_getstacksize'
/home/fabian/temp/mjpegtools-1.9.0rc3/mpeg2enc/seqencoder.cc:159: 
undefined reference to `pthread_create'
/home/fabian/temp/mjpegtools-1.9.0rc3/mpeg2enc/seqencoder.cc:148: 
undefined reference to `pthread_attr_setstacksize'
.libs/seqencoder.o: In function `~Despatcher':
/home/fabian/temp/mjpegtools-1.9.0rc3/mpeg2enc/seqencoder.cc:183: 
undefined reference to `pthread_join'
/home/fabian/temp/mjpegtools-1.9.0rc3/mpeg2enc/seqencoder.cc:183: 
undefined reference to `pthread_join'
collect2: ld returned 1 exit status
make: *** [libmpeg2encpp.la] Error 1

-8<---------------------------------

Well, in the first section you can see that .libs/seqencoder.o is 
compiled with the '-pthread' option. This seems to be allright at 
first sight.

In the second section you can see the linker fail to resolve 
references to the pthread_* symbols in this very object.

The funny thing is, if I reset LDFLAGS empty in Makefile and run 
'make' again, compilation succeeds and the resulting 
.libs/libmpeg2encpp.so *is* linked against libpthread.so.0.

Strange, isn't it?

Cheers,
Fabian

PS: Asimilar case is reported at 
<http://ubuntuforums.org/showthread.php?t=232961>.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace