Author Topic: MingW32 import library  (Read 6148 times)

Offline beave

  • Single posting newcomer
  • *
  • Posts: 3
MingW32 import library
« 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: MingW32 import library
« Reply #1 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"
(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!]

Offline beave

  • Single posting newcomer
  • *
  • Posts: 3
Re: MingW32 import library
« Reply #2 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.

Offline reckless

  • Regular
  • ***
  • Posts: 338
Re: MingW32 import library
« Reply #3 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.


« Last Edit: June 28, 2010, 08:51:47 pm by reckless »

Offline beave

  • Single posting newcomer
  • *
  • Posts: 3
Re: MingW32 import library
« Reply #4 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: MingW32 import library
« Reply #5 on: June 28, 2010, 09:58:24 pm »
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!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: MingW32 import library
« Reply #6 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.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline reckless

  • Regular
  • ***
  • Posts: 338
Re: MingW32 import library
« Reply #7 on: June 29, 2010, 07:40:29 am »
most welcome :)