3

I have a C project which I would like to build as a static library and not as a executable.

My high level environment is:

  • IDE: Code::Blocks 16.01
  • Operating System: Windows 7
  • Compiler: MinGW (GCC port for Windows)

As a build target option, I select static library (instead of executable) and select build.

Seems to work fine. Problem is, the output is a .a file (which I understand is the Unix/Linux format) and not the windows format of .lib.

Any hints on where I can look to solve this?

Dean P
  • 1,841
  • 23
  • 23
  • 1
    Do you specifically need .lib? Or do you just want to build a static library? If latter, then everything is okay. MinGW uses .a for static libs even on Windows. – HolyBlackCat Jun 06 '17 at 19:41
  • Ah, interesting. I didnt know that. If that is the case, a .a would suffice. As a matter of interest, if I specifically wanted to use .lib what would be the course of action? – Dean P Jun 06 '17 at 20:10
  • I don't know, but I assume there is a way, because MinGW seemingly can link against .lib's. – HolyBlackCat Jun 06 '17 at 23:16

2 Answers2

0

Just had the same problem, seems there is a solution:

In the main menu, open Project->Properties... and there the Build targets tab. Select your target, for example Release.

In the text field Output filename, change bin\Release\yourLib.a to bin\Release\yourLib.lib and untick the checkbox Auto-generate filename extension.

Now, building your project generates a .lib file instead of a .a file.

Don't forget to do the same steps for the Debug target, if you want to generate Debug .lib instead of .a files, as well.

SampleTime
  • 291
  • 3
  • 19
-1

Its all good dont worry you built a static library MinGW gives .a files on windows too

IP002
  • 471
  • 1
  • 5
  • 17