Subject: Re: [1/2 OT] ImageMagick, OpenMP and QThread [Mac OS X] [WORKAROUND]?
Date: Friday 29th January 2010 08:36:27 UTC (over 7 years ago)
Knoll Oliver, ITS-CMT-SUI-SL-SFR-FIN-DEV wrote on Wednesday, January 27, 2010 4:38 PM: > ... > My application crashes when I want to create an ImageMagick "Image" > within a QThread. This is the offending code: To whom it might concern, here is a crude workaround for the situation when you want to - call ImageMagick (or any other library) from within a QThread (or any other thread such as POSIX) - the compiler/OpenMP support library fails when called from a thread (see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42616) The workaround: disable OpenMP in ImageMagick. When you compile ImageMagick yourself, fine, simply add '--disable-openmp' when calling configure: $> configure --disable-openmp In my case I installed ImageMagick via "Mac Ports". I tried disabling some "port variants", like $> sudo port install -v ImageMagick -- -openmp but to no avail (I simply guessed the 'openmp' name), ImageMagick was always build with OpenMP support. So I modified the 'Portfile' 1. Make sure you have write-access to /opt/local/var/macports/sources/rsync.macports.org/release/ports/graphics/Portfile (As administrator, I temporarily changed the owner of the graphics folder and Portfile from root to administrator, my admin user) 2. Append to section 'configure.args' the line --disable-openmp: configure.args \ --enable-shared \ --enable-static \ --disable-ltdl-install \ [...] --without-rsvg \ --without-lqr \ --disable-openmp 3. Uninstall ImageMagick $> sudo port uninstall ImageMagick 4. Install again $> sudo port install -v ImageMagick 5. While the package is installing make sure that OpenMP support is really disabled, check CXXFLAGS (they are printed out when specifying the -v verbose option) etc. there should be no -fopenmp or -lgomp anymore: PREFIX = /opt/local EXEC-PREFIX = /opt/local VERSION = 6.5.8 CC = /usr/bin/gcc-4.2 -std=gnu99 CFLAGS = -O2 -arch x86_64 -Wall -W -D_THREAD_SAFE CPPFLAGS = -I/opt/local/include/ImageMagick PCFLAGS = DEFS = -DHAVE_CONFIG_H LDFLAGS = -L/opt/local/lib -L/opt/local/lib -L/opt/local/lib MAGICK_LDFLAGS = -L/opt/local/lib -L/opt/local/lib -L/opt/local/lib -L/opt/local/lib LIBS = -lMagickCore -ltiff -lfreetype -ljpeg -L/opt/local/lib -lfontconfig -lexpat -lfreetype -lz -liconv -lXext -lSM -lICE -lX11 -lXt -lbz2 -lz -lm -lpthread -lltdl CXX = /usr/bin/g++-4.2 CXXFLAGS = -O2 -arch x86_64 -Wall -W -D_THREAD_SAFE When I uninstalled the ImageMagick package the 'Portfile' still remained at its place. But I don't know when it is updated, maybe with an 'port upgrade' command at some time. And obviously you have to install ImageMagick a first time to actually have this file ;) Hope this is of any help to anyone :) Cheers, Oliver -- Oliver Knoll Dipl. Informatik-Ing. ETH COMIT AG - ++41 79 520 95 22