News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

MingW32 import library

Started by beave, June 28, 2010, 05:14:51 PM

Previous topic - Next topic

beave

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.next.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.

oBFusCATed

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"
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

beave

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.

reckless

#3
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.



beave

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.

oBFusCATed

Hm, are you sure? I think it requires the .a file.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

stahta01

Quote from: oBFusCATed on June 28, 2010, 09:58:24 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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

reckless