views:

84

answers:

1

Greetings, I am facing a complicated situation about using a static library under windows. The static library is build by a specific version of mingw which is bundled with Eiffel studio. Since Eiffel studio uses mingw to create its output as a static lib, I have no control over this configuration. If I try to use this static library with Eclipse CDT which is using a more recent version of mingw, then I can't compile my project. This is because I have to provide -l options to various libraries like winsock, and it appears due to difference between versions of compilers generating static library and my code, this does not work.

If I force Eclipse to use the same mingw directory that comes with Eiffel studio, the one that compiled the static lib, then I can compile my code (there are some other issues here though) I do not want to constrain my c++ development just because a static library is build with a particular version of mingw.

So how can I use this static library from my own mingw version? This is windows xp btw..

Best Regards Seref

+1  A: 

Though I don't have a lot of information here is what I would do:

  1. Try to compile with the newer version of mingw and see if you can make it work. Errors are very important in this case (you should check also the mingw manual/mailing lists/forums for finding about the compatibility between mingw versions

  2. Separate the library from the program and wrap all its functionality - to avoid different incompatible compilation flags (you could create a different library - even a DLL and call your new functions (wrappers for some library functions)

  3. Decide what part of the project is mandatory - the part with the library or the rest of the code

    1. If the library is mandatory I would compile the code with that version of mingw
    2. Else I would try to find an equivalent for that library or eliminate it

Others option may be available but this is what I would do (in this order)

Iulian Şerbănoiu
Thanks. I've ended up compiling with the newer version of mingw, which saved me from a lot of trouble. I'm curious though, would it be possible to wrap a static library in a dll, to overcome compiler version troubles? I mean a dll compiled with the old version, wrapping static library and its dependencies?
It depends on the problem. Usually you don't have problems using a DLL (no matter what compiler is used for building it) **if** you solve the symbols with LoadLibrary and GetProcAddress; but if you link with the DLL problems may (and usually will) arise due to the fact that linking is a process specific for each development-suite (can differ even between versions). By wrapping with the old compiler and exporting functions - if this is possible !!! - (to be solved with GetProcAddress) you bypass these problems. Of course the code must be also changed to use GetProcAddress and others.
Iulian Şerbănoiu