Code::Blocks Forums

User forums => Help => Topic started by: like2program on March 09, 2008, 02:34:53 pm

Title: Linking Console Executable
Post by: like2program on March 09, 2008, 02:34:53 pm
I can't compile an irrXML.cpp into irrXML.lib.
It should work and the code looks OK.
It would be great if someone could help.
Error Log:
Compiling: C:\Paintball Project\irrLicht\irrxml-1.2\src\irrXML.cpp
Linking console executable: C:\Paintball Project\irrLicht\irrxml-1.2\src\irrXML.exe
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../libmingw32.a(main.o):main.c:(.text+0x104): undefined reference to `_WinMain@16'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
1 errors, 0 warnings

From the looks of it Code::Blocks is broken...
Title: Re: Linking Console Executable
Post by: MortenMacFly on March 09, 2008, 03:16:08 pm
Linking console executable: C:\Paintball Project\irrLicht\irrxml-1.2\src\irrXML.exe
You are *not* linking to a library but an executable (application). Thus you either need a main routine or you change your project setup to be a library project.
Title: Re: Linking Console Executable
Post by: like2program on March 09, 2008, 09:32:12 pm
How would I change it to a library?
Title: Re: Linking Console Executable
Post by: Seronis on March 09, 2008, 09:36:52 pm
'Project' menu -> 'Properties' menu option -> 'Build Targets' tab

Right side of the dialog, 2nd field, is a pull down menu.
Title: Re: Linking Console Executable
Post by: like2program on March 09, 2008, 09:39:01 pm
I can't click on properties.
It's un-selectable.
Title: Re: Linking Console Executable
Post by: like2program on March 09, 2008, 09:43:06 pm
Ok I got it to build After creating a new project.
Thanks for your help.
Title: Re: Linking Console Executable
Post by: like2program on March 09, 2008, 09:55:52 pm
Ok it works.. kinda.
I need it to build into a .lib not .a
how might I go about doing this?
If it is possible for that matter
Title: Re: Linking Console Executable
Post by: Belgabor on March 09, 2008, 10:33:50 pm
.a are gcc's static libraries, .libS are usually used and created with/by msvc. As far as I know they are not interchangable.
Title: Re: Linking Console Executable
Post by: Seronis on March 10, 2008, 01:10:26 pm
In otherwords, since you're using gcc to compile the library you probably need the *.a file and NOT a *.lib file.  Personally in my linker settings i always omit the file suffix completely and codeblocks handles it accurately.  Just try using the *.a file and see if it works for the program that intends on using it.
Title: Re: Linking Console Executable
Post by: thomas on March 10, 2008, 05:24:49 pm
Although gcc natively works on .a files, you can (at least under MinGW) use Microsoft's .lib files with gcc (no problem at all).
However, the same is not true the other way around.
Title: Re: Linking Console Executable
Post by: Seronis on March 10, 2008, 07:02:53 pm
did not know that.  thanks.
Title: Re: Linking Console Executable
Post by: like2program on March 10, 2008, 11:33:04 pm
After doing a little reading, Thank you very much for your help.
I will accept and love *.a  :)
I really have to commend you guys in your efforts to make Code::Blocks the best IDE around.
Thanks once more,
L2P