Linking error

Hi,

I am facing some problems with linking the libraries in my projects. I am using qmake to generate the make files. I used the "same" pro files to generate the exectable on a mac, but when I switched to Linux64, it gives me linking error.

Basically, I have two applications : VF_Tool, and VF_UQ, that use the same libraries. I am able to build VF_UQ successfully. I am pasting below the commands that makefile is using to link the libraries.

1. VF_UQ :

g++ -m64 -Wl,-O1 -o ../bin.Linux64/release/Uncertainty obj/release/StreamThread.o obj/release/uncertainty.o obj/release/Viewer.o obj/release/qslim_dialog_edit.o obj/release/ibfv.o obj/release/ibfv_advection.o obj/release/texture.o obj/release/main.o obj/release/load_mesh_dialog.o obj/release/moc_uncertainty.o obj/release/moc_qslim_dialog_edit.o obj/release/moc_Viewer.o obj/release/moc_load_mesh_dialog.o obj/release/qrc_uncertainty.o -L/usr/lib64 -L/usr/X11R6/lib64 -L../QGLViewer -L../mixkit/src -L../lib.Linux64/release -lQGLViewer -L/usr/X11R6/lib64 -L/usr/lib64 -pthread-lVFViewer -lTriMesh_VF -lTriMesh_UQ -lSimplify -lVFV -lmix -lUtils -lQtXml -lQtOpenGL -lQtGui -pthread -lpng -lfreetype -lSM -lICE -lXrender -lXrandr -lXfixes -lXcursor -lXinerama -lfontconfig -lXext -lX11 -lQtCore -lz -lm -lgthread-2.0 -lrt -lglib-2.0 -lpthread -ldl -lGLU -lGL

Please note that this application depends upon the following libraries which I have compiled successfully in previous steps -
(a) libQGLViewer
(b) libVFViewer
(c) libTriMesh_VF
(d) libTriMesh_UQ
(e) libSimplify
(f) libUtils
(g) libVFV

2. VF_Tool:

g++ -m64 -o ../bin.Linux64/debug/VFTool obj/debug/graphwidget.o obj/debug/triwidget.o obj/debug/vftool.o obj/debug/main.o obj/debug/ErrZone.o obj/debug/moc_graphwidget.o obj/debug/moc_triwidget.o obj/debug/moc_vftool.o obj/debug/qrc_vftool.o -L/usr/lib64 -L/usr/X11R6/lib64 -L../QGLViewer -L../lib.Linux64/debug -lQGLViewer -L/usr/X11R6/lib64 -L/usr/lib64 -pthread -lTriMesh_VF -lTriMesh_UQ -lVFV -lUtils -lQtXml -pthread -pthread -lQtOpenGL -lQtGui -lpng -lfreetype -lSM -lICE -lXrender -lXrandr -lXfixes -lXcursor -lXinerama -lfontconfig -lXext -lX11 -lQtCore -lz -lm -lgthread-2.0 -lrt -lglib-2.0 -ldl -lGLU -lGL

This application depends upon
(a) libQGLViewer
(b) libTriMesh_VF
(c) libTriMesh_UQ
(d) libUtils

While VF_UQ links successfully, with the command posted in (1), VF_Tool gives the following error

../lib.Linux64/debug/libTriMesh_UQ.a(TriMesh_UQ.o): In function `TriMesh_UQ::doEdgeFlips()':
/Data/VectorFields/code/TriMesh_UQ/src/TriMesh_UQ.cc:415: undefined reference to `TriMesh::get_relativeCommonEdge(int, int) const'
/Data/VectorFields/code/TriMesh_UQ/src/TriMesh_UQ.cc:416: undefined reference to `TriMesh::get_relativeCommonEdge(int, int) const'
/Data/VectorFields/code/TriMesh_UQ/src/TriMesh_UQ.cc:425: undefined reference to `TriMesh::get_facePoints(int) const'
/Data/VectorFields/code/TriMesh_UQ/src/TriMesh_UQ.cc:426: undefined reference to `TriMesh::get_facePoints(int) const'

and more linking errors of the same kind. All the functions that the linker reports unreferenced are in the same cpp file, and should be in libTriMesh_VF.

I am confused as to why I am able to link one application successfully, while the other fails.

Any help is appreciated.

Thanks
Harsh
If libTriMesh_UQ depends on libTriMesh_VF, the the link line should specify -lTriMesh_UQ -lTriMesh_VF (in that order). The order of dependencies matters when linking.

It's possible that the VF_UQ program doesn't ever use these functions, but they are used in VF_Tool.
Right. Changing the order of libraries did the trick. I knew the 'unresolved' functions are used in both applications.

Thanks PanGalactic
Topic archived. No new replies allowed.