Results 1 to 3 of 3

Thread: Suggestion in library inclusion with rpath

  1. #1
    Join Date
    Mar 2011
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Suggestion in library inclusion with rpath

    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

    Qt Code:
    1. 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

    Qt Code:
    1. /mylib/libmesh-config --ldflags
    To copy to clipboard, switch view to plain text mode 

    I obtain something like this

    Qt Code:
    1. /mydir/lib/x86_64-unknown-linux-gnu_dbg/libmesh.so
    2. /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/liblaspack.so
    3. /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libparmetis.so
    4. /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libmetis.so
    5. /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libsfcurves.so
    6. /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libgzstream.so -lz
    7. /mydir/contrib/tecplot/lib/x86_64-unknown-linux-gnu/tecio.a
    8. /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libgmv.so -Wl,-rpath,/usr/lib
    9. -L/usr/lib -lvtkIO -lvtkCommon -lvtkFiltering -Wl,-rpath,/usr/lib
    10. -L/usr/lib -lglpk
    11. /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libtetgen.so
    12. /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libtriangle.so
    13. /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libexodusii.so
    14. /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libnetcdf.so
    15. /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libnemesis.so
    16. /mydir/contrib/lib/x86_64-unknown-linux-gnu_dbg/libHilbert.so -Wl,-rpath,/home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/lib
    17. -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
    18. -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

    Qt Code:
    1. ## Adding libraries ##
    2. unix {
    3. TMPLIBS = $$system(/home/daniele/programs/libmesh-0.7.1/libmesh/contrib/bin/libmesh-config --ldflags)
    4. LIBS += $$TMPLIBS
    5. }
    To copy to clipboard, switch view to plain text mode 

    and, if I print the LIBS variable (using message command) I obtain:

    Qt Code:
    1. 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

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Suggestion in library inclusion with rpath

    You are doing the correct thing. You are missing a library from the list, or the library no longer exists where the config says it does, but since you don't tell us what the error messages are we cannot even guess what it might be.

    The -rpath setting adds a directory to the runtime library search path (which can have problems after deployment) but should have no effect at build time.

  3. #3
    Join Date
    Mar 2011
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Suggestion in library inclusion with rpath

    Ok, I'll be more explicit...

    I compile manually the main.cpp of the project with this command:

    Qt Code:
    1. c++ -o test main.cpp `/home/daniele/programs/libmesh-0.7.1/libmesh/contrib/bin/libmesh-config --cxxflags --include --ldflags`
    To copy to clipboard, switch view to plain text mode 

    I obtain only some warning (unused parameter of the library), but with this command program compiles and the executable file works well.

    The complete .pro file of my project is this one:

    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2011-05-04T12:27:57
    4. #
    5. #-------------------------------------------------
    6. QT += core
    7.  
    8. QT -= gui
    9.  
    10. TARGET = test
    11. CONFIG += console
    12. CONFIG -= app_bundle
    13.  
    14. TEMPLATE = app
    15.  
    16.  
    17.  
    18. SOURCES += main.cpp
    19.  
    20. #-------------------------------------------------
    21. # Adding libmesh library
    22. #-------------------------------------------------
    23.  
    24. ## Adding include paths ##
    25. unix {
    26. TMPPATHS = $$system(/home/daniele/programs/libmesh-0.7.1/libmesh/contrib/bin/libmesh-config --include)
    27. INCLUDEPATH += $$replace(TMPPATHS, "-I", "")
    28. }
    29.  
    30. # Printing paths
    31. message(INCLUDEPATH = $$INCLUDEPATH)
    32.  
    33. ## Adding libraries ##
    34. unix {
    35.  
    36. TMPLIBS = $$system(/home/daniele/programs/libmesh-0.7.1/libmesh/contrib/bin/libmesh-config --ldflags)
    37. LIBS += $$TMPLIBS
    38.  
    39. }
    40.  
    41. # Printing libs
    42. message($$LIBS)
    43.  
    44. ## Adding compiler flags ##
    45. unix {
    46. QMAKE_CXXFLAGS += $$system(/home/daniele/programs/libmesh-0.7.1/libmesh/contrib/bin/libmesh-config --cxxflags)
    47. }
    To copy to clipboard, switch view to plain text mode 

    The compile output error is this one:

    Qt Code:
    1. main.o: In function `main':
    2. /home/daniele/Documenti/qt/test/test-build-desktop/../test/main.cpp:38: undefined reference to `libMesh::System::add_variable(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, libMeshEnums::Order, libMeshEnums::FEFamily, std::set<unsigned char, std::less<unsigned char>, std::allocator<unsigned char> > const*)'
    3. main.o: In function `assemble_1D(libMesh::EquationSystems&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
    4. /home/daniele/Documenti/qt/test/test-build-desktop/../test/main.cpp:125: undefined reference to `libMesh::DofMap::dof_indices(libMesh::Elem const*, std::vector<unsigned int, std::allocator<unsigned int> >&, unsigned int) const'
    5. /home/daniele/Documenti/qt/test/test-build-desktop/../test/main.cpp:162: undefined reference to `libMesh::DofMap::constrain_element_matrix_and_vector(libMesh::DenseMatrix<double>&, libMesh::DenseVector<double>&, std::vector<unsigned int, std::allocator<unsigned int> >&, bool) const'
    6. main.o: In function `libMesh::MeshOutput<libMesh::MeshBase>::write_equation_systems(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, libMesh::EquationSystems const&)':
    7. /home/daniele/Documenti/qt/test/test-build-desktop/../../../../programs/libmesh-0.7.1/libmesh/include/mesh/mesh_output.h:233: undefined reference to `libMesh::MeshOutput<libMesh::MeshBase>::_build_variable_names_and_solution_vector(libMesh::EquationSystems const&, std::vector<double, std::allocator<double> >&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&)'
    8. main.o:(.rodata._ZTVN7libMesh16StatisticsVectorIfEE[vtable for libMesh::StatisticsVector<float>]+0x70): undefined reference to `libMesh::StatisticsVector<float>::histogram(std::vector<unsigned int, std::allocator<unsigned int> >&, unsigned int)'
    9. main.o:(.rodata._ZTVN7libMesh16StatisticsVectorIfEE[vtable for libMesh::StatisticsVector<float>]+0x78): undefined reference to `libMesh::StatisticsVector<float>::histogram(std::vector<unsigned int, std::allocator<unsigned int> >&, unsigned int) const'
    10. main.o:(.rodata._ZTVN7libMesh6FEBaseE[vtable for libMesh::FEBase]+0x68): undefined reference to `libMesh::FEBase::compute_map(std::vector<double, std::allocator<double> > const&, libMesh::Elem const*)'
    11. main.o:(.rodata._ZTVN7libMesh6FEBaseE[vtable for libMesh::FEBase]+0x70): undefined reference to `libMesh::FEBase::compute_affine_map(std::vector<double, std::allocator<double> > const&, libMesh::Elem const*)'
    12. collect2: ld returned 1 exit status
    13. make: Leaving directory `/home/daniele/Documenti/qt/test/test-build-desktop'
    14. make: *** [test] Error 1
    15. The process "/usr/bin/make" exited with code 2.
    16. Error while building project test (target: Desktop)
    17. When executing build step 'Make'
    To copy to clipboard, switch view to plain text mode 

    If I search the method of the last error, for example (compute_affine_map) I find it in the fe_base.h file, that's in the libmesh-0.7.1/libmesh/src/fe path, that's included in the INCLUDEDPATH variable, as you can see in the .pro message below.

    Qt Code:
    1. Project MESSAGE: INCLUDEPATH = /home/daniele/programs/libmesh-0.7.1/libmesh/include/base /home/daniele/programs/libmesh-0.7.1/libmesh/include/enums /home/daniele/programs/libmesh-0.7.1/libmesh/include/error_estimation /home/daniele/programs/libmesh-0.7.1/libmesh/include/fe /home/daniele/programs/libmesh-0.7.1/libmesh/include/geom /home/daniele/programs/libmesh-0.7.1/libmesh/include/mesh /home/daniele/programs/libmesh-0.7.1/libmesh/include/numerics /home/daniele/programs/libmesh-0.7.1/libmesh/include/parallel /home/daniele/programs/libmesh-0.7.1/libmesh/include/partitioning /home/daniele/programs/libmesh-0.7.1/libmesh/include/quadrature /home/daniele/programs/libmesh-0.7.1/libmesh/include/solvers /home/daniele/programs/libmesh-0.7.1/libmesh/include/systems /home/daniele/programs/libmesh-0.7.1/libmesh/include/utils /home/daniele/programs/libmesh-0.7.1/libmesh/contrib/boost /home/daniele/programs/libmesh-0.7.1/libmesh/contrib/laspack /home/daniele/programs/libmesh-0.7.1/libmesh/contrib/parmetis/Lib /home/daniele/programs/libmesh-0.7.1/libmesh/contrib/metis/Lib /home/daniele/programs/libmesh-0.7.1/libmesh/contrib/sfcurves /home/daniele/programs/libmesh-0.7.1/libmesh/contrib/gzstream /home/daniele/programs/libmesh-0.7.1/libmesh/contrib/tecplot/include /home/daniele/programs/libmesh-0.7.1/libmesh/contrib/gmv /usr/include/vtk-5.4 /usr/include /home/daniele/programs/libmesh-0.7.1/libmesh/contrib/tetgen /home/daniele/programs/libmesh-0.7.1/libmesh/contrib/triangle /home/daniele/programs/libmesh-0.7.1/libmesh/contrib/exodusii/Lib/include /home/daniele/programs/libmesh-0.7.1/libmesh/contrib/netcdf/Lib /home/daniele/programs/libmesh-0.7.1/libmesh/contrib/nemesis/Lib /home/daniele/programs/libmesh-0.7.1/libmesh/contrib/libHilbert/include /home/daniele/programs/petsc-3.1-p8/include /home/daniele/programs/petsc-3.1-p8/bmake/linux-gnu-dbg /home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/include /home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/include /home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/include /home/daniele/programs/petsc-3.1-p8/linux-gnu-dbg/include
    To copy to clipboard, switch view to plain text mode 

    Have you any suggestion, please?


    Added after 28 minutes:


    Ok, now it seems to work. It seems that I had to clear and rebuild the project...

    Thank you very much!!!
    Last edited by jepessen; 9th May 2011 at 09:07.

Similar Threads

  1. How to set rpath in Qt Project?
    By Kevin Hoang in forum General Programming
    Replies: 2
    Last Post: 30th March 2011, 03:05
  2. Class inclusion
    By denim83 in forum Newbie
    Replies: 7
    Last Post: 18th June 2010, 12:53
  3. Why doesn't Eclipse find a correct inclusion?
    By Cruz in forum Installation and Deployment
    Replies: 4
    Last Post: 1st October 2009, 12:25
  4. dll file inclusion
    By omprakash in forum Qt Programming
    Replies: 3
    Last Post: 31st July 2008, 19:41
  5. AVOIDING mutiple inclusion of header file???
    By pratik in forum General Programming
    Replies: 4
    Last Post: 10th July 2007, 14:09

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.