Ubuntu 14.04中的OpenGL 4.3开发设置

时间:2014-07-29 19:38:38

标签: c++ linux opengl ubuntu

我刚刚开始使用OpenGL SuperBible第6版,我很难在Ubuntu 14.04上编译任何样本。我安装了dev packages依赖项:

sudo apt-get install xorg-dev libglu1-mesa-dev libglfw-dev nvidia-331-dev cmake

我从skaslev的github抓起了gl3w,运行了python脚本,然后sudo将gl3w.h和glcorearb.h复制到/ usr / include / GL /

我从SuperBible github和媒体文件中抓取样本,将媒体文件解压缩到bin / media中。然后我回到sb6文件的根目录(在我的情况下,该文件夹名为sb6code_2013_11_10),然后运行:

cmake .
make

cmake 工作正常,但 make 会抛出:

[  6%] Built target sb6
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

所以我决定尝试编写自己的小程序,基于清单2.1中的书:

#include "sb6.h"

class my_application : public sb6::application
{
    void init()
    {
        static const char title[] = "OpenGL SuperBible - Listing 2.1";

        sb6::application::init();

        memcpy(info.title, title, sizeof(title));
    }

    void render(double currentTime)
    {
        static const GLfloat red[] = {1.0f, 0.0f, 0.0f, 1.0f};
        glClearBufferfv(GL_COLOR, 0, red);
    }


};

DECLARE_MAIN(my_application)

然后我尝试编译它:

g++ listing2.1.cpp -o listing2.1 -lGL -lGLU -lX11 -lglfw -D_LINUX

但这给了我一组不同的错误:

In file included from sb6.h:65:0,
                 from listing2.1.cpp:1:
GL/gl3w.h:546:8: error: ‘PFNGLGETNMAPDVARBPROC’ does not name a type
 extern PFNGLGETNMAPDVARBPROC gl3wGetnMapdvARB;
        ^
GL/gl3w.h:547:8: error: ‘PFNGLGETNMAPFVARBPROC’ does not name a type
 extern PFNGLGETNMAPFVARBPROC gl3wGetnMapfvARB;
        ^
GL/gl3w.h:548:8: error: ‘PFNGLGETNMAPIVARBPROC’ does not name a type
 extern PFNGLGETNMAPIVARBPROC gl3wGetnMapivARB;
        ^
GL/gl3w.h:549:8: error: ‘PFNGLGETNPIXELMAPFVARBPROC’ does not name a type
 extern PFNGLGETNPIXELMAPFVARBPROC gl3wGetnPixelMapfvARB;
        ^
GL/gl3w.h:550:8: error: ‘PFNGLGETNPIXELMAPUIVARBPROC’ does not name a type
 extern PFNGLGETNPIXELMAPUIVARBPROC gl3wGetnPixelMapuivARB;
        ^
GL/gl3w.h:551:8: error: ‘PFNGLGETNPIXELMAPUSVARBPROC’ does not name a type
 extern PFNGLGETNPIXELMAPUSVARBPROC gl3wGetnPixelMapusvARB;
        ^
GL/gl3w.h:552:8: error: ‘PFNGLGETNPOLYGONSTIPPLEARBPROC’ does not name a type
 extern PFNGLGETNPOLYGONSTIPPLEARBPROC gl3wGetnPolygonStippleARB;
        ^
GL/gl3w.h:553:8: error: ‘PFNGLGETNCOLORTABLEARBPROC’ does not name a type
 extern PFNGLGETNCOLORTABLEARBPROC gl3wGetnColorTableARB;
        ^
GL/gl3w.h:554:8: error: ‘PFNGLGETNCONVOLUTIONFILTERARBPROC’ does not name a type
 extern PFNGLGETNCONVOLUTIONFILTERARBPROC gl3wGetnConvolutionFilterARB;
        ^
GL/gl3w.h:555:8: error: ‘PFNGLGETNSEPARABLEFILTERARBPROC’ does not name a type
 extern PFNGLGETNSEPARABLEFILTERARBPROC gl3wGetnSeparableFilterARB;
        ^
GL/gl3w.h:556:8: error: ‘PFNGLGETNHISTOGRAMARBPROC’ does not name a type
 extern PFNGLGETNHISTOGRAMARBPROC gl3wGetnHistogramARB;
        ^
GL/gl3w.h:557:8: error: ‘PFNGLGETNMINMAXARBPROC’ does not name a type
 extern PFNGLGETNMINMAXARBPROC gl3wGetnMinmaxARB;
        ^

我在sb6.h中检查过gl3w.h是否包含在任何OpenGL依赖项之前,这是真的,所以我真的不确定下一步该尝试什么。似乎是一个链接问题,但是我已经很长一段时间了,因为我一直在用C ++开发,而且我不确定下一步该尝试什么。

更新

我按照didierc的建议,发现有一个带有gl3w.h和glcorearb.h的sb6code_2013_11_10 / include / GL文件夹。我暂时将GL文件夹移出sb6code_2013_11_10 / include,然后再次运行 cmake make ,然后收到以下错误:

Scanning dependencies of target sb6
[  1%] Building CXX object CMakeFiles/sb6.dir/src/sb6/sb6.cpp.o
In file included from /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/include/sb6ext.h:29:0,
                 from /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/include/sb6.h:71,
                 from /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/src/sb6/sb6.cpp:26:
/usr/include/GL/glext.h:6184:181: error: conflicting declaration ‘typedef void (* PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC)(GLuint, GLenum, GLsizeiptr, GLsizeiptr, GLenum, GLenum, const void*)’
 typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);
                                                                                                                                                                                     ^
In file included from /usr/include/GL/gl3w.h:4:0,
                 from /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/include/sb6.h:65,
                 from /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/src/sb6/sb6.cpp:26:
/usr/include/GL/glcorearb.h:4348:25: error: ‘PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC’ has a previous declaration as ‘typedef void (* PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC)(GLuint, GLenum, GLenum, GLenum, GLsizeiptr, GLsizeiptr, const void*)’
 typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data);
                         ^
make[2]: *** [CMakeFiles/sb6.dir/src/sb6/sb6.cpp.o] Error 1
make[1]: *** [CMakeFiles/sb6.dir/all] Error 2
make: *** [all] Error 2

然后我想"好的,那么也许我会尝试使用sb6包附带的gl3w.h和glcorearb.h。"所以我恢复了GL文件夹,然后删除了gl3w.h和glcorearb.h我之前使用python脚本生成并放在/ usr / include / GL中。在 cmake make 后,我收到此错误:

[  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
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

所以我不确定这是否会取得进展,但至少会暴露出一些蛇。关于下一步该做什么的任何建议都将不胜感激!

更新2

这是我从运行 make VERBOSE = 1 得到的结果,GL文件夹完好无损(就像我下载sb6文件时一样,但我也有glw3.h和glcorearb.h在/ usr / include / GL)中:

/usr/bin/cmake -H/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 -B/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/CMakeFiles /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
make -f CMakeFiles/sb6.dir/build.make CMakeFiles/sb6.dir/depend
make[2]: Entering directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
cd /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/CMakeFiles/sb6.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
make -f CMakeFiles/sb6.dir/build.make CMakeFiles/sb6.dir/build
make[2]: Entering directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
/usr/bin/cmake -E cmake_progress_report /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/CMakeFiles 51
[  1%] Building CXX object CMakeFiles/sb6.dir/src/sb6/sb6.cpp.o
/usr/bin/c++    -D_LINUX -I/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/include -I/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/extern/glfw-2.7.6/include    -o CMakeFiles/sb6.dir/src/sb6/sb6.cpp.o -c /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/src/sb6/sb6.cpp
Linking CXX static library lib/libsb6.a
/usr/bin/cmake -P CMakeFiles/sb6.dir/cmake_clean_target.cmake
/usr/bin/cmake -E cmake_link_script CMakeFiles/sb6.dir/link.txt --verbose=1
/usr/bin/ar cr lib/libsb6.a  CMakeFiles/sb6.dir/src/sb6/sb6.cpp.o CMakeFiles/sb6.dir/src/sb6/sb6ktx.cpp.o CMakeFiles/sb6.dir/src/sb6/sb6object.cpp.o CMakeFiles/sb6.dir/src/sb6/sb6shader.cpp.o CMakeFiles/sb6.dir/src/sb6/gl3w.c.o
/usr/bin/ranlib lib/libsb6.a
make[2]: Leaving directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
/usr/bin/cmake -E cmake_progress_report /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/CMakeFiles  51 52 53 54 55
[  6%] Built target sb6
make -f CMakeFiles/alienrain.dir/build.make CMakeFiles/alienrain.dir/depend
make[2]: Entering directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
cd /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/CMakeFiles/alienrain.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
make -f CMakeFiles/alienrain.dir/build.make CMakeFiles/alienrain.dir/build
make[2]: Entering directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
/usr/bin/cmake -E cmake_progress_report /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/CMakeFiles 1
[  7%] Building CXX object CMakeFiles/alienrain.dir/src/alienrain/alienrain.cpp.o
/usr/bin/c++    -D_LINUX -I/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/include -I/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/extern/glfw-2.7.6/include    -o CMakeFiles/alienrain.dir/src/alienrain/alienrain.cpp.o -c /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/src/alienrain/alienrain.cpp
Linking CXX executable bin/alienrain
/usr/bin/cmake -E cmake_link_script CMakeFiles/alienrain.dir/link.txt --verbose=1
/usr/bin/c++    -D_LINUX    CMakeFiles/alienrain.dir/src/alienrain/alienrain.cpp.o  -o bin/alienrain  -L/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/lib -rdynamic lib/libsb6.a -Wl,-rpath,/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/lib 
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[2]: Leaving directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
make[1]: *** [CMakeFiles/alienrain.dir/all] Error 2
make[1]: Leaving directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
make: *** [all] Error 2

更新3

我能够使用sb6示例代码找到构建问题的解决方案。事实证明,样本代码中包含的CMakeLists.txt中存在错误,其中第13行是

trouble trying to build opengl superbible example code

https://github.com/openglsuperbible/sb6code/issues/12

https://github.com/openglsuperbible/sb6code/issues/8

通过该修复,sb6示例代码现在为我编译。但是,当我尝试在我自己的示例代码中使用sb6.h(在上面的 my_application 中列出)时,我仍然得到

In file included from sb6ext.h:29:0,
                 from sb6.h:71,
                 from listing2.1.cpp:1:
/usr/include/GL/glext.h:6184:181: error: conflicting declaration ‘typedef void (* PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC)(GLuint, GLenum, GLsizeiptr, GLsizeiptr, GLenum, GLenum, const void*)’
 typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);
                                                                                                                                                                                     ^
In file included from /usr/include/GL/gl3w.h:4:0,
                 from sb6.h:65,
                 from listing2.1.cpp:1:
/usr/include/GL/glcorearb.h:4348:25: error: ‘PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC’ has a previous declaration as ‘typedef void (* PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC)(GLuint, GLenum, GLenum, GLenum, GLsizeiptr, GLsizeiptr, const void*)’
 typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data);
                         ^

1 个答案:

答案 0 :(得分:3)

我能够通过修复CMakeLists.txt中的错误来解决sb6示例代码编译问题,其中第13行是

trouble trying to build opengl superbible example code

https://github.com/openglsuperbible/sb6code/issues/12

https://github.com/openglsuperbible/sb6code/issues/8

当我在自己的代码中使用sb6.h时,我还没有解决我的编译问题,但是当我这样做时会更新这个答案