2014-04-12 11 views
5

Vì vậy, tôi có ấn bản thứ 6 superbible, và đang cố gắng để cmake và làm cho khuôn khổ mã ví dụ, nhưng nhận được lỗi này:rắc rối cố gắng xây dựng OpenGL mã ví dụ superbible

Scanning dependencies of target sb6 
[ 1%] Building CXX object CMakeFiles/sb6.dir/src/sb6/sb6.cpp.o 
[ 2%] Building CXX object CMakeFiles/sb6.dir/src/sb6/sb6ktx.cpp.o 
[ 3%] Building CXX object CMakeFiles/sb6.dir/src/sb6/sb6object.cpp.o 
[ 5%] Building CXX object CMakeFiles/sb6.dir/src/sb6/sb6shader.cpp.o 
[ 6%] Building C object CMakeFiles/sb6.dir/src/sb6/gl3w.c.o 
Linking CXX static library lib/libsb6.a 
[ 6%] Built target sb6 
Scanning dependencies of target alienrain 
[ 7%] Building CXX object CMakeFiles/alienrain.dir/src/alienrain/alienrain.cpp.o 
Linking CXX executable bin/alienrain 
CMakeFiles/alienrain.dir/src/alienrain/alienrain.cpp.o: In function `sb6::application::run(sb6::application*)': 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x21): undefined reference to `glfwInit' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x7a): undefined reference to `glfwOpenWindowHint' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x90): undefined reference to `glfwOpenWindowHint' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x9f): undefined reference to `glfwOpenWindowHint' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xae): undefined reference to `glfwOpenWindowHint' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xc4): undefined reference to `glfwOpenWindowHint' 
CMakeFiles/alienrain.dir/src/alienrain/alienrain.cpp.o:alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xee): more undefined references to `glfwOpenWindowHint' follow 
CMakeFiles/alienrain.dir/src/alienrain/alienrain.cpp.o: In function `sb6::application::run(sb6::application*)': 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x12c): undefined reference to `glfwGetDesktopMode' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x18e): undefined reference to `glfwOpenWindow' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x1a8): undefined reference to `glfwSwapInterval' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x1f2): undefined reference to `glfwOpenWindow' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x22e): undefined reference to `glfwSetWindowTitle' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x238): undefined reference to `glfwSetWindowSizeCallback' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x242): undefined reference to `glfwSetKeyCallback' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x24c): undefined reference to `glfwSetMouseButtonCallback' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x256): undefined reference to `glfwSetMousePosCallback' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x260): undefined reference to `glfwSetMouseWheelCallback' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x277): undefined reference to `glfwEnable' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x27e): undefined reference to `glfwDisable' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x28f): undefined reference to `glfwGetWindowParam' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x373): undefined reference to `glfwGetTime' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x393): undefined reference to `glfwSwapBuffers' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x39d): undefined reference to `glfwGetKey' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x3bd): undefined reference to `glfwGetWindowParam' 
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x3f5): undefined reference to `glfwTerminate' 
lib/libsb6.a(gl3w.c.o): In function `open_libgl': 
gl3w.c:(.text+0xf): undefined reference to `dlopen' 
lib/libsb6.a(gl3w.c.o): In function `close_libgl': 
gl3w.c:(.text+0x2b): undefined reference to `dlclose' 
lib/libsb6.a(gl3w.c.o): In function `get_proc': 
gl3w.c:(.text+0x45): undefined reference to `glXGetProcAddress' 
gl3w.c:(.text+0x66): undefined reference to `dlsym' 
collect2: error: ld returned 1 exit status 
make[2]: *** [bin/alienrain] Error 1 
make[1]: *** [CMakeFiles/alienrain.dir/all] Error 2 
make: *** [all] Error 2 

tôi đang thiếu gì? Theo như tôi có thể nói tôi đã cài đặt tất cả các phụ thuộc.

+0

Khá nhiều, rõ ràng. Bạn có thể cần phải thêm '-ldl' cho' dlopen' để được giải quyết, '-lGL' cho' glXGetProcAddress'. Tôi sẽ thừa nhận tôi không biết điều đầu tiên về CMake, tôi vẫn sử dụng gmake vì vậy tôi không thể bắt đầu nói với bạn làm thế nào để thêm những lá cờ liên kết không may. Đối với các công cụ GLFW, các tên ngụ ý GLFW2. Bạn có chắc chắn rằng bạn đã không cài đặt GLFW3 suy nghĩ nó sẽ đáp ứng phụ thuộc của bạn? Chúng không tương thích, rất nhiều thứ đã thay đổi. –

+0

Yeah ... Công cụ này dường như có đường cong học tập khá thù địch. Không chỉ là C++ một ngôn ngữ sử thi trong chính nó, nhưng ngay cả tất cả những thứ xung quanh nó liên quan đến biên dịch và liên kết và makefiles và tiêu đề và như vậy là ... tâm boggling. –

Trả lời

1

như @AndonMColeman đề xuất, bạn cần -lGL-ldlvào cuối trong danh sách thư viện. Sử dụng macro target_link_libraries cho việc này.

Nếu bạn cung cấp CMakeLists.txt từ dự án của bạn sẽ dễ dàng hơn nhiều để đề nghị bạn một chuỗi chính xác để thêm/thay đổi;)