User forums > Using Code::Blocks
.obj to .exe using CodeBlocks
stahta01:
Edit: It looks like you have no idea what an header or Library is; please read the Glossary Links I added below:
An Header normally has the extension .h
An Library normally has the extension .a or .lib (sometimes .dll under Windows or .so under Linux)
Learn the difference between Compiler and Linker steps of the Build Process!
Compilers uses the headers; not the Linkers!
Linkers use the Libraries.
Found a Good Glossary of C++
http://www.glenmccl.com/glos.htm
See Linker http://www.glenmccl.com/glos.htm#tag130
See Header http://www.glenmccl.com/glos.htm#tag107
See Library http://www.glenmccl.com/glos.htm#tag127
CB Related Note: CB defaults to adding "lib" and the correct extension to the library name;
therefore try using the library name without the lib prefix or the file extension.
Tim S.
finston:
Tim, I think that I may be beginning to see the light! Thank you.
I have now set:
Linker settings>link library>gdi32
Search Directories>Compiler>C:2011sip\USR\BC\INC (where my .h files are)
Search Directory>Linker>C:\Programme Files\CodeBlocks\MinGW\lib\libopengl32.a
libkernel32.a
libgdi32.a
libuser32.a
Search Directory>Resource compiler>C:\2011sip\USR\BC\RC (where my .rc and .rh files are)
I have a confusion, please can you help: should my .rh files go with the .h files or with the .rc files? In several areas, my code calls for #include “ sipadv.rh” so I have put a copy of it in my INC folder - it was originally in my RC folder.
With these these improvements, when I ran the build, I got a buiuld log of process terminated with 5 errors and 5 warnings.
These are the 5 errors that Code::Blocks gave me on build:
C:\2011sip\USR\BC\INC\sip.h|230|error: expected ',' or '...' before '*' token|
C:\2011sip\USR\BC\INC\sip.h|231|error: expected ',' or '...' before '*' token|
C:\2011sip\USR\BC\INC\sip.h|232|error: expected ',' or '...' before '*' token|
C:\2011sip\USR\BC\INC\sip.h|233|error: expected initializer before '*' token|
C:\2011sip\USR\BC\INC\sip.h|234|error: expected initializer before '*' token|
These are the equivalent lines in sip.h:
DWORD GetDibInfoHeaderSize( DIBPTR );
WORD GetDibWidth( DIBPTR );
WORD GetDibHeight( DIBPTR );
DIBPTR GetDibBitsAddr( DIBPTR );
DIBPTR ReadDib( char * );
And here is something relevant to DIBTR from the beginning of sip.h:
// Define DIB pointers.
#ifdef __FLAT__ // 32 Bit flat memory.
#define DIBPTR BYTE FAR *
#else
#define DIBPTR BYTE huge *
#endif
Can you make any suggestions, please
Finston
stahta01:
--- Quote from: finston on January 14, 2011, 03:22:55 pm ---Search Directory>Linker>C:\Programme Files\CodeBlocks\MinGW\lib\libopengl32.a
libkernel32.a
libgdi32.a
libuser32.a
--- End quote ---
Why are you still doing this? Why do you think this is right.
Hint: libopengl32.a is NOT a folder/Directory.
Please post the Full Compiler Build Log; if you still what help.
http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F
Post the source code with problem; at least post all of the #includes from the source code.
Note: You really need to go to a site that teaches programming like cboard http://cboard.cprogramming.com/
Tim S.
finston:
TIM S, I have found a lot of your helpful hints as I have researched further, thanks
Surprisingly enough, I have got all but one of my original .c files to compile to .o compiled files using .gcc in Code::Blocks. My problem now is linking.
I have tried analysing the original.exe using IDA pro demo, but I could nor get a clear picture from this of the object files used.
As I don't know exactly which of my .o files need to be linked to create my new .exe. I thought that I would try linking the .o files that I have and see what transpired.
I have also analysed the original sip32.exe using depends.exe and obtained a listing of the .DLLs called at runtime.
I thought that if entered all these libraries at Project > Project build options > linker settings > Link Libraries using the stripped library name (deleting lib prefix and leaving off the .a), I should by default be using all the linking libraries that I need.
When I ran Build > Build and Run half the libraries came up as not existing (not in my C:\MinGW\lib or C:\MinGW\lib\gcc\Mingw32\4.5.0 - as I confirmed).
I deleted reference to these libraries and again ran Build > Build and Run.
I used Project > Project build options > linker settings > other linker options of:
-Wl,--enable-auto-image-base
-Wl,--add-stdcall-alias
-Wl,--enable-auto-import
-Wl,--enable-stdcall-fixup
-Wl,--cref
-Wl,--trace
which I found on the internet
and Project > Project Build options > Compiler settings > Other options of:
-mthreads
-fmessage-length=0
-m32
-mwindows
-v
-fmax-errors=0
again found on the internet
What I found was that the link libraries used are
kernel32
gdi32
user32
mingw32
gcc
ntdll
msvcrt
comdlg32
gcc_s
moldname
The libraries that I entered are not mentioned unless they are not present in C:\MinGW\lib or C:\MinGW\lib\gcc\Mingw32\4.5.0 and it makes no difference if I keep them or deleted all the link Libraries
What I get as Error messages are:
--- Code: ---C:/2011sip/SIP/Sipprt.c:185: undefined reference to `Plot_Axes'
C:/2011sip/SIP/Sipprt.c:187: undefined reference to `Plot_Data'
obj\Debug\sipwnd.o: In function `WndProc@16':
C:/2011sip/SIP/sipwnd.c:138: undefined reference to `Read_Ini_Int'
C:/2011sip/SIP/sipwnd.c:140: undefined reference to `File_Init'
C:/2011sip/SIP/sipwnd.c:142: undefined reference to `Ex_File_Init'
C:/2011sip/SIP/sipwnd.c:197: undefined reference to `File_Open_Dlg'
C:/2011sip/SIP/sipwnd.c:201: undefined reference to `Sip_File_Read'
C:/2011sip/SIP/sipwnd.c:234: undefined reference to `Ex_File_Save_Dlg'
C:/2011sip/SIP/sipwnd.c:248: undefined reference to `File_Export'
C:/2011sip/SIP/sipwnd.c:262: undefined reference to `File_Export'
C:/2011sip/SIP/sipwnd.c:272: undefined reference to `File_Export'
C:/2011sip/SIP/sipwnd.c:290: undefined reference to `File_Save_Dlg'
C:/2011sip/SIP/sipwnd.c:304: undefined reference to `Sip_File_Write'
C:/2011sip/SIP/sipwnd.c:321: undefined reference to `Sip_File_Write'
C:/2011sip/SIP/sipwnd.c:471: undefined reference to `Analyse_Data'
obj\Debug\sipwnd.o: In function `PlotWndProc@16':
C:/2011sip/SIP/sipwnd.c:1251: undefined reference to `Plot_Axes'
C:/2011sip/SIP/sipwnd.c:1253: undefined reference to `Plot_Data'
--- End code ---
if I delete the troublesome sipwnd.c from the compile and link, I get:
--- Code: ---obj\Debug\Sip32.o: In function `WinMain@16':
C:/2011sip/SIP/Sip32.c:161: undefined reference to `WndProc@16'
C:/2011sip/SIP/Sip32.c:192: undefined reference to `StatBarProc@16'
C:/2011sip/SIP/Sip32.c:199: undefined reference to `PlotWndProc@16'
C:/2011sip/SIP/Sip32.c:207: undefined reference to `PlotTitleWndProc@16'
C:/2011sip/SIP/Sip32.c:215: undefined reference to `PlotStatWndProc@16'
obj\Debug\Sipdlg.o: In function `DialWndProc@16':
C:/2011sip/SIP/Sipdlg.c:273: undefined reference to `bRtData'
C:/2011sip/SIP/Sipdlg.c:275: undefined reference to `bStData'
C:/2011sip/SIP/Sipdlg.c:308: undefined reference to `bRtData'
C:/2011sip/SIP/Sipdlg.c:310: undefined reference to `bStData'
obj\Debug\Sipprt.o: In function `Print_Data':
C:/2011sip/SIP/Sipprt.c:185: undefined reference to `Plot_Axes'
C:/2011sip/SIP/Sipprt.c:187: undefined reference to `Plot_Data'
--- End code ---
I am a little surprised by this as my code has been well written - as far as I can tell - and has compiled, linked and successfully run before. I would have thought that all the references were there already.
I am at a loss to know how to proceed - any ideas?
Thanks
Finston
stahta01:
--- Quote from: stahta01 on January 14, 2011, 03:52:54 pm ---
Note: You really need to go to a site that teaches programming like cboard http://cboard.cprogramming.com/
Tim S.
--- End quote ---
If you know where File_Export is defined; I might be able to help; if you do not you need someone to help you how knows how to program and can see all of your sourcecode!!
--- Quote from: finston on March 03, 2011, 06:19:31 pm ---C:/2011sip/SIP/sipwnd.c:262: undefined reference to `File_Export'
--- End quote ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version