[Qt-interest] Static compile with cmake on windows: jpeg/gif plugins

BedLamp bedlamp at gmail.com
Wed Jun 3 16:05:45 CEST 2009


Hi

I'm trying to statically compile my program in windows, and want to include
the qgif and qjpeg plugins in the final exe. Normally you would just follow
http://doc.trolltech.com/4.5/plugins-howto.html#static-plugins and all would
work, but i'm using cmake, not qmake, and cannot find the equivalent
configuration for cmake.

I currently have this in my CMakeLists.txt:

IF(WIN32)
  FIND_LIBRARY(QT_GIF_PLUGIN qgif PATHS ${QT_PLUGINS_DIR} PATH_SUFFIXES
imageformats)
  FIND_LIBRARY(QT_JPEG_PLUGIN qjpeg PATHS ${QT_PLUGINS_DIR} PATH_SUFFIXES
imageformats)
  SET(QT_USE_QTPLUGIN TRUE)
ENDIF()

...

IF(WIN32)
  ADD_EXECUTABLE(foo WIN32 ${FOO_SRCS_CXX} ${QT_GIF_PLUGIN}
${QT_JPEG_PLUGIN})
ENDIF()

and in main.cpp:

#ifdef WIN32
  #include <QtPlugin>

  Q_IMPORT_PLUGIN(qgif)
  Q_IMPORT_PLUGIN(qjpeg)
#endif

It seems to find the library ok, but when trying to link the executable i
get these errors:

CMakeFiles\foo.dir\main.cpp.obj(.text+0xa2):main.cpp: undefined reference to
`
qt_plugin_instance_qjpeg()'
CMakeFiles\foo.dir\main.cpp.obj(.text+0x193):main.cpp: undefined reference
to
`qt_plugin_instance_qgif()'
collect2: ld returned 1 exit status

What is the correct way to include these plugins using cmake?

Tim Sjoberg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090603/f99bd58b/attachment.html 


More information about the Qt-interest-old mailing list