Author Topic: undefined reference  (Read 8098 times)

Offline mikethebike

  • Multiple posting newcomer
  • *
  • Posts: 24
    • Homepage
undefined reference
« 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

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: undefined reference
« Reply #1 on: April 10, 2009, 11:09:47 am »
You need to link some library under "Build Settings".
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline mikethebike

  • Multiple posting newcomer
  • *
  • Posts: 24
    • Homepage
Re: undefined reference
« Reply #2 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

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: undefined reference
« Reply #3 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.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline mikethebike

  • Multiple posting newcomer
  • *
  • Posts: 24
    • Homepage
Re: undefined reference
« Reply #4 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

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9493
Re: undefined reference
« Reply #5 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...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline mikethebike

  • Multiple posting newcomer
  • *
  • Posts: 24
    • Homepage
Re: undefined reference
« Reply #6 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

Offline mikethebike

  • Multiple posting newcomer
  • *
  • Posts: 24
    • Homepage
Re: undefined reference
« Reply #7 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9493
Re: undefined reference
« Reply #8 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...).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline mikethebike

  • Multiple posting newcomer
  • *
  • Posts: 24
    • Homepage
Re: undefined reference
« Reply #9 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


Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9493
Re: undefined reference
« Reply #10 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. ;-)
« Last Edit: April 13, 2009, 02:29:13 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline mikethebike

  • Multiple posting newcomer
  • *
  • Posts: 24
    • Homepage
Re: undefined reference
« Reply #11 on: April 13, 2009, 03:59:58 pm »
Hi Morten
  never heard of such. Sorry where should I get and do what?
Thanks Michael
 

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9493
Re: undefined reference
« Reply #12 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline mikethebike

  • Multiple posting newcomer
  • *
  • Posts: 24
    • Homepage
Re: undefined reference
« Reply #13 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.-



Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9493
Re: undefined reference
« Reply #14 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ