views:

470

answers:

3

I'm attempting to compile a working copy of the MagickNet class library (DLL) using the sources from the ImageMagick and MagickNet libraries.

I was unable to obtain a copy of the MagickNet source files from the creator's homepage as it is currently down, so I was forced to obtain the files and C++ project file from here, courtesy of a Google search.

Following the instructions stated here and here, I created a project using the "static multi-threaded DLL" option and compiled it, before moving to the MagickNet project file and compiling that as well, after making sure all the paths pointed to the right folders.

Even so, I keep receiving this error upon compilation:

CORE_RL_magick_.lib(nt-base.obj) : error LNK2005: _DllMain@12 already defined in MSVCRT.lib(dllmain.obj)

I also receive 371 other errors, all of them related to an "unresolved external symbol xxxxxxxx", and a final 372nd error describing that I have "195 unresolved externals".

I managed to solve the DllMain error above by commenting out the DllMain declaration from the nt-base.c source file from the CORE_magick project in the ImageMagick solution, however the 372 other "unresolved externals" errors still remain.

I had performed a (Google) search for people with similar issues, and some have said that the author had offered a download of a pre-compiled MagickNet DLL which works 100%, however (as I mentioned earlier) his homepage appears to be inaccessible now.

I'm currently seeking one of these solutions:

  1. A solution to my compilation issue, as I may be making a mistake on my part since I'm not familiar with C++ at all,
  2. A link to another MagickNet source files/project zip that is 100% confirmed to compile correctly with the latest version of ImageMagick,
  3. A link to a 100% working precompiled copy of the MagickNet DLL, if anyone kept a copy from the author's homepage. It should be approximately 3MB as it contains the ImageMagick libraries as well.

I would really appreciate any one of these solutions, as I desperately require ImageMagick's ability to manipulate and convert images, as well as MagickNet's ease of use. I can provide additional details if you need more information.

Also, I am using Visual Studio 2008 to compile the source files, and the supplied projects convert with no issues at all.

A: 

You're seeing a linker issue due to (I'm guessing, and it seems to be true based on a google search) the link order of the msvcrt and MFC libraries. http://support.microsoft.com:80/support/kb/articles/q148/6/52.asp&NoWebContent=1">This article on MSDN seems to have a solution - dated, but the basic issues are the same, and so the options should be similar.

Harper Shelby
I've tried that article, but it didn't seem to have any effect. In fact, it bumped the number of errors to 4000+.
TheFuzzy
A: 

I was just able to get past this and was successfully able to compile MagickNET against the latest version of ImageMagick. I had to do several things.

  1. Configured ImageMagick to use StaticMTDll.
  2. Edited magick-config.h to undefine X11 support.
  3. Removed the CORE_xlib project from the ImageMagick solution.
  4. Clean/Rebuild of ImageMagick
  5. Added the following lib files to the linker settings for MagickNet

    CORE_DB_bzlib_.lib
    CORE_DB_coders_.lib
    CORE_DB_jbig_.lib
    CORE_DB_jpeg_.lib
    CORE_DB_magick_.lib
    CORE_DB_png_.lib
    CORE_DB_tiff_.lib
    CORE_DB_ttf_.lib
    CORE_DB_wand_.lib
    CORE_DB_wmf_.lib
    CORE_DB_zlib_.lib
    CORE_DB_libxml_.lib
    CORE_DB_jp2_.lib
    CORE_DB_lcms_.lib
    Ws2_32.lib

  6. Built MagickNet

I did have to make updates to MagickNet because methods have been deprecated since the source release on the MagickNet website. I'll try and put a repository online to share the entire solution.

bromanko
A: 

I had the exact same problem and Bromanko's answer solved it ...with one minor addition:

in imagemagick's magick-config.h, in addition to commmenting out the line:

define MAGICKCORE_X11_DELEGATE

...need to also comment out the line:

define ProvideDllMain

then you'll be cooking with gas.

Thanks bromanko...

Andy Idsinga