openglsuperbible/sb6code

Fails to Compile Linux Mint (Issues linking glfw)

Opened this issue · 15 comments

I have issues getting the code to compile and need some help. Nothing I've tried has worked so far. I am using linux mint 16 and have been programming for a while with opengl and have not ran into any problems, yet can not get these examples to compile. I have install glfw via 'apt-get libgflw-dev' and it has worked fine for me when running other code. My error looks like the program is not linking glfw properly, does anyone have suggestions to help me compile these examples on linux? When I compile with make I get the following error:

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

I should also probably mention I am a new user to this repository. I just got my book in a few days ago and have been trying to get started. I'm not experienced with this code base and am to inexperienced to correct the makefile to make it compile correctly.

Ok, I've resolved my problem and now I found a new one. In the "CMakeLists.txt" I found this section of code:

if(WIN32) set(COMMON_LIBS sb6 optimized GLFW_r32 debug GLFW_d32) elif (UNIX) set(COMMON_LIBS sb6 glfw ${GLFW_LIBRARIES} GL rt dl) else() set(COMMON_LIBS sb6) endif()

and I changed it to this

set(COMMON_LIBS sb6 glfw ${GLFW_LIBRARIES} GL rt dl)

Now all the example programs compile, but I cannot get them to run. when I try to run them I get the error "Unable to create OpenGL Context" I assume this problem may have to do with what version of opengl I am using but I have no idea. I will continue searching.

No solutions thus far to the error:

"Unable to create OpenGL Context"

OpenGL is installed and works fine for my other applications. I can't tell if the error is due to version issues. Any suggestions?

Do your video card support opengl 4? Sent from my BlackBerry 10 smartphone. From: haynesmdSent: Monday, March 17, 2014 9:10 PMTo: openglsuperbible/sb6codeReply To: openglsuperbible/sb6codeSubject: Re: [sb6code] Fails to Compile Linux Mint (Issues linking glfw) (#12)No solutions thus far to the error:

"Unable to create OpenGL Context"

OpenGL is installed and works fine for my other applications. I can't tell if the error is due to version issues. Any suggestions?

—Reply to this email directly or view it on GitHub.

Just confirmed the OpenGL version is not the issue. I am trying on two computers. The first is a desktop with an AMD HD7970 that supports up to OpenGL4.2. The second is a laptop with 2nd generation Intell 4400 video card that only supports OpenGL 3.0.

Desktop
$ glxinfo | grep "OpenGL version"
OpenGL version string: 4.2.12337 Compatibility Profile Context 13.101

Laptop
$ glxinfo | grep "OpenGL version"
OpenGL version string: 3.0 Mesa 9.2.1

I get the same error message on both systems. Any suggestions?
My Error:
Unable to create OpenGL context Failed to open window

Okay, I found some more information that may help narrow down the problem. I think the problem still has to deal with my original error with the glfw libraries:

[ 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'
I did some searching and was able to find where the error originates.

$ grep -r "OpenGL context" /Downloads/sb6code-master

sb6code-master/extern/glfw-2.7.6/lib/win32/win32_window.c: fprintf( stderr, "Unable to create OpenGL context\n" );
The problem is coming from the GLFW libraries! I think my patch that I mentioned earlier to make the code compile is causing the program to use the GLFW libraries from the folder sb6code-master. While it should be using the GLFW libraries on my system. Does this seem like a possible error?

Is there any possible way I can maybe compile just one small hello world program as opposed to trying to use the entire code base? Such as maybe a hello world example? It is difficult to catch the error when compiling everything at once.

I also came across this comment in the readme:

Please note carefully: EVEN IF YOU CAN BUILD THE SOURCES FOR YOUR FAVORITE PLATFORM OF CHOICE, YOU NEED RECENT OpenGL 4.3 DRIVERS TO RUN THEM. PLEASE DON'T PAN MY BOOK BECAUSE YOUR COMPUTER DOESN'T SUPPORT OpenGL 4.3. THANKS
It says I need OpenGL 4.3, since I have OpenGL 4.2 is that causing the problem?

I have the same problem in ubuntu-gnome 13.10. Is this only happening on
linux?

http://stackoverflow.com/questions/19719404/glfw-cant-create-4-3-context

Check if this work. I cannot try this right now, i'm busy.

2014-03-18 11:18 GMT-04:00 haynesmd notifications@github.com:

Okay, I found some more information that may help narrow down the problem.
I think the problem still has to deal with my original error with the glfw
libraries:

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

I did some searching and was able to find where the error originates.

$ grep -r "OpenGL context" /Downloads/sb6code-master

sb6code-master/extern/glfw-2.7.6/lib/win32/win32_window.c: fprintf(
stderr, "Unable to create OpenGL context\n" );

The problem is coming from the GLFW libraries! I think my patch that I
mentioned earlier to make the code compile is causing the program to use
the GLFW libraries from the folder sb6code-master. While it should be using
the GLFW libraries on my system. Does this seem like a possible error?

Is there any possible way I can maybe compile just one small hello world
program as opposed to trying to use the entire code base? Such as maybe a
hello world example? It is difficult to catch the error when compiling
everything at once.

Reply to this email directly or view it on GitHubhttps://github.com//issues/12#issuecomment-37945111
.

Adderly Gonzalez

Adderly,

This makes about 25-30% of the examples run. The other examples will either open a black window or they will segment fault. What I did was in sb6.h I commented out 2 lines and added the following four lines at line number 96 just after the init().

// glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, info.majorVersion); // glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, info.minorVersion); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 4.3); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2); glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

This is a great improvement! Any suggestions on how to get the remainder of the examples running?

Great.

Well, to see what is happening. A viable solution will be to see what is
really happening in glfw.

http://www.glfw.org/docs/latest/quick.html#quick_capture_error

This can give us, diagnostic information.

2014-03-18 14:02 GMT-04:00 haynesmd notifications@github.com:

Adderly,

This makes about 25-30% of the examples run. The other examples will
either open a black window or they will segment fault. What I did was in
sb6.h I commented out 2 lines and added the following four lines at line
number 96 just after the init().

// glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, info.majorVersion);
// glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, info.minorVersion);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 4.3);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

This is a great improvement! Any suggestions on how to get the remainder
of the examples running?

Reply to this email directly or view it on GitHubhttps://github.com//issues/12#issuecomment-37966585
.

Adderly Gonzalez

Hmm, could I still potentially have some linking issues. I tried the glfwSetErrorCallback() function but it appears it is out of scope. Is this functionality of GLFW3? Not quite sure how to approach this.
include/sb6.h:102:44: error: ‘glfwSetErrorCallback’ was not declared in this scope glfwSetErrorCallback(error_callback);

Yeah it is only available in GLFW3.

2014-03-18 14:45 GMT-04:00 haynesmd notifications@github.com:

Hmm, could I still potentially have some linking issues. I tried the
glfwSetErrorCallback() function but it appears it is out of scope. Is this
functionality of GLFW3? Not quite sure how to approach this.

include/sb6.h:102:44: error: 'glfwSetErrorCallback' was not declared in
this scope
glfwSetErrorCallback(error_callback);

Reply to this email directly or view it on GitHubhttps://github.com//issues/12#issuecomment-37972247
.

Adderly Gonzalez

Well I'm stumped. From the best that I can tell, trying to add the GLFW3 libraries to the code base creates quite a few conflicting library errors. It appears that the code base is built on the regular GLFW libraries. Adding GLFW3 makes it impossible to compile anything.

We (you and i) can port it to GLFW3 at some time @haynesmd, right now i got no time.

@grahamsellers are you gonna push some changes to the sources?
Cause we've encountered some problems.

@haynesmd well our somehow tutor is at Game Developer Conference in San Francisco at this time.
We better get to it. :D

I had this problem on Ubuntu 14.04, afaik it's a bug in the CMakeLists.txt where on line 13 the 'elif (UNIX)' should be 'elseif (UNIX)'. That fixed it for me!
FYI @grahamsellers
See
http://stackoverflow.com/questions/25023586/opengl-4-3-development-setup-in-ubuntu-14-04
http://stackoverflow.com/questions/23024789/trouble-trying-to-build-opengl-superbible-example-code?rq=1