Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, April 2008
MingW and Qt4 - problems to link


Message 1 in thread

	Hello all,

	I got a link error today when I tried to compile my Graphical Interface 
with a library. I'll try to describe the scenary:

	I use CMake to control my build process and I'm porting code from Qt3 
to Qt4. So, all code I'm describing is already moved to Qt4.
	My project is divided in:

	1) a base library
	2) an optional XML library, which is an implementation using Qt of SAX.
	3) An GUI based on Qt.

	I compile the base library without no problems.
	I compile the XML library without no problems.
	I compile the Graphical Interface and I'm able to link without any 
problems in my Linux environment.

	When I try to do the same in my Windows environment, I'm not able to 
link the Interface with my XML library. I'm guessing there is something 
wrong with my Windows version of Qt or some missing configuration on my 
CMake script that Linux can overcome.

	These are both of compilation commands:

LINUX:

Linking CXX executable Qt
/usr/local/bin/cmake -P CMakeFiles/Qt.dir/cmake_clean_target.cmake
/usr/bin/c++     -fPIC "CMakeFiles/Qt.dir/QGAbstractLayer.o" 
"CMakeFiles/Qt.dir/QGDocViewer.o" "CMakeFiles/Qt.dir/QGImageLoader.o"
---------------------------
(many object files...)
---------------------------
"CMakeFiles/Qt.dir/QGAppRegister.o" "CMakeFiles/Qt.dir/main.o"   -o Qt 
-rdynamic -L/users/qgar/vasconcv/studies -lQtCore -lpthread -lQtGui
-lQtXml -lqgar_qt4 -lqgxml_qt4 -Wl,-rpath,/users/qgar/vasconcv/studies
[100%] Built target Qt

	Base library is libqgar_qt4.a and the XML library is libqgxml_qt4.a

WINDOWS:

Linking CXX executable Qt.exe

C:\MinGW\bin\g++.exe       "CMakeFiles/Qt.dir/QGAbstractLayer.obj" 
---------------------------
(many object files...)
---------------------------
"CMakeFiles/Qt.dir/QGAppRegister.obj" "CMakeFiles/Qt.dir/m
ain.obj"
-o Qt.exe
-Wl,--major-image-version,0,--minor-image-version,0
-Lc:\Qt\4.3.0\lib
-LZ:\studies
-Wl,-Bstatic -lQtCore4 -lQtGui4 -lQtXml4 -lqgarwin -lqgxmlwin -Wl,-Bdynamic

Z:\studies\libqgxmlwin.a(QtXMLReaderAdaptor.obj)(.text+0x16c):QtXMLReaderAdaptor.cpp: 
undefined reference to `_imp___ZN16QXmlSimpleReaderC1Ev'
Z:\studies\libqgxmlwin.a(QtXMLReaderAdaptor.obj)(.text+0x2b0):QtXMLReaderAdaptor.cpp: 
undefined reference to `_imp___ZN16QXmlSimpleReaderC1Ev'
Z:\studies\libqgxmlwin.a(QtXMLReaderAdaptor.obj)(.text$_ZN5qgxml24QtQgarInputSourceAdaptorC1EPNS_11InputSourceE[qgxml::QtQgarInputSourceAdaptor::QtQgarInputSourceAdaptor(qgxml::Inp
utSource*)]+0xc7):QtXMLReaderAdaptor.cpp: undefined reference to 
`_imp___ZN15QXmlInputSourceC2EP9QIODevice'

	I have not copied all link errors because they make a long list.
	
	The names of libraries changed just because I compiled them 
specifically in the windows. (Base library is libqgarwin.a and the XML 
library is libqgxmlwin.a)


	I'm using MinGW 3.4.2 and Qt 4.30 in my Windows machine.
	I have no clue how I cannot link once in windows.

	If it's not well explained, I can give much more details.
	Thanks a lot in advance,

-- 
 [ signature omitted ] 

Message 2 in thread

> undefined reference to `_imp___ZN16QXmlSimpleReaderC1Ev'

Did you include the Windows __declspec(dll{im,ex}port) stuff into your 
classes?

i.e.:

#ifdef BUILD_MY_LIB
  #define MY_EXPORT __declspec(dllexport)
#else
  #define MY_EXPORT __declspec(dllimport)
#endif

class MY_EXPORT CMyClass
{
public:
   CMyClass();
};


Regards,

Malte


--
 [ signature omitted ]