简体   繁体   中英

Compile OpenSceneGraph with Cmake under Windows

I am trying to set up Openscenegraph 3.0.1 with Cmake. I read different blog posts but it doesn't work.

I set up the paths, click compile and selected VS11 (because I have VS 2012) and use native compiler.

Then I directly get this error:

CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules  CMakeCInformation.cmake:37 (get_filename_component):
get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
CMakeLists.txt:3 (PROJECT)


CMake Error: Internal CMake error, TryCompile configure of cmake failed
Looking for include file pthread.h - not found

Also, more errors with the same stack trace occur. Also also could paste them here if you wish.

Afterwards, CMake tells me "Error in configuration process, project files may be invalid"

your problem isn't in compiler version that you are using; in fact, i'm running OpenSceneGraph 3(and osgEarth) with no problems on VisualStudio 2012.

What it seems to be is a problem with Cmake/CMakeLists.txt itself. Try to build some other projects using cmake, to see whether they work, or try to use a version of CMake that is close to what OpenSceneGraph needs(look at CMAKE_MINIMUM_REQUIRED in main CMakeLists.txt file), although CMake language is meant to be compatible with earlier versions, i dont know if this is always the case.

pthread.h has nothing to do with your problem, DOESN'T EXIST in Windows(except if you are using MinGW to look for some more problems), and is not required by OSG - i think, you configured OpenThreads correctly to not use libs you don't have. Anyway, that's just part of the job CMake does on each build - looks for some random stuff, like whether it can find pthreads.h or not, that give CMake some idea about your environment and don't usually relate to the projects you build with cmake. So just ignore that line about pthread.h

Under normal circumstances, CMake shouldn't be looking for pthread for Windows. Following is the couple of lines in CMake's (2.8) FindThreads.cmake which is used for searching appropriate modules.

  ...      
    CHECK_INCLUDE_FILES("pthread.h" CMAKE_HAVE_PTHREAD_H)
    if(CMAKE_HAVE_PTHREAD_H) 
      ...
    endif()
  ...

  if(CMAKE_SYSTEM MATCHES "Windows")
    set(CMAKE_USE_WIN32_THREADS_INIT 1)
    set(Threads_FOUND TRUE)
  endif()

As you can see, first check should fail and roll out till the second check. However, I believe that in your case, CMake somehow finds that pthread.h (maybe you have MinGW as well) This seems to be a simple conflict in your system. Check your system's PATH etc. and try to fix it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM