Results 1 to 5 of 5

Thread: Help with undefined reference in Windows with mingw32

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Help with undefined reference in Windows with mingw32

    Hi,

    I'm getting undefined reference when I build an application in Windows witn mingw32 (it does not happen in Linux). The application is divided in two parts:

    1. A set of designer plugins with the PRO like:
    Qt Code:
    1. QT += core gui sql
    2. CONFIG += designer plugin debug_and_release
    3. TARGET = $$qtLibraryTarget(impwidgetsplugin)
    4. TEMPLATE = lib
    5. ....
    To copy to clipboard, switch view to plain text mode 

    This generate the files: libimpwidgetsplugin.a and impwidgetsplugin.dll in c:\ilri\crossimpact\

    2. A set of plugins in a library that requires impwidgetsplugin with the PRO like:
    Qt Code:
    1. QT += core gui sql svg
    2.  
    3. TARGET = $$qtLibraryTarget(impmainmodules)
    4. TEMPLATE = lib
    5. CONFIG += plugin
    6.  
    7. win32:LIBS += c:\ilri\crossimpact\libimpwidgetsplugin.a
    8. ....
    To copy to clipboard, switch view to plain text mode 

    The problem is that I always get:
    Qt Code:
    1. ./debug\plots.o:C:\ilri\crossimpact\plugins\syschar\impmainmodules/modules/plots.cpp:203: undefined reference to `impgenmaint::insertKeyField(QString, QVariant, bool)'
    To copy to clipboard, switch view to plain text mode 
    Here, impgenmaint::insertKeyField(QString, QVariant, bool) is defined in the designer plugin impwidgetsplugin.dll

    I can see that mingw32 is apparently using the library:
    Qt Code:
    1. mingw32-make[1]: Entering directory `C:/ilri/crossimpact/plugins/syschar/impmainmodules'
    2. g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -shared -Wl,--out-implib,..\..\..\libimpmainmodules.a -o ..\..\..\impmainmodules.dll object_script.impmainmodules.Debug -L"c:\Qt\2010.03\qt\lib" c:\ilri\crossimpact\libimpwidgetsplugin.a -lQtSvgd4 -lQtSqld4 -lQtGuid4 -lQtCored4
    To copy to clipboard, switch view to plain text mode 

    Any idea how I need to configure the PRO so it properly links it?

    Many thanks for any help.
    Carlos.

  2. #2
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Help with undefined reference in Windows with mingw32

    Try
    Qt Code:
    1. win32:LIBS += -Lc:/ilri/crossimpact -limpwidgetsplugin
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Help with undefined reference in Windows with mingw32

    Hi,

    Thanks for your reply.

    I tried that and still does not work.

    I also try to build both libraries on release but I get the same result

    This is the first error:
    Qt Code:
    1. ./release\plots.o:plots.cpp:(.text+0x13f5): undefined reference to `calcDialog::calcDialog(QWidget*)'
    To copy to clipboard, switch view to plain text mode 

    Indeed the code in plots.cpp uses calcDialog like:
    Qt Code:
    1. #include <calcdialog.h>
    2. ....
    3. calcDialog calc;
    4. calc.setDatabase(dataBase);
    5. calc.setCurrentDisplay(index.data().toFloat());
    6. calc.exec();
    7. ....
    To copy to clipboard, switch view to plain text mode 

    In the PRO I have the include path of calculator:
    Qt Code:
    1. INCLUDEPATH += ../../../plugins/interfaces ../../designer/impwidgets ../../designer/impwidgets/widgets/calculator
    To copy to clipboard, switch view to plain text mode 

    So, I really don't know what is wrong because in Linux it works ok with:
    Qt Code:
    1. unix:LIBS += -L/home/cquiros/data/projects/tools/crossimpact -limpwidgetsplugin
    To copy to clipboard, switch view to plain text mode 
    Many thanks,
    Carlos.
    Last edited by qlands; 22nd March 2012 at 07:06.

  4. #4
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Help with undefined reference in Windows with mingw32

    Post content of both pro files, maybe there's a problem you're missing.

  5. The following user says thank you to Spitfire for this useful post:

    qlands (23rd March 2012)

  6. #5
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Help with undefined reference in Windows with mingw32

    I fixed!

    I had to put Q_DECL_EXPORT and Q_DECL_IMPORT in the library + DEFINES in the pro.

    http://qt-project.org/doc/qt-4.8/sharedlibrary.html

    Thanks.

Similar Threads

  1. undefined reference for qt creator in windows
    By morteza in forum Qt Programming
    Replies: 1
    Last Post: 13th October 2011, 19:19
  2. Undefined reference
    By eekhoorn12 in forum Qt Programming
    Replies: 2
    Last Post: 6th January 2011, 15:45
  3. undefined reference
    By digidas in forum Newbie
    Replies: 9
    Last Post: 19th May 2010, 13:04
  4. Undefined reference to crt
    By derektaprell in forum Installation and Deployment
    Replies: 0
    Last Post: 20th October 2009, 08:34
  5. Undefined reference
    By Salazaar in forum Newbie
    Replies: 12
    Last Post: 23rd May 2007, 10:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.