Page 1 of 1

Selective undefined references when compiling under Qt/Win

Posted: 2010-08-24T16:57:18-07:00
by blackhaz
I beg my pardon for flood of questions. Probably someone got this before?

Compiling under Qt for Windows results in errors. Looks like everything is fine except the composite function or composite operator. I have pasted compiler output below. The same code compiles fine on Mac. I have compiled the latest version of ImageMagick under CygWin and it works fine. Libraries and headers are found. Any hints? It is strange it barks only on the compose while I have many more IM operations in the code above that.

Thank you!

Max

Running build steps for project DStation...
Starting: "c:/qt/2010.04/qt/bin/qmake.exe" C:/src/DStation/DStation/DStation/DStation.pro -r -spec win32-g++
The process "c:/qt/2010.04/qt/bin/qmake.exe" exited normally.
Starting: "C:/Qt/2010.04/mingw/bin/mingw32-make.exe" -w
mingw32-make: Entering directory `C:/-Astro/DStation/DStation-build-desktop'
C:/Qt/2010.04/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/-Astro/DStation/DStation-build-desktop'
c:\Qt\2010.04\qt\bin\uic.exe ..\..\..\src\DStation\DStation\DStation\dstation.ui -o ui_dstation.h
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\Qt\2010.04\qt\include\QtCore" -I"..\..\..\Qt\2010.04\qt\include\QtGui" -I"..\..\..\Qt\2010.04\qt\include" -I"..\..\..\cygwin\usr\local\include\ImageMagick" -I"..\..\..\Qt\2010.04\qt\include\ActiveQt" -I"debug" -I"." -I"..\..\..\src\DStation\DStation\DStation" -I"." -I"..\..\..\Qt\2010.04\qt\mkspecs\win32-g++" -o debug\main.o ..\..\..\src\DStation\DStation\DStation\main.cpp
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\Qt\2010.04\qt\include\QtCore" -I"..\..\..\Qt\2010.04\qt\include\QtGui" -I"..\..\..\Qt\2010.04\qt\include" -I"..\..\..\cygwin\usr\local\include\ImageMagick" -I"..\..\..\Qt\2010.04\qt\include\ActiveQt" -I"debug" -I"." -I"..\..\..\src\DStation\DStation\DStation" -I"." -I"..\..\..\Qt\2010.04\qt\mkspecs\win32-g++" -o debug\dstation.o ..\..\..\src\DStation\DStation\DStation\dstation.cpp
C:\Qt\2010.04\qt\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\Qt\2010.04\qt\include\QtCore" -I"..\..\..\Qt\2010.04\qt\include\QtGui" -I"..\..\..\Qt\2010.04\qt\include" -I"..\..\..\cygwin\usr\local\include\ImageMagick" -I"..\..\..\Qt\2010.04\qt\include\ActiveQt" -I"debug" -I"." -I"..\..\..\src\DStation\DStation\DStation" -I"." -I"..\..\..\Qt\2010.04\qt\mkspecs\win32-g++" -D__GNUC__ -DWIN32 ..\..\..\src\DStation\DStation\DStation\dstation.h -o debug\moc_dstation.cpp
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\Qt\2010.04\qt\include\QtCore" -I"..\..\..\Qt\2010.04\qt\include\QtGui" -I"..\..\..\Qt\2010.04\qt\include" -I"..\..\..\cygwin\usr\local\include\ImageMagick" -I"..\..\..\Qt\2010.04\qt\include\ActiveQt" -I"debug" -I"." -I"..\..\..\src\DStation\DStation\DStation" -I"." -I"..\..\..\Qt\2010.04\qt\mkspecs\win32-g++" -o debug\moc_dstation.o debug\moc_dstation.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\DStation.exe debug/main.o debug/dstation.o debug/moc_dstation.o -L"c:\Qt\2010.04\qt\lib" -lmingw32 -lqtmaind -LC:\cygwin\usr\local\lib -lMagick++ -lQtGuid4 -lQtCored4
mingw32-make[1]: Leaving directory `C:/-Astro/DStation/DStation-build-desktop'
mingw32-make: Leaving directory `C:/-Astro/DStation/DStation-build-desktop'
debug/dstation.o:C:\-Astro\DStation\DStation-build-desktop/../../../src/DStation/DStation/DStation/dstation.cpp:280: undefined reference to `Magick::Image::composite(Magick::Image const&, long, long, MagickCore::CompositeOperator)'
debug/dstation.o:C:\-Astro\DStation\DStation-build-desktop/../../../src/DStation/DStation/DStation/dstation.cpp:306: undefined reference to `Magick::Image::composite(Magick::Image const&, long, long, MagickCore::CompositeOperator)'
debug/dstation.o:C:\-Astro\DStation\DStation-build-desktop/../../../src/DStation/DStation/DStation/dstation.cpp:372: undefined reference to `Magick::Image::composite(Magick::Image const&, long, long, MagickCore::CompositeOperator)'
debug/dstation.o:C:\-Astro\DStation\DStation-build-desktop/../../../src/DStation/DStation/DStation/dstation.cpp:373: undefined reference to `Magick::Image::composite(Magick::Image const&, long, long, MagickCore::CompositeOperator)'
debug/dstation.o:C:\-Astro\DStation\DStation-build-desktop/../../../src/DStation/DStation/DStation/dstation.cpp:381: undefined reference to `Magick::Image::composite(Magick::Image const&, long, long, MagickCore::CompositeOperator)'
debug/dstation.o:C:\-Astro\DStation\DStation-build-desktop/../../../src/DStation/DStation/DStation/dstation.cpp:382: more undefined references to `Magick::Image::composite(Magick::Image const&, long, long, MagickCore::CompositeOperator)' follow
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\DStation.exe] Error 1
mingw32-make: *** [debug] Error 2
The process "C:/Qt/2010.04/mingw/bin/mingw32-make.exe" exited with code %2.
Error while building project DStation (target: Desktop)
When executing build step 'Make'

Re: Selective undefined references when compiling under Qt/W

Posted: 2010-08-26T06:46:12-07:00
by blackhaz
This has been resolved.

Probably this information will be useful for those who are using Magick++ under Qt for Windows:

1) IM compiled under gcc/Cygwin does not work as it can't find reference to composite operators. Probably naming convention issue. You need to compile IM under MSYS/MinGW as MinGW is what Qt for Windows uses by default.

2) Using pre-compiled MinGW binary won't work as it looks like to be compiled with sjlj extensions and other compiler features unavailable to Qt's MinGW.

3) Here are the caveats compiling IM with FFTW and some important libraries under MinGW:

* fftw builds as static library by default. Configure with --with-our-malloc16 --with-windows-f77-mangling --enabled-shared --disable-static --enable-portable-binary --enable-sse2
to build DLLs. My MSYS does not handle pthreads correctly for unknown reasons for this library, so I have not enabled them when building fftw.

* Redifinition of type boolean in jpeglib. Edit /local/include/jconfig.h, and add before the line 24 that has typedef unsigned char boolean: #ifndef HAVE_BOOLEAN
and #endif after that line. Edit Imagemagick_src_directory/coders/jpeg.c and add #define HAVE_BOOLEAN there at the top of includes.

* libpng 1.4.x problem with undefined references. Build libpng-1.5.0 (works with 1.5.0beta45)

After this, I have successfully compiled IM 6.6.3-9 and is using all its functions in my Qt app - Windows version.