2017-05-06 112 views
0

我正在閱讀this tutorial on OpenGL。我收到編譯錯誤如下:無法編譯GLFW,未定義符號

Undefined symbols for architecture x86_64: 
    "_glfwInit", referenced from: 
     _main in main.cpp.o 
    "_glfwTerminate", referenced from: 
     _main in main.cpp.o 
ld: symbol(s) not found for architecture x86_64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 
make[3]: *** [OpenGL] Error 1 
make[2]: *** [CMakeFiles/OpenGL.dir/all] Error 2 
make[1]: *** [CMakeFiles/OpenGL.dir/rule] Error 2 
make: *** [OpenGL] Error 2 

現在,我將列出我的當前設置,與我的main.cpp

#include <iostream> 
#include <GLFW/glfw3.h> 
#include <thread> 

int main() { 
    glfwInit(); 
    std::this_thread::sleep_for(std::chrono::seconds(1)); 
    glfwTerminate(); 
    return 0; 
} 

這裏開始我的CMake的文件

cmake_minimum_required(VERSION 3.7) 
project(OpenGL) 

set(CMAKE_CXX_STANDARD 11) 

set(SOURCE_FILES main.cpp) 
add_executable(OpenGL ${SOURCE_FILES}) 

而且最後我的命令行參數:

-lglfw -framework Cocoa -framework OpenGL - 
framework IOKit -framework CoreVideo 

我使用CLion,我相信我已經正確編譯它。我只是試圖弄到一個空白的窗口。

回答

1

如果您使用CMake,爲什麼要在命令行上指定庫?將target_link_libraries指令納入您的CMakeLists.txt

相關問題