Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Maybe a library linking bug
Qt 6.11 is out! See what's new in the release blog

Maybe a library linking bug

Scheduled Pinned Locked Moved Qt Creator and other tools
2 Posts 1 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello everyone!
    I'm developing a library set. There are 4 libraries, let's call them libA, libB, libC and libD. B, C and D depends on A. D also depends on C.
    So, when I'm running an example application which uses libA, everything is fine. But if I try using some classes from libB (or C, or D) the application crashes instantly after being launched.
    I'm having this issue with Qt5 only. With Qt4 everything works fine. The OS is Ununtu 12.04. The project's sources are here: https://github.com/the-dark-angel/BeQt/tree/develop (the "develop" branch).
    So, what do?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      I've found the source of my problem. When using Qt5, the initialization order is different from that when using Qt4. For example, look at the following code:
      @//a.h
      class A
      {
      public:
      A() {}
      static const QFont Font;
      static QFont createFont();
      };

      //a.cpp
      const QFont A::Font = A::createFont();

      QFont A::createFont()
      {
      QFont fnt = QApplication::font();
      fnt.setPointSize(15);
      return fnt;
      }@
      It will work fine when Qt4 is used, but you'll get an application crash with Qt5. (The class must be part of a library, of course) Seems like the QtCore and/or QtGui libraries are not loaded when the QApplication::font() method is called.
      I had several places in my code where such a variable initialization technique was used. After removing them, I was able to launch my test application normally. I found out the source of problem using Valgrind (the initializing static method was mentioned in the output).
      Hope this will be helpful.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved