Author Topic: OpenGL Linker problem.  (Read 8273 times)

radioact1ve

  • Guest
OpenGL Linker problem.
« on: April 12, 2006, 04:26:08 am »
Hello everyone!

Hows it going?! I have been messing with C::B(v1, rc2) for the last couple of days, I always knew it was good, just didn't use it. Anyway, onto my question.

How do you set up C::B with OpenGL (version that comes with CB)? Let me explain. Like I said for the last couple of days, I have been trying to set it up to no success. Funny because the same problem I have, after searching the forums, is very common but there was never a solution. Google couldn't even help me out here.

Basically, on WinXP trying to get C::B to run a simple opengl and glut.
This is the error I'm getting, which I'm pretty sure has do to with the "linking process":
Code
mingw32-g++.exe   "-D_WCHAR_T_DEFINED "     -I"C:\Program Files\CodeBlocks\include" -c Simple.cpp -o .objs\Simple.o
mingw32-g++.exe    -L"C:\Program Files\CodeBlocks\lib" -o "C:\Documents and Settings\radioact1ve\Desktop\Programming\CB\OpenGL.exe" .objs\Simple.o        -lglut32 -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32  -mwindows
.objs\Simple.o:Simple.cpp:(.text+0x1c): undefined reference to `__glutInitWithExit'
.objs\Simple.o:Simple.cpp:(.text+0x37): undefined reference to `__glutCreateWindowWithExit'
.objs\Simple.o:Simple.cpp:(.text+0x53): undefined reference to `__glutCreateMenuWithExit'
...... Insert a whole bunch of undefines here
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings

As you can see from the message, that's the order that I'm linking the libs. Truth be told I have been using many different combinations b/c the forums and Google keep giving me different orders, and it worked for them.

I have tried to be as detailed as possible, if more info is needed please let me know. Hope anyone can help!! I know this has been asked before but I haven't found a workable solution. Thanks for your time!!

BTW, The basic template that comes with C::B when you create a new  OpenGL project compiles but it doesn't run. The "time" cursor on the mouse appears for like a second and nothing happens. My guess is that something is failing so the app just exists. Thought I would share that.
« Last Edit: April 12, 2006, 04:29:41 am by radioact1ve »

Offline Vampyre_Dark

  • Regular
  • ***
  • Posts: 255
  • Hello!
    • Somewhere Over The Rainbow...
Re: OpenGL Linker problem.
« Reply #1 on: April 12, 2006, 07:03:24 am »
Do you have GLUT? It's not a part of OpenGL, it's an external library.
Do you have your linker and include folders set in CB so that it can find your libraries?
C::B Wishlist
~BOYCOTT THE EVIL YELLOW BOXES~

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: OpenGL Linker problem.
« Reply #2 on: April 12, 2006, 08:31:21 am »
I have been messing with C::B(v1, rc2) [...]
As usual question: Did you try one of the nigtlys?
Anyway: I believe there is NO GLUT template that ships with C::B. The only thing are a "generic" OpenGL tamplate and a GLFW template. Anyway: I'm providing you with a GLUT template as attachment. Copy the content of the archive to the [C::B]\share\CodeBlocks\templates folder. This template requires one of the nightlies as is uses features that are not availabe in RC2 and below. In addition it requires the path to the GLUT SDK to be setup (it will ask you to setup a global variable accordingly). I doenloaded the GLUT Devpack (do a google search for it, version 3.7.6) and setup the path to this directory.
This template compiles fine and works well on my machine (Windows with MinGW).
I'm going to post this as a patch to BerliOS, soon.
With regards, Morten.

EDIT: I've uploaded the patch by now (#992). We'll see if and when the admins agree and apply it to SVN.

[attachment deleted by admin]
« Last Edit: April 12, 2006, 08:46:48 am by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: OpenGL Linker problem.
« Reply #3 on: April 12, 2006, 09:38:03 am »
GLUT is generally a troublemaker. It is unmaintained for a couple of years now.

Once upon a time (in the ages of Dev-CPP), I used the original binary from Nate Robins' site: http://www.xmission.com/~nate/glut.html
You may want to try that one if the DevPak does not work for you (for some reason, it did not work for me).

If you can, try to do without GLUT alltogether (or use freeglut, which is at least being maintained). Usually, people only ever need GLUT to compile a 5-8 year old OpenGL demo code sample, not for actually developing something.

If you aren't afraid of trying something completely different, you should consider using GLFW. It does not have all of GLUT's functions (you don't need most of them anyway), but it is quite good if you want to open a window that does OpenGL, catch mouse and keyboard input, etc. It is cross-platform, reliable, and very lightweight. There is a template for GLFW coming with Code::Blocks, and instructions on how to build the library in the WiKi.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline bluekid

  • Multiple posting newcomer
  • *
  • Posts: 57
  • What is blue ? Blue is the invisible becoming visi
Re: OpenGL Linker problem.
« Reply #4 on: April 12, 2006, 03:41:47 pm »
look here
http://forums.codeblocks.org/index.php?topic=2656.0
download
http://file004.mylivepage.com/chunk4/57394/35/Code%20Blocks%20i%C3%A7in%20GLUT%20full%20paket%20.zip
full Glut !
- Library Files for Mingw32
- C::B Template for GLUT
- Tutorial with Example C::B projects
- glut-3.spec.pdf
- Glut-Puzzle ! - from FLTK examples
« Last Edit: April 12, 2006, 03:44:53 pm by bluekid »
What is blue ? Blue is the invisible becoming visible.

radioact1ve

  • Guest
Re: OpenGL Linker problem.
« Reply #5 on: April 13, 2006, 05:11:28 am »
sweet! Thanks all. I have been using glut that came with the book, Beginning OpenGL game programming. Everything was working with C++ express '05 but not with CB.

The problem was that I didn't have glut32.dll in the /bin. Didn't think a dll would go there. Oh well, I learn something new everyday!! Thanks again!!