Author Topic: Linking Console Executable  (Read 7312 times)

Offline like2program

  • Single posting newcomer
  • *
  • Posts: 6
Linking Console Executable
« 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...

Offline MortenMacFly

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

Offline like2program

  • Single posting newcomer
  • *
  • Posts: 6
Re: Linking Console Executable
« Reply #2 on: March 09, 2008, 09:32:12 pm »
How would I change it to a library?

Offline Seronis

  • Almost regular
  • **
  • Posts: 197
Re: Linking Console Executable
« Reply #3 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.

Offline like2program

  • Single posting newcomer
  • *
  • Posts: 6
Re: Linking Console Executable
« Reply #4 on: March 09, 2008, 09:39:01 pm »
I can't click on properties.
It's un-selectable.

Offline like2program

  • Single posting newcomer
  • *
  • Posts: 6
Re: Linking Console Executable
« Reply #5 on: March 09, 2008, 09:43:06 pm »
Ok I got it to build After creating a new project.
Thanks for your help.

Offline like2program

  • Single posting newcomer
  • *
  • Posts: 6
Re: Linking Console Executable
« Reply #6 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
« Last Edit: March 09, 2008, 10:00:05 pm by like2program »

Offline Belgabor

  • Multiple posting newcomer
  • *
  • Posts: 91
Re: Linking Console Executable
« Reply #7 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.

Offline Seronis

  • Almost regular
  • **
  • Posts: 197
Re: Linking Console Executable
« Reply #8 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.

Offline thomas

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

Offline Seronis

  • Almost regular
  • **
  • Posts: 197
Re: Linking Console Executable
« Reply #10 on: March 10, 2008, 07:02:53 pm »
did not know that.  thanks.

Offline like2program

  • Single posting newcomer
  • *
  • Posts: 6
Re: Linking Console Executable
« Reply #11 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