|
Linking openGL/Glut in Code::Blocks |
Skywhy
Member #9,243
November 2007
|
As the topic says, having problems with linking files. Again. I never seem to learn this. Oh well... Here we go. The idea is to setup opengl and glut properly, sounds simple. Files I got and places I threw them in: <CodeBlocks>\include\GL: <CodeBlocks>\lib: I think I've got the files in right places, correct me if I'm wrong. But simple examples won't compile. I get loads of errors and I think it's because I don't really know what to link... In Project > Project Options ... > Linker Settings > Other linker options I've tried using: -lopengl32 -lglu32 -lglut32. And still I get the same errors, which are: Quote:
\CodeBlocks\include\GL\glut.h|58|warning: ignoring #pragma comment | ### The actual code is opengl/glut example, hello.c:
So as far as code comes, no magic there really... Just having the time of my life linking these files. I tried this: Using OpenGL & GLUT in Code::Blocks and read through several other stuff but couldn't really solve this... Someone, point me in the right direction. What am I doing wrong? How do I get these to compile? </code> |
Erin Maus
Member #7,537
July 2006
|
According to this, you need to add the following to the commandline: -D_STDCALL_SUPPORTED -D_M_IX86 And then it should link properly. edit: --- |
wiseguy
Member #44
April 2000
|
Aaron Bolyard said: Oh, wait, you included the windows header before then... Try adding the library as it says so in the tutorial, not with the linker options. That's right, instead of using the linker options, browse for the libraries in the other half of that tab, and add them to the project one at a time, preserving relative paths. |
Skywhy
Member #9,243
November 2007
|
Ok, I did so but still having problems. Now it just crashes when I run it. I get few warnings but I think they are not the cause of this crash. Quote:
\CodeBlocks\include\GL\glut.h|58|warning: ignoring #pragma comment |
It runs and instantly crashes before showing anything. Nice. EDIT #1: Before this linking / testing I tried out the Code::Blocks own openGL template, it worked and compiled fine and showed me the piece of openGL neatnes it created. Now when I try compiling it, it pops up and instantly crashes... Hmm... Something wrong with my precious openGL now? Oh boy, this is |
wiseguy
Member #44
April 2000
|
Are you sure that the DLLs you have match the libraries you're using? When I had problems with this, I found out that I had older DLL files than the libraries I was using. Other than that, I'm not sure. Maybe something in your display function? |
Skywhy
Member #9,243
November 2007
|
I'd go as far as blaming the dll files... Obviously I don't about the code for sure, since I'm trying to learn OpenGL but this monster is fighting me with all of it's might. Any advices where to find the latest dll's ? Since it seems that everything opengl / glut related is spread among the internet in random bits and pieces, your supposed to collect them and put the pieces together. Any site that actually has like.. I don't know, one rar that contains example .dll, .lib and .h files for openGL? And same thing for glut and glu. Oh well, It's already past midnight here, I'll hit the sack and fight with this some more tomorrow when I get off work / school. This is really starting to tick me off [rand] Can't really understand why this is so darn hard. [/rand] Any advices, sites and so on are welcome. |
wiseguy
Member #44
April 2000
|
Well, what I did was delete the DLLs in the system32 directory, and then copy over the ones from your compiler's dll/lib directory. If they aren't there you might try the MinGW or CodeBlocks site. |
Thomas Fjellstrom
Member #476
June 2000
|
You did not overwrite opengl32.dll in system did you? each system32/opengl32.dll is specific to the drivers you have installed. Overwriting it with, say MESA's opengl32.dll will leave you with software rendering (or just a broken opengl setup). -- |
Skywhy
Member #9,243
November 2007
|
Thomas said: You did not overwrite opengl32.dll in system did you? each system32/opengl32.dll is specific to the drivers you have installed. Overwriting it with, say MESA's opengl32.dll will leave you with software rendering (or just a broken opengl setup). Heh, no I did not. Finally, I got it working. I don't know for sure where the problem was but I think it was in the libraries. I even tried using libglut32.a but in the end, after thousand copies of glut32.lib I got it working. The current glut32.lib is from here. This was the first glut I tried but I think I had some other linker settings missing then... Oh joy, this is HELL. I can't believe how hard this was. Okay, still one question remains, now that the library paths are relative in the linker options, what if I'm doing the project with a group and they have different kind of file structure? I suppose it doesn't work since The compiler can't find the libraries in the specified paths. How do I get around this? With use of -l<something>? |
Thomas Fjellstrom
Member #476
June 2000
|
You should tell your IDE about the libs via its global (or project local) library paths settings. -- |
gnolam
Member #2,030
March 2002
|
Quote: Finally, I got it working. I don't know for sure where the problem was but I think it was in the libraries. I even tried using libglut32.a but in the end, after thousand copies of glut32.lib I got it working. The current glut32.lib is from here [xmission.com]. This was the first glut I tried but I think I had some other linker settings missing then... Oh joy, this is HELL. I can't believe how hard this was. It's GLUT. It actually working is a rare sight to behold. -- |
Skywhy
Member #9,243
November 2007
|
Thomas said: You should tell your IDE about the libs via its global (or project local) library paths settings. Forgive me for my stupidity, care to throw in any urls/examples/explanations on this? With our current Allegro project we are using -lalleg(+few other) and it works like a wonder with both of our IDE's. And if we do similiar linking as in the example above with our current Allegro project it won't work on my friends IDE. Since the path's differ. So do you mean we should use like.. err... -lglut32 with the GLUT so it would work on both of our IDE's? OR do we need to change the library path's everytime the project gets passed to my friend or he passes it to me? Holy hell, my small head can't hold this stuff... Somebody, hold my hand and explain this to me like you are talking to a five year old. gnolam said: It actually working is a rare sight to behold. Really..? Should I be scared? I know it's a bit ancient but the examples I've got, start out with it, so I'll live with it. I have to start somewhere. And now I'll just keep hoping it won't blow up again. |
Thomas Fjellstrom
Member #476
June 2000
|
Quote: So do you mean we should use like.. err... -lglut32 with the GLUT so it would work on both of our IDE's? OR do we need to change the library path's everytime the project gets passed to my friend or he passes it to me? Holy hell, my small head can't hold this stuff... Uh, IF you have the gl libs installed properly, your ide will find it naturally if you just say "link to foo". IF you don't have things installed properly, you're hosed. Simple as that. IDEs like MSVC and Code:Blocks have two sets of library paths it searches, Global (for all projects), and local, per project paths. I suggest setting up GL to be in the global library paths. -- |
Skywhy
Member #9,243
November 2007
|
Thank you. Solved. |
|