PDA

View Full Version : Help with undefined reference in Windows with mingw32



qlands
21st March 2012, 09:33
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 += core gui sql
CONFIG += designer plugin debug_and_release
TARGET = $$qtLibraryTarget(impwidgetsplugin)
TEMPLATE = lib
....


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 += core gui sql svg

TARGET = $$qtLibraryTarget(impmainmodules)
TEMPLATE = lib
CONFIG += plugin

win32:LIBS += c:\ilri\crossimpact\libimpwidgetsplugin.a
....


The problem is that I always get:


./debug\plots.o:C:\ilri\crossimpact\plugins\syschar\ impmainmodules/modules/plots.cpp:203: undefined reference to `impgenmaint::insertKeyField(QString, QVariant, bool)'

Here, impgenmaint::insertKeyField(QString, QVariant, bool) is defined in the designer plugin impwidgetsplugin.dll

I can see that mingw32 is apparently using the library:


mingw32-make[1]: Entering directory `C:/ilri/crossimpact/plugins/syschar/impmainmodules'
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


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

Many thanks for any help.
Carlos.

Spitfire
21st March 2012, 13:35
Try
win32:LIBS += -Lc:/ilri/crossimpact -limpwidgetsplugin

qlands
22nd March 2012, 06:28
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:


./release\plots.o:plots.cpp:(.text+0x13f5): undefined reference to `calcDialog::calcDialog(QWidget*)'


Indeed the code in plots.cpp uses calcDialog like:


#include <calcdialog.h>
....
calcDialog calc;
calc.setDatabase(dataBase);
calc.setCurrentDisplay(index.data().toFloat());
calc.exec();
....


In the PRO I have the include path of calculator:


INCLUDEPATH += ../../../plugins/interfaces ../../designer/impwidgets ../../designer/impwidgets/widgets/calculator


So, I really don't know what is wrong because in Linux it works ok with:


unix:LIBS += -L/home/cquiros/data/projects/tools/crossimpact -limpwidgetsplugin

Many thanks,
Carlos.

Spitfire
22nd March 2012, 16:48
Post content of both pro files, maybe there's a problem you're missing.

qlands
23rd March 2012, 11:41
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.