From: Herng-Jeng J. <hj...@qu...> - 2003-10-16 20:46:16
|
<html> <font size=3>Hi Alan,<br> Thanks for the useful explanation.<br> I did what you explained with the CVS 20031004 by:<br> $ ./configure --prefix=/usr/local/plplot_at --disable-dyndrivers --with-double<br> $ make<br> $ su<br> # make install <br> # exit<br> $ cd example/c++<br> $ /usr/local/plplot_at/bin/plplot_libtool --mode=link g++ -all-static x01.cc \<br> -I/usr/local/plplot_at/include/plplot -L/usr/local/plplot_at/lib \<br> -lplplotcxxd -o x01 -ldl<br> on my system, it complaints that -ltk8.3 cannot be found. I think it is because<br> I only have /usr/lib/libtk8.3.so, no .a in it.<br> Jou<br> <br> At 11:56 AM 10/15/2003 -0700, Alan W. Irwin wrote:<br> <blockquote type=cite cite>On 2003-10-15 09:37-0500 Herng-Jeng Jou wrote:<br> <br> > After I install PLplot into "/usr/local/plplot" directory,<br> > then I was trying to compile a standalone x01 without dynamic linkage at<br> > all to PLplot, and<br> > this is what I did:<br> > $ g++ -I/usr/local/plplot/include/plplot -c x01.cc<br> > $ g++ -g -O2 -o x01 x01.o /usr/local/plplot/lib/libplplotcxxd.a<br> > /usr/local/plplot/lib/libplplotd.a /usr/lib/libfreetype.so<br> > /usr/local/plplot/lib/libcsirocsa.a -ldl<br> <br> You should use plplot_libtool to solve the problem of making statically<br> linked versions of executables.<br> <br> Here is what to do:<br> <br> Adjust the line below for your prefix, but if I build<br> plplot-5.2.1.cvs.20031004 using<br> <br> --prefix=/usr/local/plplot_at --disable-dyndrivers<br> <br> Note the --disable-dyndrivers is essential because the combination of static<br> libraries (what you are ultimately trying to use) and dyndrivers does not<br> currently work.<br> <br> plplot_libtool --mode=link g++ -all-static x01.cc \<br> -I/usr/local/plplot_at/include/plplot -L/usr/local/plplot_at/lib \<br> -lplplotcxxd -o x01 -ldl<br> <br> then I get good results.<br> <br> Herng-Jeng and Andrew, will you please confirm this also works well on your<br> systems?<br> <br> Note the resulting executable is statically linked:<br> <br> file x01<br> x01: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically<br> linked, not stripped<br> <br> Also, the size of the executable is enormous<br> <br> ls -l x01<br> -rwxr-xr-x 1 software software 4760851 Oct 15 11:36 x01*<br> <br> But ./x01 -dev xwin, for example, works fine.<br> <br> I tried the same thing in the c directory, and again no problems.<br> <br> Also, I tried ordinary builds using make (which invokes plplot_libtool<br> without the -all-static and -ldl options) and they worked fine as well.<br> <br> So plplot_libtool is your friend for sorting out various linking cases.<br> (Rafael is working on a replacement to plplot_libtool which should be<br> able to do the same thing in a simpler way, but until that works,<br> use plplot_libtool.)<br> <br> What is going on here is that by default, both dynamic and static versions<br> of the plplot library are built. And the plplot_libtool -all-static flag<br> (see info libtool for documentation on how to invoke libtool, and therefore<br> its locally configured copy for your system, plplot_libtool) forces use of<br> the static libraries. On my system, the above plplot_libtool command<br> generates the following good compile/build commmand and executes it:<br> <br> g++ -static x01.cc -I/usr/local/plplot_at/include/plplot -o x01<br> -L/usr/local/plplot_at/lib /usr/local/plplot_at/lib/libplplotcxxd.a<br> /usr/local/plplot_at/lib/libplplotd.a /usr/local/plplot_at/lib/libcsirocsa.a<br> /usr/local/plplot_at/lib/libcsironn.a -lqhull -lcd -lgd -lpng<br> /usr/lib/libjpeg.a -lz -litk3.1 -ltk8.3 -litcl3.1 -ltcl8.3<br> /usr/lib/libfreetype.a -L/usr/X11R6/lib -lX11 -ldl<br> <br> So you could adjust your own g++ invocation to mimic this, but I think it is<br> much better to use plplot_libtool directly.<br> <br> BTW, the reason I knew what to do with plplot_libtool was I pretty much<br> (except for the -all-static option and -ldl on the end) followed what was<br> done for the examples to build them. I have already discussed why<br> -all-static is necessary. I found that the -ldl flag was necessary for the<br> --all-static case because /usr/lib/libtcl8.3.a refers to dlopen and friends,<br> and you have to resolve those reference with an explicit -ldl option.<br> <br> Alan<br> __________________________<br> Alan W. Irwin<br> email: ir...@be...<br> phone: 250-727-2902<br> <br> Astronomical research affiliation with Department of Physics and Astronomy,<br> University of Victoria (astrowww.phys.uvic.ca).<br> <br> Programming affiliations with the PLplot scientific plotting software<br> package (plplot.org), the Yorick front-end to PLplot (yplot.sf.net), the<br> Loads of Linux Links project (loll.sf.net), and the Linux Brochure Project<br> (lbproject.sf.net).<br> __________________________<br> <br> Linux-powered Science<br> __________________________<br> <br> <br> -------------------------------------------------------<br> This SF.net email is sponsored by: SF.net Giveback Program.<br> SourceForge.net hosts over 70,000 Open Source Projects.<br> See the people who have HELPED US provide better services:<br> Click here: <a href="http://sourceforge.net/supporters.php" eudora="autourl">http://sourceforge.net/supporters.php</a><br> _______________________________________________<br> Plplot-general mailing list<br> Plp...@li...<br> <a href="https://lists.sourceforge.net/lists/listinfo/plplot-general" eudora="autourl">https://lists.sourceforge.net/lists/listinfo/plplot-general</a> </font></blockquote><br> </html> |