Subject: CGAL users discussion list
List archive
- From: Joachim Reichel <>
- To:
- Subject: Re: [cgal-discuss] Re: link static
- Date: Sun, 24 Apr 2011 11:49:45 +0200
Hi,
On 04/20/2011 08:57 AM, pascal8361 wrote:
> I forgot the link command:
I still don't see it ;-) BTW if you call cmake with
-DCMAKE_VERBOSE_MAKEFILE=ON
it will print the executed commands.
> I am building the project with cmake and I am using the CGAL flag to build
> statically when calling cmake .
Doing this within cmake might be difficult. I would call the link command
manually.
For the Alpha_shapes_2 demo the link command looks as follows:
/usr/bin/c++ -frounding-math -g
/CMakeFiles/Alpha_shapes_2.dir/Alpha_shapes_2.o
/CMakeFiles/Alpha_shapes_2.dir/qrc_Alpha_shapes_2.o -o Alpha_shapes_2
-rdynamic
-lCGAL_Qt4 -lCGAL -lgmpxx -lmpfr -lgmp -lboost_thread-mt lQtOpenGL -lQtGui
-lQtCore -lGLU -lGL -lX11 -lXext -lQtOpenGL -lQtScript -lQtGui -lQtXml
-lQtCore
-lCGAL_Qt4 -lCGAL -lgmpxx -lmpfr -lgmp -lboost_thread-mt -lQtOpenGL -lQtGui
-lQtCore -lGLU -lGL -lX11 -lXext -lQtScript -lQtXml
First get rid of the repeated and unneeded libraries (it might be necessary to
reorder the libraries):
/usr/bin/c++ -frounding-math -g
CMakeFiles/Alpha_shapes_2.dir/Alpha_shapes_2.o
CMakeFiles/Alpha_shapes_2.dir/qrc_Alpha_shapes_2.o -o Alpha_shapes_2
-rdynamic
-lCGAL_Qt4 -lCGAL -lgmpxx -lmpfr -lgmp -lboost_thread-mt -lQtOpenGL -lQtGui
-lQtCore -lGLU -lGL -lX11 -lXext
Now use -Wl,-Bstatic and -Wl,-Bdynamic to force the use of static libraries:
/usr/bin/c++ -frounding-math -g
CMakeFiles/Alpha_shapes_2.dir/Alpha_shapes_2.o
CMakeFiles/Alpha_shapes_2.dir/qrc_Alpha_shapes_2.o -o Alpha_shapes_2
-rdynamic
-Wl,-Bstatic -lCGAL_Qt4 -lCGAL -lgmpxx -lmpfr -lgmp -lboost_thread-mt
-lQtOpenGL
-lQtGui -lQtCore -lGLU -lGL -lX11 -lXext -Wl,-Bdynamic
/usr/bin/ld: cannot find -lQtOpenGL
/usr/bin/ld: cannot find -lQtGui
/usr/bin/ld: cannot find -lQtCore
/usr/bin/ld: cannot find -lGL
collect2: ld returned 1 exit status
It turns out that on my machine there is no static version of the Qt and GL
libraries. Again, use -Wl,-Bstatic and -Wl,-Bdynamic to use the dynamic
libraries for these (and for -lX11 too):
/usr/bin/c++ -frounding-math -g
CMakeFiles/Alpha_shapes_2.dir/Alpha_shapes_2.o
CMakeFiles/Alpha_shapes_2.dir/qrc_Alpha_shapes_2.o -o Alpha_shapes_2
-rdynamic
-Wl,-Bstatic -lCGAL_Qt4 -lCGAL -lgmpxx -lmpfr -lgmp -lboost_thread-mt
-Wl,-Bdynamic -lQtOpenGL -lQtGui -lQtCore -Wl,-Bstatic -lGLU -Wl,-Bdynamic
-lGL
-lX11 -Wl,-Bstatic -lXext -Wl,-Bdynamic
/usr/bin/ld:
/usr/lib/gcc/x86_64-linux-gnu/4.5.2/../../../../lib/libboost_thread-mt.a(thread.o):
undefined reference to symbol 'pthread_getspecific@@GLIBC_2.2.5'
/usr/bin/ld: note: 'pthread_getspecific@@GLIBC_2.2.5' is defined in DSO
/lib64/libpthread.so.0 so try adding it to the linker command line
/lib64/libpthread.so.0: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
The link command actually lacks -pthread (no idea why this causes only a
problem
with the static boost library):
/usr/bin/c++ -frounding-math -g
CMakeFiles/Alpha_shapes_2.dir/Alpha_shapes_2.o
CMakeFiles/Alpha_shapes_2.dir/qrc_Alpha_shapes_2.o -o Alpha_shapes_2
-rdynamic
-Wl,-Bstatic -lCGAL_Qt4 -lCGAL -lgmpxx -lmpfr -lgmp -lboost_thread-mt
-Wl,-Bdynamic -lQtOpenGL -lQtGui -lQtCore -Wl,-Bstatic -lGLU -Wl,-Bdynamic
-lGL
-lX11 -Wl,-Bstatic -lXext -Wl,-Bdynamic -pthread
Unfortunately, this command eliminates only a few dependencies. Most of the
remaining ones are probably caused by Qt. Maybe you are luckier if you happen
to
have static libraries for Qt.
Joachim
- [cgal-discuss] link static, pascal8361, 04/17/2011
- Re: [cgal-discuss] link static, Joachim Reichel, 04/20/2011
- [cgal-discuss] Re: link static, pascal8361, 04/20/2011
- [cgal-discuss] Re: link static, pascal8361, 04/20/2011
- Re: [cgal-discuss] Re: link static, Joachim Reichel, 04/24/2011
- [cgal-discuss] Re: link static, pascal8361, 04/24/2011
- [cgal-discuss] Re: link static, pascal8361, 04/25/2011
- Re: [cgal-discuss] Re: link static, Joachim Reichel, 04/25/2011
- Re: [cgal-discuss] Re: link static, Qianqian Fang, 04/25/2011
- [cgal-discuss] Re: link static, pascal8361, 04/25/2011
- [cgal-discuss] Re: link static, pascal8361, 04/24/2011
- Re: [cgal-discuss] Re: link static, Joachim Reichel, 04/24/2011
- [cgal-discuss] Re: link static, pascal8361, 04/20/2011
- [cgal-discuss] Re: link static, pascal8361, 04/20/2011
- Re: [cgal-discuss] link static, Joachim Reichel, 04/20/2011
Archive powered by MHonArc 2.6.16.