3

I'm using Qt (5.5.1) with OpenSceneGraph (OSG-3.4.0) library. I have a basic "HelloWorld" project that compiles and works from Qt on another machine on Windows 7. But when I try to compile the same project on Linux (Lubuntu-14.04), the CMake within the Qt cannot find the OSG libraries. The strangest thing is that when I run cmake from command line, all the libraries are found - no problem.

So, that's how I search for libraries within my CMake project file:

# ...
find_package(OpenSceneGraph REQUIRED COMPONENTS osgDB osgGA osgUtil osgViewer)

include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS})
#...

target_link_libraries( ${PROJECT_NAME}
    ${OPENSCENEGRAPH_LIBRARIES}
    )

I also include some Qt libraries, and they are found with no problem.

When I check the location of CMake within the Qt (in Manage kits... menu), it shows me the same path as when I run which cmake from a command line. So, the cmake executable is the same, and is located at /usr/bin/. My cmake --version is 2.8.12.2.

My .zshrc contains all the paths for the installed OSG libraries (as it is described in OSG installation manual):

export OPENTHREADS_INC_DIR="/usr/local/include"
export OPENTHREADS_LIB_DIR="/usr/local/lib64:/usr/local/lib"
export PATH="$OPENTHREADS_LIB_DIR:$PATH"
export LD_LIBRARY_PATH="/usr/local/lib64:/usr/local/lib:$LD_LIBRARY_PATH"
export OSG_FILE_PATH="/usr/local/OpenSceneGraph/data:/usr/local/OpenSceneGraph/data/Images"

I found a temporal solution for my problem:

  • first I run cmake from a command line;
  • then I give Qt the location of just build folder.

This way everything works.

However, I want to know where is the problem so that I could run cmake from Qt; it's been buzzing me for several days, and I ran out of ideas what is wrong with my setup. Any hints and suggestions are appreciated.

UPD: here is the error message that I get when try to run CMake from Qt:

-- Could NOT find osgDB (missing:  OSGDB_LIBRARY) 
-- Could NOT find osgGA (missing:  OSGGA_LIBRARY) 
-- Could NOT find osgUtil (missing:  OSGUTIL_LIBRARY) 
-- Could NOT find osgViewer (missing:  OSGVIEWER_LIBRARY) 
-- Could NOT find osg (missing:  OSG_LIBRARY) 
-- Could NOT find OpenThreads (missing:  OPENTHREADS_LIBRARY) 
CMake Error at /usr/share/cmake-2.8/Modules /FindPackageHandleStandardArgs.cmake:108 (message):
Could NOT find OpenSceneGraph (missing: OPENSCENEGRAPH_LIBRARIES
OSGDB_FOUND OSGGA_FOUND OSGUTIL_FOUND OSGVIEWER_FOUND OSG_FOUND
OPENTHREADS_FOUND) (found version "3.4.0")

Call Stack (most recent call first):
/usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-2.8/Modules/FindOpenSceneGraph.cmake:187 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:19 (find_package)

-- Configuring incomplete, errors occurred!

The OSG library files are installed in:

/usr/local/bin
/usr/local/include
/usr/local/lib64

UPD2: as user1034749 suggested, it seems there is a problem with environment variables. When I launch QtCreator from a command line - everything works; if I launch it from a menu, then it cannot find the libraries.

vicrucann
  • 1,703
  • 1
  • 24
  • 34
  • 1
    If `cmake` works from command line and not works from your IDE (Qt creator?), then problem in environment variables, try run Qt creator from command line – fghj Nov 07 '15 at 17:54
  • More info needed: 1. Error message, when CMake failed to found package(it will show what exactly cannot be found). 2. Where the package is actually placed. – Tsyvarev Nov 07 '15 at 18:37
  • sorry, I forgot to display the error, it is now updated. – vicrucann Nov 07 '15 at 19:03
  • To user1034749: apparently, I cannot run qtcreator from command line! It is not xonfigured. I am trying to fix it now and see how it will behave if ran from a command line. Thank you for suggestion. – vicrucann Nov 07 '15 at 19:04
  • 1
    It seems that your `.zshrc` file contains PATH definition (`/usr/local/lib64`) which allow to `OSG`-related libraries, `OpenThreads` and `OpenSceneGraph` to be found (with `find_library` inside corresponded `find_package()`). Qt doesn't use your definitions file for some reason. For make Qt work, you may pass `CMAKE_LIBRARY_PATH=/usr/local/lib64` definition for its CMake. – Tsyvarev Nov 07 '15 at 21:11
  • @Tsyvarev, you are right. I will try to see how to fix that. – vicrucann Nov 08 '15 at 15:44
  • You can try to use ~/.profile to export your variables – Vitalii Minnakhmetov Nov 09 '15 at 03:11

1 Answers1

1

Unfortunately I could not find how to fix the problem with the given setup. I discovered my Qt was not installed correctly on my Linux machine. To fix the problem: I had to remove all the Qt versions from my Linux machine and then re-install a new Qt version.

vicrucann
  • 1,703
  • 1
  • 24
  • 34