PDA

View Full Version : undefined reference



mili123
12-02-2009, 02:56 PM
Hi all,

I am trying to recompile some old project using Qt+openGL+glut, but it just wont work.
My system is Windows vista and I have installed the newest version of MinGW to compile the project.

When I compile, the following command is used to link everything together:



g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -mthreads -Wl -Wl,-subsystem,windows -o release\WorldBuilder.exe object_script.WorldBuilder.Release -L"c:\Qt\4.6.0\lib" -lopengl32 -lglu32 -lgdi32 -luser32 -lmingw32 -lqtmain -lwinmm -lglut32win -lQtOpenGL4 -lQtGui4 -lQtCore4


What makes me crazy are undefined references to opengl-methods although I have linked -lopengl32. This are the errors I get (Mainly the first 4 error are concerned but If you have any idea for the other errors I would also be very grateful):



./release\Speedometer.o:Speedometer.cpp:(.text+0x23b ): undefined reference to `_imp__glVertex2i'
./release\Speedometer.o:Speedometer.cpp:(.text+0x24e ): undefined reference to `_imp__glVertex2i'
./release\Speedometer.o:Speedometer.cpp:(.text+0x2e6 ): undefined reference to `_imp__glDrawPixels'
./release\Texture.o:Texture.cpp:(.text+0xb0): undefined reference to `_imp__glDrawPixels'
c:\Qt\4.6.0\lib/libqtmain.a(qtmain_win.o):qtmain_win.cpp:(.text+0x 1c2): undefined reference to `_Unwind_Resume'
c:\Qt\4.6.0\lib/libqtmain.a(qtmain_win.o):qtmain_win.cpp:(.text$_Z N7QVectorIPcE7reallocEii[QVector<char*>::realloc(int, int)]+0x187): undefined reference to `_Unwind_Resume'
c:\Qt\4.6.0\lib/libqtmain.a(qtmain_win.o):qtmain_win.cpp:(.eh_fram e+0x12): undefined reference to `__gxx_personality_v0'


Just give me some ideas, I am getting crazy...

Milad

Benoit
12-09-2009, 01:43 PM
Hi,

Can you compile Qt OpenGL examples ?

Best,

Stuart McDonald
12-11-2009, 05:32 AM
I use cygwin not MinGW, but I've hit similar problems. If I compile with -mno-cygwin (which I think is similar to using MinGW) then the symbols are of the form "_glClear@4". If I compile without that then the symbols are "_glClear" and "__impl__glClear".

The opengl32 lib has "_glClear@4" where as libGL.dll.a has the other form.

Never used MinGW, but it looks like your code is being compiled for the wrong environment. Does your g++ have a -mno-cygwin? maybe even just try -DWIN32?

You can use nm (don't know if MinGW has this) to look at the symbols.

Not a huge help sorry.

Resident
12-21-2009, 09:45 PM
A few issues:

1. The order of -l parameters on your link line is wrong. GCC/g++ actually cares about the order, where the most dependent have to be listed first, followed by their dependencies. For example, "-lQtOpenGL4 -lglu32 -lopengl32 -lgdi32" would be correct.

2. It appears that Qt and MinGW disagree about the exception model (the "Unwind" symbols are related to raising exceptions). Looking at the Trolltech website, it appears that if you want to use Qt 4.6 and Windows Vista, you're stuck with either Visual C++ or the previous official version of MinGW (3.4.2). (http://doc.trolltech.com/4.6/supported-platforms.html) This would make sense because the old version of MinGW used the setjmp/longjmp exception model where the new one uses the zero-cost (dwarf?) model.

Try using the older version of MinGW. Your other option is to use WinXP.