Static linking problem with MinGW

I'm having static linking problems with a library that is set for DLL. I would like to build as static library .a and dll library depending on the setup below.

#ifdef WIN32
#ifdef DLL
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT __declspec(dllimport)
#endif
#else
#define DLLEXPORT //<-- expecting this to take effect when building as static = nothing added
#endif


#ifdef __cplusplus
extern "C" {
#endif

void DLLEXPORT Function1();
void DLLEXPORT Function2();

#ifdef __cplusplus
} // extern "C"
#endif


compiling the objects like g++ -c file1.cpp file2.cpp

then creating a lib

ar rcs libmylib.a file1.o file2.o

The DLL version already works w/o problems,
but the static version does not work (-DDLL macro not set), it throws undefined __imp__ Functions.

g++ main.cpp -L. -lmylib
Last edited on
problem solved. somehow I have a backup file that is the one included with the old DLLEXPORT setup.
Topic archived. No new replies allowed.