Hi, I have problems to compile a c++ program that uses a static lib that I
made in VC++, I've use vc because I needed CImage class.
If I export from VC++ as a dynamic library then my program compiles with that
lib with no problems... But I need my program to be just 1 .exe file.
So the problems arrives when I export from VC as static library and import it
to my Dev C++ program. When I compile I get this error:
undefined reference to `_imp__SaveToJPG'
I've exported from VC like this
extern "C" declspec(dllexport)void SaveToJPG(HBITMAP bmp,const char *path)
and imported in DevC++ like this:
extern "C" declspec(dllimport) void SaveToJPG(HBITMAP bmp,const char *path)
Any suggestions?
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Microsoft static libraries are not compatible with the MinGW/GNU toolchain
supplied with Dev-C++. I believe that they can be used with 4.x versions. You
may get newer versions at www.mingw.org. Alternatively stick with the DLL.
I am somewhat confused as to why you have __declspec(dllexport) for a static
library? That should not be necessary, even if it is valid (and I am not sure
about that).
However it does beg the question of why you would not just use VC++ for the
entire project?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If libraries are incompatible why I can link a lib from the dynamic dll from
VC? or they are using some different convention for static and dynamic.
I want to make a clean program using just standard function. All goes well
until I needed a JPEG library. I've try every library what I found on net and
cannot compile them. So I used VC with embeded MFC to make this library only.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
2010-01-27 18:07:06 GMT
If libraries are incompatible why I can link a lib from the dynamic dll from
VC?
That's a good question. I had assumed that you had used either reimp.exe which
can convert DLL export libraries but not static object libraries, or that you
were using LoadLibrary(). I may also be recalling incorrectly about GCC 4.x
being able to link MS static libraries, but I believe it can link MS export
libraries, so perhaps you have already upgraded your MinGW/GCC installation?
I want to make a clean program using just standard function.
That still does not explain why you would not use MSVC; it is just as capable
(in fact more so) as MinGW and accepting ISO C++ and ISO C90 code (but not
C99).
I've try every library what I found on net and cannot compile them.
Did you try http://devpaks.org/? These a library
packages and tools specifically designed to work with Dev-C++.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I have problems to compile a c++ program that uses a static lib that I
made in VC++, I've use vc because I needed CImage class.
If I export from VC++ as a dynamic library then my program compiles with that
lib with no problems... But I need my program to be just 1 .exe file.
So the problems arrives when I export from VC as static library and import it
to my Dev C++ program. When I compile I get this error:
undefined reference to `_imp__SaveToJPG'
I've exported from VC like this
extern "C" declspec(dllexport)void SaveToJPG(HBITMAP bmp,const char *path)
and imported in DevC++ like this:
extern "C" declspec(dllimport) void SaveToJPG(HBITMAP bmp,const char *path)
Any suggestions?
Thanks.
Microsoft static libraries are not compatible with the MinGW/GNU toolchain
supplied with Dev-C++. I believe that they can be used with 4.x versions. You
may get newer versions at www.mingw.org. Alternatively stick with the DLL.
I am somewhat confused as to why you have __declspec(dllexport) for a static
library? That should not be necessary, even if it is valid (and I am not sure
about that).
However it does beg the question of why you would not just use VC++ for the
entire project?
Thanks for answer
If libraries are incompatible why I can link a lib from the dynamic dll from
VC? or they are using some different convention for static and dynamic.
I want to make a clean program using just standard function. All goes well
until I needed a JPEG library. I've try every library what I found on net and
cannot compile them. So I used VC with embeded MFC to make this library only.
That's a good question. I had assumed that you had used either reimp.exe which
can convert DLL export libraries but not static object libraries, or that you
were using LoadLibrary(). I may also be recalling incorrectly about GCC 4.x
being able to link MS static libraries, but I believe it can link MS export
libraries, so perhaps you have already upgraded your MinGW/GCC installation?
That still does not explain why you would not use MSVC; it is just as capable
(in fact more so) as MinGW and accepting ISO C++ and ISO C90 code (but not
C99).
Did you try http://devpaks.org/? These a library
packages and tools specifically designed to work with Dev-C++.
Thanks!