How to compile G’MIC lib with MSVC2015?


How to compile G’MIC lib with MSVC2015 compiler? 64 and 32 -bit
I need lib for Qt project

(David Tschumperlé) #2

It’s been a while since I tried to compile G’MIC on MSVC, but last time it was OK.
I’ll probably give another try today, and tell you how it is going.


Thanks! Will wait…


I just need some guide. Sorry for newbie quastion.


I have the same issue. Compiling the static lib generates something that really looks like an infinite loop in lc (May not be infinite, I gave up after 5 hours) :slight_smile:
If it’s not possible, would it be possible to provide the libcgmicstatic.lib file for version 2.0? I could do with that and use the gmic_libc interface.


infinite loop only when compiling static lib? Dynamic is ok?


Didn’t try, but static or dynamic shouldn’t change that much at compilation level. Furthermore, for packaging reason, I prefer not to pack all dependencies.


I forgot. I used cmake_gui to create the MSVC solution.

(David Tschumperlé) #9

Hello. Yes, there have always been a lot of issues when trying to compile the libgmic with Microsoft Visual Studio.
Particularly, when the optimizations are enabled (so in Release mode), this takes forever to complete (several hours).
Don’t ask me why, I suspect this is a problem with the compiler itself :slight_smile:

I haven’t made a lot of tests, so I can’t say much about that. What I did is compiling the libgmic in Debug mode, and without any dependencies activated, so something pretty useless at the end, but it was done mainly to see if there was compiler warnings or errors that I could fix.

Sorry for this non-answer by the way :slight_smile:


So… it’s impossible? Make release lib on MSVC2015 x32? G’MIC 1.7.9

(David Tschumperlé) #11

I guess that the best way to use libgmic with MSVC is actually using the libcgmic .dll file, look at:

The .dll is available as a pre-compiled library file, which makes it easy to use on MSVC (as shown in the link below).


I agree and it works mostly like a charm for version 1.7.
I have some issues though.Inplace mode generates an error and freeing external images plays some tricks with the stack when several images are to be freed.

I wanted to try with the latest version, but the distribution for version 2.0 lacks the .lib associated with the .dll.

(David Tschumperlé) #13

Ah that is interesting. I guess @Tobias_Fleischer might be interested by any feedback on the use of its libcgmic.
He has told me once how to create the .lib file associated to a .dll, but I cannot remember the command.
If you have any idea :slight_smile: I could add the .lib file to the newest Windows archive ASAP.

(Tobias Fleischer) #14

If it is not included with the download, then you first have to create a .def file with the exported functions.
Then create a .lib stub file from that .def file.
Here the process is explained in detail:

(Tobias Fleischer) #15

Oh, and it is a good idea to add the parameter /MACHINE:x64 to the “lib” call to generate 64bit libs.

Here is how I create my 64bit libs:

lib /def:libcgmic.def /out:libcgmic.lib /machine:x64
lib /def:libcgmicstatic.def /out:libcgmicstatic.lib /machine:x64


Great. Thank you so much.
It works perfectly.

One more question if I may. Using libgmic, how can I have access to the function init_rc or change the path to where the cluts are stored ? (need to access cluts without internet connection).

(Tobias Fleischer) #17

Interesting question about init_rc :slight_smile:
The libcgmic approach works mostly the same as the command line application, therefore I have to ask: how is it solved there?
@David_Tschumperle: is it currently possivble to enter the path to the cluts for a command on the GMIC CLI application?

(Tobias Fleischer) #18

@Philemo: if you could give me more info or a little sample application using libcgmic that shows the bugs you described (inplace sometimes not working or porblems when freeing external images), I will try to track them down and fix them.

(David Tschumperlé) #19

Yes, by setting the environment variable %GMIC_PATH% to a valid folder name.

(Tobias Fleischer) #20

Then I think this should also work for @Philemo 's requirements :slight_smile: