Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: mikethebike on April 10, 2009, 10:38:45 am

Title: undefined reference
Post by: mikethebike on April 10, 2009, 10:38:45 am
Hi
 my first CB project. I can't find which setting I forgot for that error below:
C:\Users\Michael\Desktop\C++\PC-12\main.cpp|118|undefined reference to `__imp__XPLMGetSystemPath'|
etc.
Thanks for letting me know which/where CB setting to add/change.
Regards Michael
Title: Re: undefined reference
Post by: thomas on April 10, 2009, 11:09:47 am
You need to link some library under "Build Settings".
Title: Re: undefined reference
Post by: mikethebike on April 12, 2009, 09:29:21 am
Thanks. Actually I was told VC to be incompatible to SDL therefore I move to CodeBlocks. Having the same IDE on all platforms is even an advantage...now I get some OpenGL linking issues.
"undefined reference to `_glGenTextures@8'|" etc.
Where are those located:
opengl32.lib
glu32.lib
odbc32.lib
odbccp32.lib
or how shall I fix the above errors?
Thanks again and happy easter.
Michael
Title: Re: undefined reference
Post by: thomas on April 12, 2009, 01:09:24 pm
They're in MinGW's lib folder. However, you can provide the library's base name (opengl32, glu32, ...) for all system libraries. The linker will find them.
Title: Re: undefined reference
Post by: mikethebike on April 12, 2009, 01:21:38 pm
Thanks Thomas. Now I get:
" You must select a host application to run a library."
Where? In build targets I've set:

Type: DLL
Output filename: E:\X-Plane 9.00\Resources\plugins\PC12.dll
Execution working dir: E:\X-Plane 9.00
Objects output dir: obj\Debug\

anything false or missing?
Thanks again and regards
Michael
Title: Re: undefined reference
Post by: MortenMacFly on April 12, 2009, 02:02:32 pm
" You must select a host application to run a library."
The host application is the one that loads the DLL you are developing. In your case it's X-Plane. You can setup the host application in the "Project" menu under "Set programs arguments".

BTW: In the case of X-Plane it's best if you run X-Plane separately and not from within C::B. You cannot debug it easily anyways...
Title: Re: undefined reference
Post by: mikethebike on April 12, 2009, 03:08:50 pm
Thanks Morten. In VC I could debug, VC started x-plane. But here not. Even manually starting x-plane does not allow debugging. Am i doing something wrong, F7 ends immediately debug mode. How shall I debug, use CB?
Thanks again Michael
Title: Re: undefined reference
Post by: mikethebike on April 12, 2009, 06:14:01 pm
So CB is broken?
This is what I get:
...
The program is not being run.
Debugger finished with status 0

If debugging is not working the whole IDE is worthless.
Title: Re: undefined reference
Post by: MortenMacFly on April 12, 2009, 09:22:28 pm
So CB is broken?
No. I am developing an X-Plane plugin myself using C::B - I can tell you: It just works. :-)

Did you compile your DLL correctly - meaning: Does it include debugging information? Did you setup the host application correctly? It's best if you post thew build log (see my sig...).
Title: Re: undefined reference
Post by: mikethebike on April 12, 2009, 10:21:15 pm
Hi Morten
 many thanks for your help. Below the build and debugger log:
-------------- Build: Debug in PC-12 ---------------

mingw32-g++.exe -Wall -DIBM=1  -g -DIBM=1  -DIBM=1   -I..\SDL -I..\XPSDK200b2\SDK\CHeaders\XPLM -I..\AdvancedSDKExamples\Projects\Win\SDL\lib -I..\XPSDK200b2\SDK\CHeaders\XPLM -I..\SDL -I..\AdvancedSDKExamples\Projects\Win\SDL\lib -IC:\Users\Michael\Desktop\C++\XPSDK200b2\SDK\CHeaders\XPLM  -c C:\Users\Michael\Desktop\C++\PC-12\main.cpp -o obj\Debug\main.o
C:\Users\Michael\Desktop\C++\PC-12\main.cpp:2: warning: ignoring #pragma comment
C:\Users\Michael\Desktop\C++\PC-12\main.cpp:3: warning: ignoring #pragma comment
C:\Users\Michael\Desktop\C++\PC-12\main.cpp: In function `int LoadGLTexture(char*, int)':
C:\Users\Michael\Desktop\C++\PC-12\main.cpp:290: warning: unused variable 'pImageData'
C:\Users\Michael\Desktop\C++\PC-12\main.cpp:291: warning: unused variable 'sWidth'
C:\Users\Michael\Desktop\C++\PC-12\main.cpp:291: warning: unused variable 'sHeight'
C:\Users\Michael\Desktop\C++\PC-12\main.cpp:292: warning: unused variable 'result'
C:\Users\Michael\Desktop\C++\PC-12\main.cpp:292: warning: unused variable 'width'
C:\Users\Michael\Desktop\C++\PC-12\main.cpp:292: warning: unused variable 'height'
C:\Users\Michael\Desktop\C++\PC-12\main.cpp:299: warning: unused variable 'texture_format'
C:\Users\Michael\Desktop\C++\PC-12\main.cpp:300: warning: unused variable 'nOfColors'
mingw32-g++.exe -shared   -Wl,--dll -LC:\Users\Michael\Desktop\C++\AdvancedSDKExamples\Projects\Win\SDL\lib -L..\SDL -LC:\Users\Michael\Desktop\C++\AdvancedSDKExamples\Projects\Win\SDL\lib -L..\SDL\lib -L..\SDL -LC:\Users\Michael\Desktop\C++\XPSDK200b2\SDK\CHeaders\XPLM  obj\Debug\main.o   -o E:\X-Plane\Resources\plugins\PC12.xpl  -lmingw32 -lSDLmain -lSDL.dll -luser32 -lgdi32 -lwinmm -ldxguid ..\XPSDK200b2\SDK\Libraries\Win\XPLM.lib ..\AdvancedSDKExamples\Projects\Win\SDL\lib\SDL_image.lib -lopengl32 -lglu32 -lmingw32 -lSDLmain -lSDL.dll -luser32 -lgdi32 -lwinmm -ldxguid ..\XPSDK200b2\SDK\Libraries\Win\XPLM.lib ..\AdvancedSDKExamples\Projects\Win\SDL\lib\SDL_image.lib -lopengl32 -lglu32 "C:\Program Files (x86)\CodeBlocks\MinGW\lib\libmingw32.a" "C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL.dll.a" "C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSDLmain.a"
Output size is 827.94 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 10 warnings
 

Debugger:
---------------------
Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: C:\Users\Michael\Desktop\C++\PC-12\
Adding source dir: C:\Users\Michael\Desktop\C++\PC-12\
Changing directory to: E:/X-Plane
Adding file: X-Plane.exe
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 6.7.50.20071127
No symbol table is loaded.  Use the "file" command.
No symbol table is loaded.  Use the "file" command.
No symbol table is loaded.  Use the "file" command.
The program is not being run.
Debugger finished with status 0

Title: Re: undefined reference
Post by: MortenMacFly on April 13, 2009, 02:27:02 pm
many thanks for your help. Below the build and debugger log:
The build log is OK. But I doubt you have the debug version of X-Plane, right? That's what I meant when saying "debugging X-Plane is not easy".
I do it by logging to a file - plain old skool debug. ;-)
Title: Re: undefined reference
Post by: mikethebike on April 13, 2009, 03:59:58 pm
Hi Morten
  never heard of such. Sorry where should I get and do what?
Thanks Michael
 
Title: Re: undefined reference
Post by: MortenMacFly on April 13, 2009, 06:32:08 pm
  never heard of such. Sorry where should I get and do what?
You won't get a debug version of a commercial product. Sorry.
Just grab yourself a debugging framework based on files/streams and/or just pipe every debug output to a file... using usual C/C++ file handling.
Title: Re: undefined reference
Post by: mikethebike on April 13, 2009, 06:51:13 pm
I've no idea what u are talking about!

So u are telling me that CB is broken and worthless.-


Title: Re: undefined reference
Post by: MortenMacFly on April 13, 2009, 06:58:35 pm
So u are telling me that CB is broken and worthless.-
No I am not. I told you several times that I can debug X-Plane plugins just fine.

If you don't understand what I am talking about I wonder if you know what debugging is and how a debugger works?! :shock:
Listen: To debug a framework/application you need a debug version of the target application. If you ask the guys that develop X-Plane for a debug version and they'll provide you with such all is fine. Alternatively ask at the X-Plane forum. If you receive a positive answer - let me know.
Title: Re: undefined reference
Post by: mikethebike on April 14, 2009, 07:02:08 am
The guys at x-plane.org told that I'd never get a debug version...

I only have some VB.NET experience, where debugging is very easy. If you can
let me know, step by step, on how I could use CB, a huge thanks then. Otherways
I'll have to try Eclipse. I cannot use VC because of compatibility troubles with SDL.

Regards Michael
Title: Re: undefined reference
Post by: MortenMacFly on April 14, 2009, 07:44:56 am
The guys at x-plane.org told that I'd never get a debug version...
See... ;-)

If you can let me know, step by step, on how I could use CB, a huge thanks then.
Open a file when your plugin starts (search for fopen on Google), pipe in what you need to know during debugging, close the file when your plugin ends. Inspect the file using your favourite editor, e.g. Notepad.
Notice that there are for sure logging frameworks (e.g. http://log4c.sourceforge.net) you can easily use. There are also debugging/logging frameworks that protocol to a server during runtime. But  I have no example atm.

Otherways I'll have to try Eclipse.
You can try - but the problem here is not (I repeat:) NOT solvable with another IDE. I don't really get why it's so hard to understand that if you want to debug an application with a plugin framework you'll need a debug version of the application itself and a debug version of your plugin. It starts to become annoying to repeat myself over and over again. :?