2014-04-12 18 views
5

così ho preso la 6 ° edizione superbible, e sto cercando di cmake e rendere il quadro codice di esempio, ma questo errore:problemi cercando di costruire opengl codice di esempio 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 

Che cosa mi manca? Per quanto posso dire ho già installato tutte le dipendenze.

+0

un bel po ', a quanto pare. Potrebbe essere necessario aggiungere '-ldl' per' dlopen' da risolvere, '-lGL' per' glXGetProcAddress'. Devo ammettere che non conosco la prima cosa su CMake, uso ancora gmake, quindi non posso iniziare a dirti come aggiungere quelle bandiere linker sfortunatamente. Per quanto riguarda il materiale GLFW, i nomi implicano GLFW2. Sei sicuro di non aver installato GLFW3 pensando che avrebbe soddisfatto le tue dipendenze? Non sono compatibili, molte cose sono cambiate. –

+0

Sì ... Questa roba sembra avere una curva di apprendimento ostile. Non solo è C++ un linguaggio epico in sé, ma anche tutte le cose che lo circondano per quanto riguarda la compilazione e il collegamento, i makefile e le intestazioni e così via sono ... sconvolgenti. –

risposta

1

come suggerito @AndonMColeman, è necessario -lGL e -ldlalla fine della lista librerie. Utilizzare la macro target_link_libraries per questo.

Se si fornisce CMakeLists.txt dal progetto sarebbe molto più facile da suggerire una stringa esatta per aggiungere/modificare;)