Reputation: 3348
Since a few WIN32 related things didn't quite work using MinGW, I decided to create a small static library with MSVC 2010 and link it with MinGW afterwards. However, I am currently looking for a tool that allows me to convert static MSVC libraries(.lib) to MinGW static libraries(.a). Searching the web, I have found various tools such as "lib to a", which requires a .dll file for some reason, so I figured it was not quite what I was looking for.
The library is compiled in C and works perfectly using MSVC. This is the header file:
#ifndef _GWSI_H
#define _GWSI_H
#include <Windows.h>
#define GWSI_HEIGHT 0x0001
#define GWSI_WIDTH 0x0002
#define GWSI_OSVI_MAJOR 0x0010
#define GWSI_OSVI_MINOR 0x0011
#define GWSI_OSVI_BUILD 0x0012
#ifdef __cplusplus
extern "C" {
#endif
float GWSI_getCpuSpeed();
int GWSI_getOSV(unsigned int flag);
int GWSI_getScreenResolution(unsigned int flag);
unsigned _int64 GWSI_getTotalSystemMemory();
#ifdef __cplusplus
}
#endif
#endif /*_GWSI_H*/
The attempt of simply trying to link the .lib, pretending it was an .a, (using Netbeans with MinGW and not VisualStudio, of course) led to this error:
GWSI.h:26:17: error: expected initializer before GWSI.h:26:17: error: expected initializer before 'GWSI_getTotalSystemMemory'
After removing the 'GWSI_getTotalSystemMemory();' prototype I got this error, which I assume means that the library was not linked to begin with:
main.o:main.cpp:(.text+0xf): undefined reference to `GWSI_getCpuSpeed'
Do you have any idea on how I could achieve my goal, of using this static library with MinGW? Also, what could possibly have caused the first error? I can't see any invalid deceleration.
Thanks for your help!
Upvotes: 2
Views: 860
Reputation: 864
I believe that you can't link libraries compiled in MSVC to your MinGW code.
Upvotes: 0