简体   繁体   English

尝试在 Linux 上运行 OpenGL SuperBible 示例代码时出现“未定义的对 'glfwOpenWindowHint' 的引用”错误

[英]Getting `undefined reference to 'glfwOpenWindowHint' ` error when trying to run OpenGL SuperBible example code on Linux

I'm trying to sun OpenGL SuperBible 6th edition example code for the first time on my Manjaro (arch) system.我第一次尝试在我的 Manjaro (arch) 系统上晒 OpenGL SuperBible 第 6 版示例代码。 I followed the HOWTOBUILD.txt, installed mesa and glfw (glfw-wayland, not sure if there is a difference) via pacman.我按照 HOWTOBUILD.txt,通过 pacman 安装了 mesa 和 glfw(glfw-wayland,不确定是否有区别)。 Tried to run the first time unsuccessfuly, then changed an error in the CMakeList.txt as described in here https://stackoverflow.com/a/24474361/9197461 it got rid of the undefined reference to 'glfwInit' error, but all other undefined errors stayed.尝试第一次运行不成功,然后更改了 CMakeList.txt 中的错误,如https://stackoverflow.com/a/24474361/9197461中所述,它消除了undefined reference to 'glfwInit' ,但所有其他未定义的错误仍然存在。 Can anyone help me compile this without errors?谁能帮我编译这个没有错误?

code example: https://github.com/openglsuperbible/sb6code代码示例: https://github.com/openglsuperbible/sb6code

full error when I try to run make :当我尝试运行make时出现完整错误:

/usr/bin/ld: CMakeFiles/wrapmodes.dir/src/wrapmodes/wrapmodes.cpp.o: in function `sb6::application::run(sb6::application*)':
wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x8b): undefined reference to `glfwOpenWindowHint'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xa1): undefined reference to `glfwOpenWindowHint'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xb0): undefined reference to `glfwOpenWindowHint'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xbf): undefined reference to `glfwOpenWindowHint'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xd5): undefined reference to `glfwOpenWindowHint'
/usr/bin/ld: CMakeFiles/wrapmodes.dir/src/wrapmodes/wrapmodes.cpp.o:wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xf5): more undefined references to `glfwOpenWindowHint' follow
/usr/bin/ld: CMakeFiles/wrapmodes.dir/src/wrapmodes/wrapmodes.cpp.o: in function `sb6::application::run(sb6::application*)':
wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x133): undefined reference to `glfwGetDesktopMode'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x18b): undefined reference to `glfwOpenWindow'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x1e9): undefined reference to `glfwOpenWindow'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x25b): undefined reference to `glfwSetMousePosCallback'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x267): undefined reference to `glfwSetMouseWheelCallback'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x280): undefined reference to `glfwEnable'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x289): undefined reference to `glfwDisable'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x29a): undefined reference to `glfwGetWindowParam'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x3bc): undefined reference to `glfwGetWindowParam'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/wrapmodes.dir/build.make:105: bin/wrapmodes] Error 1
make[1]: *** [CMakeFiles/Makefile2:296: CMakeFiles/wrapmodes.dir/all] Error 2
make: *** [Makefile:104: all] Error 2

I downloaded the source code and tried the steps you've done and not surpringsingly, received the same error message.我下载了源代码并尝试了您所做的步骤,但并不意外地收到了相同的错误消息。

And it seems that the source code uses GLFW2 instead of GLFW3.并且似乎源代码使用 GLFW2 而不是 GLFW3。

glfwOpenWindowHint is renamed to glfwWindowHint in GLFW3 glfwOpenWindowHint在 GLFW3 中重命名为glfwWindowHint

See: glfwOpenWindowHint not declared in this scope GLFW3 & GLEW请参阅: glfwOpenWindowHint 未在此 scope GLFW3 和 GLEW 中声明

You could try installing GLFW2 and run it again.您可以尝试安装 GLFW2 并再次运行它。 Since GLFW2 is available in Ubuntu Xenial, remember to configure sources.list accordingly.由于 GLFW2 在 Ubuntu Xenial 中可用,请记住相应地配置sources.list

For OpenGL SuperBible 6th对于 OpenGL SuperBible 6th

EDIT : I could not manage to install libglfw2 from Ubuntu Xenial repository.编辑:我无法从 Ubuntu Xenial 存储库安装libglfw2 And manually installed dpkg from official website.并从官方网站手动安装dpkg

  1. download .deb file from https://launchpad.net/ubuntu/xenial/+package/libglfw-devhttps://launchpad.net/ubuntu/xenial/+package/libglfw-dev下载.deb文件

  2. go to the folder .deb is installed in and run sudo dpkg -i [name of libglfw2].deb go 到安装文件夹.deb并运行sudo dpkg -i [name of libglfw2].deb

  3. Run find. -name "libglfw*"运行find. -name "libglfw*" find. -name "libglfw*" in /usr/lib to find the path to the library. find. -name "libglfw*"/usr/lib中查找库的路径。 (there can be multiple libglfw.so as you already downloaded GLFW3 so be careful) (可能有多个libglfw.so ,因为您已经下载GLFW3 ,所以要小心)

  4. Create a symbolic link for the dynamic library just installed by running the following command:通过运行以下命令为刚刚安装的动态库创建符号链接:

    sudo ln -s /usr/lib/[path to file]/[filename] /usr/lib/[path to file]/libglfw2.so

  5. Edit sb6code/CMakeFiles/tunnel.dir/link.txt as follows编辑sb6code/CMakeFiles/tunnel.dir/link.txt如下

    -lglfw to -lglfw2 -lglfw-lglfw2

  6. Run make运行make

For OpenGL SuperBible 7th对于 OpenGL SuperBible 7th

If you have already installed libglfw3 but could not manage to run cmake.. , this could be because your libglfw3.so is stored as libglfw.so .如果您已经安装了libglfw3但无法运行cmake.. ,这可能是因为您的libglfw3.so存储为libglfw.so

In that case, you can create a symbolic link to it:在这种情况下,您可以创建指向它的符号链接:

sudo ln -s /usr/lib/[path to file]/[libglfw name].so /usr/lib/[path to file]/libglfw3.so

Save and run cmake.. again inside build .保存并再次运行cmake..build中。

If it fails because of linker, make sure you have all the dependencies:如果由于 linker 而失败,请确保您拥有所有依赖项:

libglfw3-dev libx11-dev libxrandr-dev libxinerama-dev libxi-dev libxxf86vm-dev libxcursor-dev

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM