Page 1 of 1

Static compiling for Win & Mac

Posted: 2014-03-06T05:54:06-07:00
by PBert
Hi Folks,

my apologies in advance for the lengthy post that follows - but I thought best to explain/cover my position as best as possible.

I'm in the process of building a software plugin under another SDK environment (for Win and Mac, possibly Linux too). This software builds fine inside of VS 2010 Express, but getting ImageMagic to co-operate is starting to stretch my (albeit lack-of!) knowledge with C++ programming.

There are a few rules governing the making of this software, but the main one in regards to IM (and any other non-SDK related material) is that it needs to be built into the software - i.e. no other links/libraries/dlls/libs etc (STL-based stuff is an exception).

When I add the main header to my project file, and try to build my plugin from VS, it fails with a LNK2019 unresolved external symbol Magick::InitializeMagick(...). I get the same error with Magick::Image() and so on. My searches to date suggest there's a missing CORE_RL_Magick++_.lib file, but I cannot find this file anywhere, nor know how to get it. I'm not able to use the button demo project as a template to start with, because of the nature of the other SDK environment.

Am I needing the static version in order to do the above ("build" it into the plugin)? Is it possible to achieve this without the need for other files for the user? I've run through the configure.exe program and tried the Windows install .txt file steps etc, but unfortunately neither seem to get me going.

Is it possible at all (or is there a download somewhere!? Or could one be made available?) where I can just add IM to my project via a simple #include "My_IM_Header.h" call without having all the other un-needed bits and pieces packaged in the download zips? I'm quite lost with the downloads I've tried - they feel messy - their full of folders and files and just make it difficult to grasp (for a non-coder like me anyway!). So I tried to put together a folder system (see below) to keep things simple and easy to move amongst platforms, which for what it's worth, works, until I start calling the classes. I.e. it builds with the header file included, but once I add for example Magick::Image() the build fails.

I'm not at all concerned with build times or the size of the end-software file. What's important is that it's built into the plugin without the need for other "supporting" files. Is someone able to clarify for me (or provide..) this kind of setup? This is not a student-based request! :) Cheers!

PBert.

Simple folder/file system:

MyImageMagic (FOLDER)
- MyMagic.h --> the only header added to the project
- Includes (FOLDER)
- Include_1.h
- Include_2.h
- Include_3.h
- and etc!!

Re: Static compiling for Win & Mac

Posted: 2014-03-12T07:14:27-07:00
by fubert
Select in ImageMagick->VisualMagick configure.exe "Static Multithreaded DLL Runtimes"
Select Decorade exe files with build options.
Edit the config file and remove "#define ProvideDllMain"

Complie everything with Visual Studio 2010 for debug and release.
Copy the .lib files to your source folder and use this code.

Code: Select all

#include "MyMagick.h"

// this lack to this define is the reason of your problem
#define STATIC_MAGICK 1

#include <Magick++.h>


using namespace Magick;

MyMagick::load()
{
	// use ImageMagick here
}

Code: Select all

#pragma once

#ifdef MyMagick_EXPORTS
#ifndef MyMagick_STATIC_LIB
#define MyMagick __declspec(dllexport)
#else
#define MyMagick
#endif
#else
#if (defined(MyMagick_IMPORTS) || defined(_DLL_IMP_)) && !defined(MyMagick_STATIC_LIB)
#define MyMagick __declspec(dllimport)
#else
#define MyMagick
#endif
#endif


#ifdef _WIN64
#ifdef _DEBUG
#pragma comment(lib, "CORE_DB64_bzlib_.lib")
#pragma comment(lib, "CORE_DB64_cairo_.lib")
#pragma comment(lib, "CORE_DB64_coders_.lib")
#pragma comment(lib, "CORE_DB64_croco_.lib")
#pragma comment(lib, "CORE_DB64_ffi_.lib")
#pragma comment(lib, "CORE_DB64_filters_.lib")
#pragma comment(lib, "CORE_DB64_glib_.lib")
#pragma comment(lib, "CORE_DB64_jbig_.lib")
#pragma comment(lib, "CORE_DB64_jp2_.lib")
#pragma comment(lib, "CORE_DB64_jpeg_.lib")
#pragma comment(lib, "CORE_DB64_lcms_.lib")
#pragma comment(lib, "CORE_DB64_librsvg_.lib")
#pragma comment(lib, "CORE_DB64_libxml_.lib")
#pragma comment(lib, "CORE_DB64_lqr_.lib")
#pragma comment(lib, "CORE_DB64_magick_.lib")
#pragma comment(lib, "CORE_DB64_Magick++_.lib")
#pragma comment(lib, "CORE_DB64_openjpeg_.lib")
#pragma comment(lib, "CORE_DB64_pango_.lib")
#pragma comment(lib, "CORE_DB64_pixman_.lib")
#pragma comment(lib, "CORE_DB64_png_.lib")
#pragma comment(lib, "CORE_DB64_tiff_.lib")
#pragma comment(lib, "CORE_DB64_ttf_.lib")
#pragma comment(lib, "CORE_DB64_wand_.lib")
#pragma comment(lib, "CORE_DB64_webp_.lib")
#pragma comment(lib, "CORE_DB64_zlib_.lib")
#else // Debug
#pragma comment(lib, "CORE_RL64_bzlib_.lib")
#pragma comment(lib, "CORE_RL64_cairo_.lib")
#pragma comment(lib, "CORE_RL64_coders_.lib")
#pragma comment(lib, "CORE_RL64_croco_.lib")
#pragma comment(lib, "CORE_RL64_ffi_.lib")
#pragma comment(lib, "CORE_RL64_filters_.lib")
#pragma comment(lib, "CORE_RL64_glib_.lib")
#pragma comment(lib, "CORE_RL64_jbig_.lib")
#pragma comment(lib, "CORE_RL64_jp2_.lib")
#pragma comment(lib, "CORE_RL64_jpeg_.lib")
#pragma comment(lib, "CORE_RL64_lcms_.lib")
#pragma comment(lib, "CORE_RL64_librsvg_.lib")
#pragma comment(lib, "CORE_RL64_libxml_.lib")
#pragma comment(lib, "CORE_RL64_lqr_.lib")
#pragma comment(lib, "CORE_RL64_magick_.lib")
#pragma comment(lib, "CORE_RL64_Magick++_.lib")
#pragma comment(lib, "CORE_RL64_openjpeg_.lib")
#pragma comment(lib, "CORE_RL64_pango_.lib")
#pragma comment(lib, "CORE_RL64_pixman_.lib")
#pragma comment(lib, "CORE_RL64_png_.lib")
#pragma comment(lib, "CORE_RL64_tiff_.lib")
#pragma comment(lib, "CORE_RL64_ttf_.lib")
#pragma comment(lib, "CORE_RL64_wand_.lib")
#pragma comment(lib, "CORE_RL64_webp_.lib")
#pragma comment(lib, "CORE_RL64_zlib_.lib")
#endif // _DEBUG


#else // _WIN64
#ifdef _DEBUG
#pragma comment(lib, "CORE_DB_bzlib_.lib")
#pragma comment(lib, "CORE_DB_cairo_.lib")
#pragma comment(lib, "CORE_DB_coders_.lib")
#pragma comment(lib, "CORE_DB_croco_.lib")
#pragma comment(lib, "CORE_DB_ffi_.lib")
#pragma comment(lib, "CORE_DB_filters_.lib")
#pragma comment(lib, "CORE_DB_glib_.lib")
#pragma comment(lib, "CORE_DB_jbig_.lib")
#pragma comment(lib, "CORE_DB_jp2_.lib")
#pragma comment(lib, "CORE_DB_jpeg_.lib")
#pragma comment(lib, "CORE_DB_lcms_.lib")
#pragma comment(lib, "CORE_DB_librsvg_.lib")
#pragma comment(lib, "CORE_DB_libxml_.lib")
#pragma comment(lib, "CORE_DB_lqr_.lib")
#pragma comment(lib, "CORE_DB_magick_.lib")
#pragma comment(lib, "CORE_DB_Magick++_.lib")
#pragma comment(lib, "CORE_DB_openjpeg_.lib")
#pragma comment(lib, "CORE_DB_pango_.lib")
#pragma comment(lib, "CORE_DB_pixman_.lib")
#pragma comment(lib, "CORE_DB_png_.lib")
#pragma comment(lib, "CORE_DB_tiff_.lib")
#pragma comment(lib, "CORE_DB_ttf_.lib")
#pragma comment(lib, "CORE_DB_wand_.lib")
#pragma comment(lib, "CORE_DB_webp_.lib")
#pragma comment(lib, "CORE_DB_zlib_.lib")

#else // Debug
#pragma comment(lib, "CORE_RL_bzlib_.lib")
#pragma comment(lib, "CORE_RL_cairo_.lib")
#pragma comment(lib, "CORE_RL_coders_.lib")
#pragma comment(lib, "CORE_RL_croco_.lib")
#pragma comment(lib, "CORE_RL_ffi_.lib")
#pragma comment(lib, "CORE_RL_filters_.lib")
#pragma comment(lib, "CORE_RL_glib_.lib")
#pragma comment(lib, "CORE_RL_jbig_.lib")
#pragma comment(lib, "CORE_RL_jp2_.lib")
#pragma comment(lib, "CORE_RL_jpeg_.lib")
#pragma comment(lib, "CORE_RL_lcms_.lib")
#pragma comment(lib, "CORE_RL_librsvg_.lib")
#pragma comment(lib, "CORE_RL_libxml_.lib")
#pragma comment(lib, "CORE_RL_lqr_.lib")
#pragma comment(lib, "CORE_RL_magick_.lib")
#pragma comment(lib, "CORE_RL_Magick++_.lib")
#pragma comment(lib, "CORE_RL_openjpeg_.lib")
#pragma comment(lib, "CORE_RL_pango_.lib")
#pragma comment(lib, "CORE_RL_pixman_.lib")
#pragma comment(lib, "CORE_RL_png_.lib")
#pragma comment(lib, "CORE_RL_tiff_.lib")
#pragma comment(lib, "CORE_RL_ttf_.lib")
#pragma comment(lib, "CORE_RL_wand_.lib")
#pragma comment(lib, "CORE_RL_webp_.lib")
#pragma comment(lib, "CORE_RL_zlib_.lib")
#endif // _DEBUG
#endif // _WIN64

class dclMacro MyMagick
{
	public:
	void load();
};

add the image magick libpath to your project and
compile Mymagick as a DLL.

MyMagick.dll size will be about 6MB in release mode.

Re: Static compiling for Win & Mac

Posted: 2014-04-25T19:58:00-07:00
by PBert
Hi there fubert (love the name :D )!

I wasn't alerted to a reply. Thanks for posting a response. However, to usual PBert standards, I simply cannot get it to compile. Following the steps seems to get me further than before, but the build fails with 36 errors such as:

LNK2019: unresolved external symbol __imp__inet_addr@4 in function _WspiapiParseV4Address@8

I'm guessing this is a missing header/obj file. I'm using Image Magic 6.8.5, don't know if that makes any difference (I did comment out some .lib files that weren't there). One step I'm unclear about is the MyMagic.dll file. Is there a project in the IM folders that I've got to build to get that? Or is that a reference to my project file once it's built?

My project ends up a library file, but not as a dll (different extension, but still a library file). Is there any way to just add include files by themselves to get the complete IM? I would find that easier - build times/sizes are irrelevant for my purposes. Would also allow me to go into the headers to make some changes (there are conflicts between the sdk I'm working in, and the IM package - no big deal, but I can't edit the sdk that's all, so IM has to be ammended). If not, then that's kewl bananas. Am just very keen to get this project going! Debugging is not a necessity either, I have to build the project and operate it in another program anyway (it's a concept plugin I'm putting together for other software).

My lack of C++ knowledge is probably my downfall here! Cheers,

PBert.

Re: Static compiling for Win & Mac

Posted: 2014-09-01T04:49:41-07:00
by Spikky
In the end, I cannot read or write images to/from disk. However calling `convert` in bin directory of my IM build works fine.
What could be the reason? What sould i check?