Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi, I was wondering whether it is possible to create lib files with gcc and use them also with gcc. As lib files I mean the files produced by Microsoft CL that have the extension lib and look like "advapi32.lib". My platform is Windows NT. I already know that I can produce and use .a files from .o files. An ideal set of commands for me to build the whole thing would be like this:
 
For the library:
gcc -c libfile1.c -o libfile1.o
gcc -c libfile2.c -o libfile2.o
gcc -o sample.lib libfile1.o libfile2.o
And for the program:
gcc -c appfile1.c -o appfile1.o
gcc -c appfile2.c -o appfile2.o
gcc -o app.exe appfile1.o appfile2.o -l sample.lib
Posted 3-Jul-12 6:52am
iPick12507

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Nope. No can do.
 
MS compiler produces .lib files, GCC produces .a files.
 
You can't link .a files to projects with Visual Studio. Nor an you link .lib files to projects with GCC.
 
What you trying to do/achieve?
  Permalink  
Comments
iPick12 at 3-Jul-12 12:09pm
   
I'm trying to create an IDE that runs on Win32 and I thought it'd be nice to have Visual Studio compatibility. Apparently I can't, but anyway, thanks for your help.
enhzflep at 3-Jul-12 12:13pm
   
Okay, well in that instance - you can write the code such that it will build with both VS and GCC.
If you're using Code::Blocks, you can even setup both build targets for the same project, since CB will let you use any one of a whole bunch of build tools with no problems.
So, typically a new project will have Debug and Release configurations. You can add 2 new configs - Debug VS & Release VS. You just have to point to the correct compiler and setup any environment vars.
 
Never bothered myself, I just create 2 project files - one for CB and the other for VS - but all of the .cpp .h .rc and sound/image files are shared between both projects - it just means another short period to build with the alternate tool. Got a pdf creation lib that works fine for both - no changes needed or compiler specific hacks. (Just stay away from the nasty practise of using the #pragma directive as a way to link libraries in VS - it doesn't work in GCC)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 428
1 Maciej Los 249
2 BillWoodruff 199
3 /\jmot 180
4 Suraj Sahoo | Coding Passion 150
0 OriginalGriff 8,484
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,159
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 3 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100