[Qt-interest] Difficulties with statically linking plugins

Atlant Schmidt aschmidt at dekaresearch.com
Fri Aug 20 21:37:47 CEST 2010


Folks:

  I'm trying to statically link my Qt application and running into
  several problem with plugins:

  I'm following the instructions here:

    http://doc.trolltech.com/4.6.2/plugins-howto.html#static-plugins

  And using the qgif plugin as my example. I've built Qt 4.6.2 with
  -static added to and -shared removed from the configuration
  command line and the result was all the expected .a libraries in
  my tree. (Oddly enough, the .../plugins/... directories all
  contain both .so and .a versions of the plugins even though Qt
  was rebuilt from distclean up.)

 -=-=-=-=-=-

  If I simply follow the instructions on that web page, my application
  won't link, complaining:

> /eldk/usr/bin/../lib/gcc/powerpc-linux/4.2.2/../../../../powerpc-linux/bin/ld: cannot find -lqgif
> collect2: ld returned 1 exit status

  That makes a sort of sense, given that the -L line that qmake
  included into the Makefile was:

> -L/usr/lib/qtopia/plugins/imageformats

  and the Qt build procedure certainly doesn't push any of the created libraries
  into my /usr/lib/ directory (and I wouldn't want it to). This sounds like bug in
  qmake; for everything else, it includes -L lines that point to the .../lib/
  directory within my Qt tree.

 -=-=-=-=-=-

  So I tried adding the following strings to the .pro file, first:

> LIBS += -L../plugins/imageformats/

  And later:

> LIBS += -L../plugins/imageformats/ -lqgif


  These both got farther. Qmake built an appropriate -L line into my
  Makefile:

> -L../plugins/imageformats/

  and it built it into the command line appropriately "early" so this time,
  the linker found libqgif.a, but with either version of the line in the
  .pro file, the linker couldn't find the necessary routine within the library,
  so it now reported:

> .obj/release-static-emb-powerpc/my_qt_app.o: In function `__static_initialization_and_destruction_0(int, int)':
> my_qt_app.cpp:(.text+0x32): undefined reference to `qt_plugin_instance_qgif()'
> my_qt_app.cpp:(.text+0x36): undefined reference to `qt_plugin_instance_qgif()'
> collect2: ld returned 1 exit status

 -=-=-=-=-=-

  I then simply moved a copy of libqgif.a into my .../lib/
  directory and with that change, my application built fine!

  So why does the linker get in trouble when the libqgif.a file is
  coming from the directory where Qt built it?

 -=-=-=-=-=-

  Second part of the question:

  We also have our own plugin (for an Epson framebuffer chip).
  AFAIK, it was built exactly the same as the qgif plugin and
  at the same time. But with our plugin, even when I put its
  .a file into my .../lib/ directory, I still get:

> .obj/release-static-emb-powerpc/my_qt_app.o: In function `__static_initialization_and_destruction_0(int, int)':
> my_qt_app.cpp:(.text+0x32): undefined reference to `qt_plugin_instance_qscreenlinuxfbepson()'
> my_qt_app.cpp:(.text+0x36): undefined reference to `qt_plugin_instance_qscreenlinuxfbepson()'
> collect2: ld returned 1 exit status

  similar to when I was trying to access libqgif.a from the
  result directory. In other words, in this case, my "move
  the library" work-around didn't work.

  (FYI: This plug-in has been working okay when dynamically
  loaded.)

  Does anyone know why these things are behaving as they are?

                                      Atlant


________________________________
This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.

Thank you.

Please consider the environment before printing this email.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100820/02e9d91d/attachment.html 


More information about the Qt-interest-old mailing list