Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: beave on June 28, 2010, 05:14:51 pm

Title: MingW32 import library
Post by: beave on June 28, 2010, 05:14:51 pm
Hi guys,

I've spent the better half of a day trying to figure out how to create .lib files for windows when compiling on linux.

I've followed the guide on setting up mingw32 to cross compile for windows but it doesnt create the lib file for the dll (as the documentation states when building on linux)

The closest i've got is this post:
http://forums.codeblocks.org/index.php/topic,3343.msg55888.html#msg55888

but that hasnt worked.

Also, the forum post and wiki differ when setting the linker, ie ar compared to ld. Whats the difference and which one should I use?

I'm using cb 10.05 on ubuntu 10.04 32bit

I appreciate any help.
Title: Re: MingW32 import library
Post by: oBFusCATed on June 28, 2010, 05:57:28 pm
ld creates shared libraries (dlls)
ar creates static libraries, the resulting file is just an archive with all the compiled object files.

I don't think that it is possible to make .lib from .a.

Probably this link could help: http://www.codeproject.com/KB/cpp/libfromdll.aspx
google search string: "howto make lib from dll"
Title: Re: MingW32 import library
Post by: beave on June 28, 2010, 06:21:39 pm
thanks for the clarification, so this step in the how to is wrong then:
http://wiki.codeblocks.org/index.php?title=File:Settings_compiler_debugger_programms.png
(well it fails when i set it to ld so i guess it is)

I was also looking at some windows tools running under wine to create the lib file. I found how ffmpeg does this here:
http://ffmpeg.arrozcru.org/wiki/index.php?title=Cross-compiling

But will using VC++ tool create lib files that can work with MingW? Or is it just the dll that differ?

thanks for the help so far.
Title: Re: MingW32 import library
Post by: reckless on June 28, 2010, 08:49:02 pm
no need to convert the .a files to .lib for mingw, mingw itself uses .a libraries not .lib as default.

files with .lib extention are ms compiler format and as such only needed if you need a specific library from gnu with msvc.

the difference from ms library format is that mingw libraries have .dll.a for libraries that link to a dll.


Title: Re: MingW32 import library
Post by: beave on June 28, 2010, 09:43:08 pm
cheers reckless you've saved me a whole lot of time.

I did a quick test and you're right, mingw can link just against the dll. I was under the impression it needed the lib.
Title: Re: MingW32 import library
Post by: oBFusCATed on June 28, 2010, 09:58:24 pm
Hm, are you sure? I think it requires the .a file.
Title: Re: MingW32 import library
Post by: stahta01 on June 28, 2010, 11:18:06 pm
Hm, are you sure? I think it requires the .a file.

Works for linking Code::Blocks dll every time I tried it.

Tim S.
Title: Re: MingW32 import library
Post by: reckless on June 29, 2010, 07:40:29 am
most welcome :)