Menu

Help with Static linking

Help
Brandon
2005-01-22
2012-10-31
  • Brandon

    Brandon - 2005-01-22

    I've been trying to static link FreeImage into my MFC MDI project, but keep getting errors on compile when I try to initiallize/deinitiallize the library. I did a search on the forums, and it looks like I've done all of the stuff that I think I'm suppose to do. Here's what I've done:

    Compiled release and debug versions of the lib
    Placed the .lib files in my VC98/Lib directory of Visual Studio.
    Placed the .dll files in my VC98/Bin directory of Visual Studio.
    Included the FreeImage.h file into my project, and called it in the main App class.
    Added the FREEIMAGE_LIB preprocessor definition
    Set the Multithreaded runtime library in both release and debug mode
    Included the FreeImage.lib into the object library modules (Settings > Link)
    Added LIBCMT to the ignore list

    Finally, in the InitInstance of my App class, I called the FreeImage_Initialise().. I get the following compile warnings and messages:

    C:\Programming\MotionX\MotionX.cpp(4) : warning C4651: '/D_DLL' specified for precompiled header but not for current compile
    Linking...
    MotionX.obj : error LNK2001: unresolved external symbol _FreeImage_Initialise
    Debug/MotionX.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    MotionX.exe - 2 error(s), 1 warning(s)

    I know that the LNK2001 is generally that it can't find the library, but I've included it everywhere I know to.. Any Ideas ??

    Thanks

     
    • Hervé Drolon

      Hervé Drolon - 2005-02-03

      I think you don't understand what static linking means :
      - either you use the DLL and then you need to add the small FreeImage.lib file to your linker
      - or you use the FreeImage library and then you don't need the DLL, but you need to add the big FreeImage.lib to your linker

      The FAQ is only for users who don't want the DLL but the library

       
    • rageu

      rageu - 2005-02-11

      Ok...I've done it

      In fact it's a lot more simple compare to the FAQ when you use the DLL. Maybe you should add a step by step explanation even for this? It could help the newest beginners as I am ;)

      1.add FreeImage.h to the project
      2.add the DLL in your project directory
      3.add the FreeImage.lib in your lib directory
      always use the files of the FreeImage.zip\Dist

      Anyway, it's what I've done...is it the good way?

       
    • rageu

      rageu - 2005-02-11

      I've got EXACTLY the same problem!
      And I'm sorry but I'm quite beginner in VS6 C++ and your answear still not clear enough for me :(

      I'm interested either in the 2 solutions but I can't catch any of them...
      Would you please explain it in an other way?

       

Log in to post a comment.