cmake:oglplus找不到上下文初始化库(glfw)

时间:2013-12-07 18:44:57

标签: cmake glfw

我尝试使用cmake构建oglplus(OpenGL的C ++包装器)(在OS X 10.9上使用Xcode 5 / Clang 5.0.0)。

但是要这样做,需要一个上下文初始化库(即GLUT,GLFW,GLFW3,GL3W,QT4,SDL,wxWidgets)。但是我尝试多次编译和安装GLFW和GLFW3:但是来自oglplus的cmake文件仍然不会使用它们。

cmake输出说:

cmake -G Xcode
-- The C compiler identification is Clang 5.0.0
-- The CXX compiler identification is Clang 5.0.0
-- Check for working C compiler using: Xcode
-- Check for working C compiler using: Xcode -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Xcode
-- Check for working CXX compiler using: Xcode -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Could NOT find PkgConfig (missing:  PKG_CONFIG_EXECUTABLE) 
-- Found GLEW: /usr/local/include /Library/Frameworks/GLEW.framework
-- Could NOT find GL3W
-- Could NOT compile or link with GLFW
-- Could NOT compile or link with GLFW3
-- Could NOT find GLUT (missing:  GLUT_INCLUDE_DIR) 
-- GLUT header file not found
-- Could NOT find wxWidgets (missing:  wxWidgets_FOUND) 
-- Could NOT find Qt4 (missing:  QT_QMAKE_EXECUTABLE QT_MOC_EXECUTABLE QT_RCC_EXECUTABLE QT_INCLUDE_DIR QT_LIBRARY_DIR QT_QTCORE_INCLUDE_DIR QT_QTCORE_LIBRARY QT_QTGUI_INCLUDE_DIR QT_QTGUI_LIBRARY QT_QTOPENGL_INCLUDE_DIR QT_QTOPENGL_LIBRARY QT_UIC_EXECUTABLE) 
-- Could NOT find SDL
-- GLM header files not found
-- Found PNG: /usr/local/include /usr/local/lib/libpng.dylib
-- Detecting support for c++11 feature 'SCOPED_ENUMS': TRUE
-- Detecting support for c++11 feature 'VARIADIC_MACROS': TRUE
-- Detecting support for c++11 feature 'VARIADIC_TEMPLATES': TRUE
-- Detecting support for c++11 feature 'UNIFIED_INITIALIZATION_SYNTAX': TRUE
-- Detecting support for c++11 feature 'INITIALIZER_LISTS': TRUE
-- Detecting support for c++11 feature 'DEFAULTED_FUNCTIONS': TRUE
-- Detecting support for c++11 feature 'DELETED_FUNCTIONS': TRUE
-- Detecting support for c++11 feature 'EXPLICIT_CONVERSION_OPERATORS': TRUE
-- Detecting support for c++11 feature 'FUNCTION_TEMPLATE_DEFAULT_ARGS': TRUE
-- Detecting support for c++11 feature 'UNICODE_LITERALS': TRUE
-- Detecting support for c++11 feature 'USER_DEFINED_LITERALS': TRUE
-- Detecting support for c++11 feature 'CONSTEXPR': TRUE
-- Detecting support for c++11 feature 'NOEXCEPT': TRUE
-- Detecting support for c++11 feature 'LAMBDAS': TRUE
-- Detecting support for c++11 feature 'NULLPTR': TRUE
-- Detecting support for c++11 feature 'CHRONO': TRUE
-- Detecting support for c++11 feature 'THREADS': TRUE
-- Could NOT find Boost
CMake Error at CMakeLists.txt:122 (message):
  No OpenGL context initialization library found!

所以看起来它可以找到GLFW / GLFW3,因为出于某种原因它会说Could NOT compile or link with *而不是Could NOT find *。我对cmake脚本并不熟悉,所以我不知道如何在这里检查原因。

有什么想法可以解决这个问题吗?

3 个答案:

答案 0 :(得分:2)

我遇到了类似的问题,似乎找到了GLFW并编译了一个测试程序以检查它是否有效。简单地说,使用MSVC工具链,测试失败。

最简单的解决方法是删除/重命名测试程序(oglplus / config / ext_lib / test_glfw.cpp和/或test_glfw3.cpp)

答案 1 :(得分:1)

您是否阅读过GitHub上的文档?直接提取:

  

基于CMake的构建配置

     

CMake脚本定义并使用多个变量来修改   构建配置,可以在命令行中指定   调用cmake(使用-D选项。有关详细信息,请参阅cmake手册):

     
      
  • HEADER_SEARCH_PATHS :(以分号分隔)在查找第三方标题时要搜索的其他目录的路径列表,例如GL/glew.hGL3/gl3.hGL/glcorearb.h等。
  •   
  • LIBRARY_SEARCH_PATHS :(以分号分隔的)查找其他目录的路径列表,以查找第三方二进制库,如GL,GLEW,GL3W,GLFW,SDL,GLUT,png等。
  •   

此外,OGLplus实际上是一个仅限标头的库,因此您可以简单地跳过构建示例/演示和测试,以便根本不需要与第三方库链接。您甚至可以将标题复制到您想要的位置,只需在不运行CMake的情况下使用它(上次使用它时,此方法工作正常,可能已更改,因此请自行检查)。

答案 2 :(得分:1)

我知道这是一个老问题,但我也遇到了问题。

请确保为glfw,glfw3或cmake中要使用的任何内容指定include和lib文件夹。

It should look similar to this.