Ubuntu 14.04 中的 OpenGL 4.3 开发设置

     2023-02-22     119

关键词:

【中文标题】Ubuntu 14.04 中的 OpenGL 4.3 开发设置【英文标题】:OpenGL 4.3 development setup in Ubuntu 14.04 【发布时间】:2014-07-29 19:38:37 【问题描述】:

我刚刚开始学习 OpenGL SuperBible 第 6 版,并且很难让任何示例在 Ubuntu 14.04 上编译。我安装了开发包依赖项:

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 的建议,发现有一个 sb6code_2013_11_10/include/GL 文件夹,里面有 gl3w.h 和 glcorearb.h。我暂时将 GL 文件夹移出 sb6code_2013_11_10/include 然后再次运行 cmakemake 然后收到以下错误:

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文件夹,然后删除了之前用python脚本生成的gl3w.h和glcorearb.h,放在/usr/include/GL中。在 cmakemake 之后,我得到这个错误:

[  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

这是我在 GL 文件夹完好无损的情况下运行 make VERBOSE=1 得到的结果(即就像我下载 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 行的“elif (UNIX)”应该是“elseif (UNIX)”。请参阅参考资料:

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);
                         ^

【问题讨论】:

也许你有不同版本的glcorearb.h 冲突:检查/usr/include/GL/usr/local/include/GL(或者你的$PATH 中的其他目录)看看那里是否安装了一个。 sb6.h 可能希望在它自己的子目录中找到那个,其中包含*define gcc 抱怨的内容。 试过了 - 更新后 您没有与glfw3GLXdl 链接。 make VERBOSE=1 应该向您显示正在发出的实际命令;如果您无法理解它,请将其附加到问题中。如果您可以编译并运行任何 glfw 示例 - 您的设置就可以了。 已更新。在这种情况下如何链接 glfw?感谢您的帮助! 我用 sb6 代码解决了编译问题,但在编译我自己的示例时仍然遇到问题。查看更新。 【参考方案1】:

我能够通过修复 CMakeLists.txt 中的一个错误来解决 sb6 示例代码编译问题,其中第 13 行的“elif (UNIX)”应该是“elseif (UNIX)”。请参阅以下内容以获取参考:

trouble trying to build opengl superbible example code

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

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

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

【讨论】:

更新:在我自己的代码中使用 sb6.h 时,我仍然没有解决冲突声明错误。事实上,我已经完全停止使用 SuperBible,而是阅读 Anton Gerdelan 的 book 和 website 以及 arcsynthesis tutorials,从代码和可读性的角度来看,它们都更易于访问。

opengl在ubuntu14.04中的设置与编程

  在sudoapt-getinstallXXX,别的教程讲的很详细了。  编写好程序需要在shell中链接g++teapot.c-oteapot-lglut-lGL-lGLU  此处要注意I和l的区别。  然后在执行就ok了。./teapot.o  查看详情

Ubuntu 14.04 中的 production.log 在哪里 - Rails 4

】Ubuntu14.04中的production.log在哪里-Rails4【英文标题】:Whereistheproduction.loginUbuntu14.04-Rails4【发布时间】:2015-03-2219:04:41【问题描述】:我在OpsWorks中有一个Ubuntu14.04,我的production.rb文件中有这个配置:config.log_level=:debug问题是我在... 查看详情

来自 Ubuntu 14.04 的 NGINX 1.4.7 与最新版本 NGINX 1.8.0

】来自Ubuntu14.04的NGINX1.4.7与最新版本NGINX1.8.0【英文标题】:NGINX1.4.7fromUbuntu14.04vslatestversionNGINX1.8.0【发布时间】:2015-07-1202:15:51【问题描述】:我注意到ubuntu14.04中的标准NGINX版本与NGINXwebsite上的(!stable)版本(目前是1.8.0)相比确... 查看详情

.htaccess 未在 Ubuntu 14.04 (Apache 2.4.7) 中加载

】.htaccess未在Ubuntu14.04(Apache2.4.7)中加载【英文标题】:.htaccessnotbeingloadedinUbuntu14.04(Apache2.4.7)【发布时间】:2014-11-0702:18:21【问题描述】:我正在尝试在Ubuntu14.04(Apache2.4.7)中使用.htaccess文件。这是我的.htaccess的样子#1YEAR<FilesMatch... 查看详情

Ubuntu 14.04:Apache 2.4.7 虚拟主机不工作/重定向

】Ubuntu14.04:Apache2.4.7虚拟主机不工作/重定向【英文标题】:Ubuntu14.04:Apache2.4.7virtualhostnotworking/redirecting【发布时间】:2014-07-1006:07:57【问题描述】:我在我的Ubuntu14.04机器上安装了Apache2.4.7,但我的一些虚拟主机不同意我的看法... 查看详情

Ubuntu 14.04 Apache 2.4.7 404 未找到

】Ubuntu14.04Apache2.4.7404未找到【英文标题】:Ubuntu14.04Apache2.4.7404NotFound【发布时间】:2016-07-1717:24:42【问题描述】:我一直在阅读论坛并尝试复制他们的修复程序,但我肯定遗漏了一些东西,因为它会从简单的404ErrorNotFound切换到4... 查看详情

Ubuntu 14.04 - 将 Apache2 升级到 2.4.10

】Ubuntu14.04-将Apache2升级到2.4.10【英文标题】:Ubuntu14.04-upgradeApache2to2.4.10【发布时间】:2016-06-2602:17:54【问题描述】:我遇到了这个错误:https://bz.apache.org/bugzilla/show_bug.cgi?id=56480我似乎无法使用包含修复(2.4.10)的版本:#apt-cachepol... 查看详情

为啥 Ubuntu 14.04 在 4.3 发布后仍坚持使用(旧)Eclipse 3.8?

】为啥Ubuntu14.04在4.3发布后仍坚持使用(旧)Eclipse3.8?【英文标题】:WhydoesUbuntu14.04stickwith(old)Eclipse3.8when4.3isout?为什么Ubuntu14.04在4.3发布后仍坚持使用(旧)Eclipse3.8?【发布时间】:2013-11-1613:24:04【问题描述】:Ubuntu通常是一... 查看详情

Ubuntu 14.04 中的 webgrind 分析文件存储在哪里?

】Ubuntu14.04中的webgrind分析文件存储在哪里?【英文标题】:WherearewebgrindprofilingfilesstoredinUbuntu14.04?【发布时间】:2016-01-1816:24:31【问题描述】:我已经设置了xdebug和webgrind,并生成了几个分析文件。那些生成的文件存放在哪里?... 查看详情

ubuntu 14.04lts 上的奇怪编译错误 c++ opencv 2.4.10

】ubuntu14.04lts上的奇怪编译错误c++opencv2.4.10【英文标题】:Weirdcompilationerrorc++opencv2.4.10onubuntu14.04lts【发布时间】:2016-03-2418:43:37【问题描述】:基本上,我的笔记本电脑上已经有opencv2.4.8,我是通过anacondapython下载的。但是现在... 查看详情

如何在ubuntulinux14.04lts上安装php7

...图12.04桌面版的方法,今天向大家介绍一下XP下硬盘安装Ubuntu14.04的方法。我用的是长期支持版Ubuntu14.04LTS,而没有使用UbuntuKylin中国版。注意:用wubi.exe这个文件简单安装的是软件而不是真正的双操作系统。真正的双操作系统不是... 查看详情

shruby(2.2.2)rails(4.2.3)安装ubuntu(14.04)(代码片段)

查看详情

ubuntu14.04opencv2.4.13安装

1.下载然后解压安装压缩包unzipopencv-2.4.13.zip2.进入刚解压的文件夹,建立release文件夹cdopencv-2.4.13mkdirrelease3.安装一下必须的依赖库sudoapt-getinstallbuild-essentialcmakelibgtk2.0-devpkg-configpython-devpython-numpylibavcodec-devlibav 查看详情

rails 4.2.0:无法在 ubuntu 14.04 上安装 pg gem

】rails4.2.0:无法在ubuntu14.04上安装pggem【英文标题】:rails4.2.0:can\'tinstallpggemonubuntu14.04【发布时间】:2015-04-0611:57:05【问题描述】:我最近尝试将我的rail3.2*应用程序升级到rails4.2.*。但是,我在安装\'pg\'gem时被阻止了。当我用谷... 查看详情

MySQL 数据库在 ubuntu 14.04 的 XAMPP-1.8.3.4 中停止

】MySQL数据库在ubuntu14.04的XAMPP-1.8.3.4中停止【英文标题】:MySQLDatabasestoppedinXAMPP-1.8.3.4inubuntu14.04【发布时间】:2015-12-2823:21:30【问题描述】:MySQL已经在运行,但打开http://localhost/phpmyadmin/时出现如下错误:#2002-Connectionrefused服务... 查看详情

在 DigitalOcean Ubuntu 14.04 中的 Meteor 上的 Webshot 失败

】在DigitalOceanUbuntu14.04中的Meteor上的Webshot失败【英文标题】:WebshotfailsonMeteorinDigitalOceanUbuntu14.04【发布时间】:2016-05-1223:47:46【问题描述】:我正在使用此代码生成pdf:letfileUri=process.env.PWD+\'/storage/orders-pdf/\'+fileName;//CommenceWebshot 查看详情

ubuntu14.04中安装opencv2.4.13

 1.先下载OpenCV的源码 2.解压到任意目录 unzipopencv-2.4.13.zip 3.进入源码目录,创建release目录 cdopencv-2.4.13mkdir release   4.可以看到在OpenCV目录下,有个CMakeLists.txt文件,需要事先安装一些软件 su 查看详情

ubuntu14.04中的redis-server:绑定地址已经在使用中

】ubuntu14.04中的redis-server:绑定地址已经在使用中【英文标题】:redis-serverinubuntu14.04:Bindaddressalreadyinuse【发布时间】:2016-01-0200:28:15【问题描述】:我在ubuntu上通过在终端上输入以下命令启动了redis服务器:$redis-server这会导致以... 查看详情