Hi. I'm trying of use the libmesh library in a project. When I compile a test file by hand, I use a command like this
c++ -o foo foo.C `/mylib/libmesh-config --cxxflags --include --ldflags`
c++ -o foo foo.C `/mylib/libmesh-config --cxxflags --include --ldflags`
To copy to clipboard, switch view to plain text mode
when I use the --ldflags option
/mylib/libmesh-config --ldflags
/mylib/libmesh-config --ldflags
To copy to clipboard, switch view to plain text mode
I obtain something like this
/mydir/lib/x86_64-unknown-linux-gnu_dbg/libmesh.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/liblaspack.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libparmetis.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libmetis.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libsfcurves.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libgzstream.so -lz
/mydir/contrib/tecplot/lib/x86_64-unknown-linux-gnu/tecio.a
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libgmv.so -Wl,-rpath,/usr/lib
-L/usr/lib -lvtkIO -lvtkCommon -lvtkFiltering -Wl,-rpath,/usr/lib
-L/usr/lib -lglpk
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libtetgen.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libtriangle.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libexodusii.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libnetcdf.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libnemesis.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libHilbert.so -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib
-L/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -lpetsc -lX11 -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib
-L/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -lsuperlu_4.0 -lsuperlu_dist_2.4 -lparmetis -lmetis -lHYPRE -Wl,-rpath,/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2 -Wl,-rpath,/usr/lib/x86_64-linux-gnu -lmpichcxx -lstdc++ -lspooles -lumfpack -lamd -lflapack -lfblas -lnsl -lrt -lm -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -L/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -Wl,-rpath,/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2 -L/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2 -Wl,-rpath,/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -ldl -lmpich -lpthread -lrt -lgcc_s -lmpichf90 -lgfortran -lm -lm -lmpichcxx -lstdc++ -ldl -lmpich -lpthread -lrt -lgcc_s -ldl -lnsl -lrt -Wl,-rpath,/mydir/lib/x86_64-unknown-linux-gnu_dbg -Wl,-rpath,/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -Wl,-rpath,/mydir/lib/x86_64-unknown-linux-gnu_dbg -Wl,-rpath,/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib
/mydir/lib/x86_64-unknown-linux-gnu_dbg/libmesh.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/liblaspack.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libparmetis.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libmetis.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libsfcurves.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libgzstream.so -lz
/mydir/contrib/tecplot/lib/x86_64-unknown-linux-gnu/tecio.a
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libgmv.so -Wl,-rpath,/usr/lib
-L/usr/lib -lvtkIO -lvtkCommon -lvtkFiltering -Wl,-rpath,/usr/lib
-L/usr/lib -lglpk
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libtetgen.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libtriangle.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libexodusii.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libnetcdf.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libnemesis.so
/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libHilbert.so -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib
-L/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -lpetsc -lX11 -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib
-L/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -lsuperlu_4.0 -lsuperlu_dist_2.4 -lparmetis -lmetis -lHYPRE -Wl,-rpath,/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2 -Wl,-rpath,/usr/lib/x86_64-linux-gnu -lmpichcxx -lstdc++ -lspooles -lumfpack -lamd -lflapack -lfblas -lnsl -lrt -lm -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -L/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -Wl,-rpath,/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2 -L/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2 -Wl,-rpath,/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -ldl -lmpich -lpthread -lrt -lgcc_s -lmpichf90 -lgfortran -lm -lm -lmpichcxx -lstdc++ -ldl -lmpich -lpthread -lrt -lgcc_s -ldl -lnsl -lrt -Wl,-rpath,/mydir/lib/x86_64-unknown-linux-gnu_dbg -Wl,-rpath,/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -Wl,-rpath,/mydir/lib/x86_64-unknown-linux-gnu_dbg -Wl,-rpath,/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib
To copy to clipboard, switch view to plain text mode
I add these libraries using this code in the .pro file
## Adding libraries ##
unix {
TMPLIBS = $$system(/home/daniele/programs/libmesh-0.7.1/libmesh/contrib/bin/libmesh-config --ldflags)
LIBS += $$TMPLIBS
}
## Adding libraries ##
unix {
TMPLIBS = $$system(/home/daniele/programs/libmesh-0.7.1/libmesh/contrib/bin/libmesh-config --ldflags)
LIBS += $$TMPLIBS
}
To copy to clipboard, switch view to plain text mode
and, if I print the LIBS variable (using message command) I obtain:
Project MESSAGE: LIBS = /mydir/lib/x86_64-unknown-linux-gnu_dbg/libmesh.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/liblaspack.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libparmetis.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libmetis.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libsfcurves.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libgzstream.so -lz /mydir/contrib/tecplot/lib/x86_64-unknown-linux-gnu/tecio.a /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libgmv.so -Wl,-rpath,/usr/lib -L/usr/lib -lvtkIO -lvtkCommon -lvtkFiltering -Wl,-rpath,/usr/lib -L/usr/lib -lglpk /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libtetgen.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libtriangle.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libexodusii.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libnetcdf.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libnemesis.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libHilbert.so -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -L/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -lpetsc -lX11 -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -L/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -lsuperlu_4.0 -lsuperlu_dist_2.4 -lparmetis -lmetis -lHYPRE -Wl,-rpath,/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2 -Wl,-rpath,/usr/lib/x86_64-linux-gnu -lmpichcxx -lstdc++ -lspooles -lumfpack -lamd -lflapack -lfblas -lnsl -lrt -lm -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -L/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -Wl,-rpath,/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2 -L/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2 -Wl,-rpath,/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -ldl -lmpich -lpthread -lrt -lgcc_s -lmpichf90 -lgfortran -lm -lm -lmpichcxx -lstdc++ -ldl -lmpich -lpthread -lrt -lgcc_s -ldl -lnsl -lrt -Wl,-rpath,/mydir/lib/x86_64-unknown-linux-gnu_dbg -Wl,-rpath,/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -Wl,-rpath,/mydir/lib/x86_64-unknown-linux-gnu_dbg -Wl,-rpath,/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib
Project MESSAGE: LIBS = /mydir/lib/x86_64-unknown-linux-gnu_dbg/libmesh.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/liblaspack.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libparmetis.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libmetis.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libsfcurves.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libgzstream.so -lz /mydir/contrib/tecplot/lib/x86_64-unknown-linux-gnu/tecio.a /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libgmv.so -Wl,-rpath,/usr/lib -L/usr/lib -lvtkIO -lvtkCommon -lvtkFiltering -Wl,-rpath,/usr/lib -L/usr/lib -lglpk /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libtetgen.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libtriangle.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libexodusii.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libnetcdf.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libnemesis.so /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libHilbert.so -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -L/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -lpetsc -lX11 -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -L/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -lsuperlu_4.0 -lsuperlu_dist_2.4 -lparmetis -lmetis -lHYPRE -Wl,-rpath,/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2 -Wl,-rpath,/usr/lib/x86_64-linux-gnu -lmpichcxx -lstdc++ -lspooles -lumfpack -lamd -lflapack -lfblas -lnsl -lrt -lm -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -L/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -Wl,-rpath,/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2 -L/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2 -Wl,-rpath,/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -ldl -lmpich -lpthread -lrt -lgcc_s -lmpichf90 -lgfortran -lm -lm -lmpichcxx -lstdc++ -ldl -lmpich -lpthread -lrt -lgcc_s -ldl -lnsl -lrt -Wl,-rpath,/mydir/lib/x86_64-unknown-linux-gnu_dbg -Wl,-rpath,/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib -Wl,-rpath,/mydir/lib/x86_64-unknown-linux-gnu_dbg -Wl,-rpath,/mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib
To copy to clipboard, switch view to plain text mode
But, in these case, it yet fails to load some library. Without this code, I got a lot of compiler error (about 50), while using this code errors (all of the type "undefined reference") are only 4, but not zero.
I've seen in the variale something like -rpath with commas around it, and I don't know what's this. I don't know if this is the cause of my error, and I'd like to know how insert all libraries in a correct way.
Thanks in advance for your reply
Bookmarks