Menu

post Link a VC++ static lib to Dev C++ progr

Spider
2010-01-27
2012-09-26
  • Spider

    Spider - 2010-01-27

    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.

     
  • cpns

    cpns - 2010-01-27

    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?

     
  • Spider

    Spider - 2010-01-27

    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.

     
  • cpns

    cpns - 2010-01-27

    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++.

     
  • Spider

    Spider - 2010-01-28

    Thanks!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.