Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Custom Widget compilation problem
Forum Update on Monday, May 27th 2025

Custom Widget compilation problem

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.6k Views
  • 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.
  • S Offline
    S Offline
    swhweng
    wrote on 27 Jun 2011, 18:52 last edited by
    #1

    Hello dear developers/specialists/coders/programers.
    How are you doing?
    I develop custom applications for major platforms and I use QSwitch widget from
    [url]http://qt-apps.org/content/show.php/QSwitch?content=72481[/url]
    that is inherited from QWidget and uses <QtDesigner/QDesignerExportWidget>
    @class QDESIGNER_WIDGET_EXPORT QSwitch : public QWidget
    {...}@
    I put it to ui generated from Qt Designer at Qt Designer ( QSwitch plugin added to it ),
    in Ubuntu I compile my project with that widget well , but on Windows I get the following errors each time compiler meets QSwitch instances:

    ./release\mainwindow.o:mainwindow.cpp:(.text+0x2c6a6): undefined reference to _imp___ZN7QSwitch8setValueEb' ./release\mainwindow.o:mainwindow.cpp:(.text+0x56b5a): undefined reference to _imp___ZN7QSwitch8setValueEb'
    ./release\mainwindow.o:mainwindow.cpp:(.text+0x56c2e): undefined reference to _imp___ZN7QSwitch8setValueEb' ./release\mainwindow.o:mainwindow.cpp:(.text+0x57023): undefined reference to _imp___ZN7QSwitch8setValueEb'
    ./release\mainwindow.o:mainwindow.cpp:(.text+0x5707f): undefined reference to _imp___ZN7QSwitch8setValueEb' ./release\mainwindow.o:mainwindow.cpp:(.text+0x5723c): more undefined references to _imp___ZN7QSwitch8setValueEb' follow
    ./release\mainwindow.o:mainwindow.cpp:(.text$_ZN14Ui_MainControl7setupUiEP11QMainWindow[Ui_MainControl::setupUi(QMainWindow*)]+0xa2e2): undefined reference to _imp___ZN7QSwitchC1EP7QWidget' ./release\mainwindow.o:mainwindow.cpp:(.text$_ZN14Ui_MainControl7setupUiEP11QMainWindow[Ui_MainControl::setupUi(QMainWindow*)]+0xb5b5): undefined reference to _imp___ZN7QSwitch8setValueEb'
    ./release\mainwindow.o:mainwindow.cpp:(.text$_ZN14Ui_MainControl7setupUiEP11QMainWindow[Ui_MainControl::setupUi(QMainWindow*)]+0xb5fa): undefined reference to _imp___ZN7QSwitch7setTypeENS_10SwitchTypeE' ./release\qswitch.o:qswitch.cpp:(.text+0x4f): undefined reference to _imp___ZN7QSwitch12valueChangedEb'
    ./release\qswitch.o:qswitch.cpp:(.text+0x79): undefined reference to _imp___ZN7QSwitch12valueChangedEb' ./release\qswitch.o:qswitch.cpp:(.text+0xdd): undefined reference to _imp___ZTV7QSwitch'
    ./release\qswitch.o:qswitch.cpp:(.text+0x169): undefined reference to _imp___ZTV7QSwitch' ./release\moc_qswitch.o:moc_qswitch.cpp:(.text+0x15): undefined reference to _imp___ZN7QSwitch16staticMetaObjectE'
    ./release\moc_qswitch.o:moc_qswitch.cpp:(.text+0x26): undefined reference to _imp___ZN7QSwitch16staticMetaObjectE' ./release\moc_qswitch.o:moc_qswitch.cpp:(.text+0x59): undefined reference to _imp___ZN7QSwitch16staticMetaObjectE'
    ./release\moc_qswitch.o:moc_qswitch.cpp:(.text+0xc3): undefined reference to _imp___ZN7QSwitch11toggleValueEv' ./release\moc_qswitch.o:moc_qswitch.cpp:(.text+0x11d): undefined reference to _imp___ZN7QSwitch7setTypeENS_10SwitchTypeE'
    ./release\moc_qswitch.o:moc_qswitch.cpp:(.text+0x151): undefined reference to _imp___ZN7QSwitch7setTypeENS_10SwitchTypeE' ./release\moc_qswitch.o:moc_qswitch.cpp:(.text+0x16e): undefined reference to _imp___ZN7QSwitch8setValueEb'
    ./release\moc_qswitch.o:moc_qswitch.cpp:(.text+0x1c7): undefined reference to `_imp___ZN7QSwitch8setValueEb'
    collect2: ld returned 1 exit status

    Please help: Why such errors does anybody know? What is wrong/unclear? How to successfully compile on Windows ui with QSwitch widget?
    Thanks.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      swhweng
      wrote on 27 Jun 2011, 19:10 last edited by
      #2

      ...I've solved the problem now by removing @QDESIGNER_WIDGET_EXPORT@ macro and @#include <QtDesigner/QDesignerExportWidget>@ in the qswitch.h.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        swhweng
        wrote on 27 Jun 2011, 19:11 last edited by
        #3

        But...,perhaps it will be interesting, why on Windows it can't be compiled with the macro?

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          ZapB
          wrote on 28 Jun 2011, 06:45 last edited by
          #4

          It is because MS compiler uses symbol visibility rules by default (ie it only exports those symbols that you tell it to). Whereas with GCC you have to explicitly enable this feature by using

          @
          CONFIG += hide_symbols
          @

          If you add the above to your .pro file it will also fail to link on Linux due to unexported symbols. We use this as it reduces the number of symbols exported in our libs and hence slightly improves application start up time and keeps the private parts of our API private.

          Nokia Certified Qt Specialist
          Interested in hearing about Qt related work

          1 Reply Last reply
          0

          1/4

          27 Jun 2011, 18:52

          • Login

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