0

I'm trying to sun OpenGL SuperBible 6th edition example code for the first time on my Manjaro (arch) system. I followed the HOWTOBUILD.txt, installed mesa and glfw (glfw-wayland, not sure if there is a difference) via pacman. 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. Can anyone help me compile this without errors?

code example: https://github.com/openglsuperbible/sb6code

full error when I try to run 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
genpfault
  • 51,148
  • 11
  • 85
  • 139

1 Answers1

1

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.

glfwOpenWindowHint is renamed to glfwWindowHint in GLFW3

See: glfwOpenWindowHint not declared in this scope GLFW3 & GLEW

You could try installing GLFW2 and run it again. Since GLFW2 is available in Ubuntu Xenial, remember to configure sources.list accordingly.

For OpenGL SuperBible 6th

EDIT: I could not manage to install libglfw2 from Ubuntu Xenial repository. And manually installed dpkg from official website.

  1. download .deb file from https://launchpad.net/ubuntu/xenial/+package/libglfw-dev

  2. go to the folder .deb is installed in and run sudo dpkg -i [name of libglfw2].deb

  3. Run find . -name "libglfw*" in /usr/lib to find the path to the library. (there can be multiple libglfw.so as you already downloaded GLFW3 so be careful)

  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

    -lglfw to -lglfw2

  6. Run make

For 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.

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.

If it fails because of linker, make sure you have all the dependencies:

libglfw3-dev libx11-dev libxrandr-dev libxinerama-dev libxi-dev libxxf86vm-dev libxcursor-dev
Community
  • 1
  • 1
PHD
  • 595
  • 1
  • 8
  • 18
  • Can you explain how to configure sources.list? or can you give me a link to a documentation? – SnakesCantWearBoots Apr 19 '20 at 13:08
  • more accurate one: https://superuser.com/questions/124174/how-can-i-specify-the-repository-from-which-a-package-will-be-installed-emacs – PHD Apr 19 '20 at 13:26
  • @SnakesCantWearBoots I edited the answer to help you. Ask me if anything goes wrong. – PHD Apr 19 '20 at 14:09
  • @SnakesCantWearBoots I just realised you are using Arch Linux. Then, this might not be a solution. – PHD Apr 19 '20 at 14:26
  • I know this is different now, but I tried to launch the 7th version code which is in http://www.openglsuperbible.com/example-code/ under `Download the OpenGL SuperBible Example Source Code (master repository at GitHub)` and I'm getting `/usr/bin/ld: cannot find -lglfw3` error. I've installed the latest glfw-wayland from AUR, don't understand why it's still not working – SnakesCantWearBoots Apr 19 '20 at 16:39
  • Can you go to the `/usr/lib/` and run `find . -name "libglfw*"` or `whereis libglfw`? Because linker and the corresponding `.lib` file should have the exact name. – PHD Apr 20 '20 at 00:36
  • @SnakesCantWearBoots I added instructions for SuperBible 7th I used to successfully build the source code. – PHD Apr 20 '20 at 01:46