Xcode链接与glew错误

时间:2015-03-04 12:44:12

标签: c++ xcode opengl cmake glew

我尝试使用OpenGL 4.1编写项目。我通常在Windows和OS X之间切换。在Windows上,我使用Visual Studio 2013使用cmake制作项目。这很好用。在OS X上,当我使用cmake和-G" Unix Makefiles"我可以编译并运行得很好。但是,如果我生成一个Xcode项目,Xcode将无法构建错误:

ld: library not found for -lglew
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我正在使用此CMakeLists.txt。

cmake_minimum_required(VERSION 2.8.9)
project(Framework)

set(SRC_FILES src/shader.cpp  
              src/framework.cpp                 
              src/fileio.cpp    
              src/scene.cpp   
              src/renderable.cpp   
              src/camera.cpp  
              src/mesh.cpp   
              src/material.cpp 
              src/light.cpp 
              src/triangle.cpp 
              src/cube.cpp 
              src/basicshader.cpp
              src/frameworkmodel.cpp
              src/texture.cpp
              )

set(HEADER_FILES include/shader.h 
                 include/framework.h
                 include/fileio.h
                 include/scene.h
                 include/renderable.h
                 include/camera.h 
                 include/mesh.h   
                 include/material.h 
                 include/light.h 
                 include/triangle.h
                 include/cube.h
                 include/basicshader.h
                 include/frameworkmodel.h
                 include/texture.h
                 )



if (WIN32)
  list(APPEND SRC_FILES src/GLee.cpp src/glew.cpp)
  list(APPEND HEADER_FILES include/GLee.h include/glew.h)
endif()

if (APPLE)
  SET(GCC_COVERAGE_LINK_FLAGS "-framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -lglew")
endif()

set(GLFW_PATH glfw-3.1)
set(SOIL_PATH SOIL)

add_subdirectory(${GLFW_PATH})


include_directories(${GLFW_PATH}/include)
include_directories(${SOIL_PATH})

file(GLOB SOIL_SRC
    "${SOIL_PATH}/*.h"
    "${SOIL_PATH}/*.c"
)

include_directories(./include)

add_library(soil ${SOIL_SRC})

add_library(framework ${SRC_FILES} ${HEADER_FILES})
target_link_libraries(framework soil)

add_executable(test01 tests/test01.cpp)
target_link_libraries(test01 framework)
target_link_libraries(test01 glfw ${GLFW_LIBRARIES})
target_link_libraries(test01 glfw ${OPENGL_glu_LIBRARY} ${GLFW_LIBRARIES})
target_link_libraries(test01 glfw ${GCC_COVERAGE_LINK_FLAGS})

这有什么明显的错误吗?

我找到了我的glew安装的.dylib位置,并将其添加到xcode搜索路径,正常工作。

0 个答案:

没有答案