Unresolved symbols when linking VC2010 app with QxOrm 1.2.5

Forum for posting problems using QxOrm library

Unresolved symbols when linking VC2010 app with QxOrm 1.2.5

Postby alqfr » Wed Apr 10, 2013 4:20 pm

I think I have successfully made a dynamic build of QxOrm 1.2.5 (and 1.2.5_BETA_04) using VC2010, Boost 1.50, and the VC2010 build of Qt 4.8.4 on Windows 7, after configuring Qt 4.8.4 and modifying the boost paths in QxOrm.pri. When I tried to use this QxOrm VC2010 build to build a couple of my applications which have been built and worked fine on Linux (RHEL6) with QxOrm since 1.2.4, I got the following linker errors (linker command included):

"/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin"/link.exe /incremental:no /machine:X86 /nologo /debug /FIXED:NO /nodefaultlib:LIBCMT.lib /subsystem:console /OUT:F:/afung/dev/qfr/trunk/builds/dal/unittest/win32_vc100_debug/driver.t.exe F:/afung/dev/qfr/trunk/builds/dal/unittest/objs_win32_vc100_debug/driver.t.obj \
/LIBPATH:F:/afung/dev/qfr/trunk/builds/dal/win32_vc100_debug/ dal.lib \
/LIBPATH:F:/afung/dev/qfr/trunk/builds/dbc/win32_vc100_debug/ dbc.lib \
/LIBPATH:F:/afung/dev/qfr/trunk/builds/core/win32_vc100_debug/ core.lib \
/LIBPATH:F:/afung/dev/qfr/trunk/3rdParty/win32/boost/1.50/libs/ libboost_filesystem-vc100-mt-s-1_50.lib libboost_system-vc100-mt-s-1_50.lib libboost_thread-vc100-mt-s-1_50.lib libboost_serialization-vc100-mt-s-1_50.lib libboost_date_time-vc100-mt-s-1_50.lib libboost_chrono-vc100-mt-s-1_50.lib \
/LIBPATH:F:/afung/dev/qfr/trunk/3rdParty/win32/qpid/0.18/libs/ qpidclient.lib qpidcommon.lib qpidtypes.lib qpidmessaging.lib \
/LIBPATH:F:/afung/dev/qfr/trunk/3rdParty/win32/qxorm/1.2.5/libs/ QxOrm.lib \
/LIBPATH:C:/Qt/4.8.4/lib/ QtGui4.lib QtNetwork4.lib QtSql4.lib QtXml4.lib QtCore4.lib \
kernel32.lib wsock32.lib netapi32.lib advapi32.lib oldnames.lib comdlg32.lib comctl32.lib user32.lib

driver.t.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const qx::dao::detail::QxDaoAsyncRunner::staticMetaObject" (?staticMetaObject@QxDaoAsyncRunner@detail@dao@qx@@2UQMetaObject@@B)
dal.lib(DBFactory.obj) : error LNK2001: unresolved external symbol "public: static struct QMetaObject const qx::dao::detail::QxDaoAsyncRunner::staticMetaObject" (?staticMetaObject@QxDaoAsyncRunner@detail@dao@qx@@2UQMetaObject@@B)
driver.t.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const qx::QxDaoAsync::staticMetaObject" (?staticMetaObject@QxDaoAsync@qx@@2UQMetaObject@@B)
dal.lib(DBFactory.obj) : error LNK2001: unresolved external symbol "public: static struct QMetaObject const qx::QxDaoAsync::staticMetaObject" (?staticMetaObject@QxDaoAsync@qx@@2UQMetaObject@@B)
driver.t.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const qx::service::QxThread::staticMetaObject" (?staticMetaObject@QxThread@service@qx@@2UQMetaObject@@B)
dal.lib(DBFactory.obj) : error LNK2001: unresolved external symbol "public: static struct QMetaObject const qx::service::QxThread::staticMetaObject" (?staticMetaObject@QxThread@service@qx@@2UQMetaObject@@B)
driver.t.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const qx::service::QxThreadPool::staticMetaObject" (?staticMetaObject@QxThreadPool@service@qx@@2UQMetaObject@@B)
dal.lib(DBFactory.obj) : error LNK2001: unresolved external symbol "public: static struct QMetaObject const qx::service::QxThreadPool::staticMetaObject" (?staticMetaObject@QxThreadPool@service@qx@@2UQMetaObject@@B)
driver.t.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class qx::QxDataMemberX<class JpmCds> * __thiscall qx::QxClass<class JpmCds>::dataMemberX(void)const " (__imp_?dataMemberX@?$QxClass@VJpmCds@@@qx@@QBEPAV?$QxDataMemberX@VJpmCds@@@2@XZ) referenced in function "public: virtual void __thiscall qx::QxSqlQueryBuilder<class boost::shared_ptr<class JpmCds> >::init(void)" (?init@?$QxSqlQueryBuilder@V?$shared_ptr@VJpmCds@@@boost@@@qx@@UAEXXZ)
driver.t.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class qx::QxClass<class JpmCds> * __cdecl qx::QxSingleton<class qx::QxClass<class JpmCds> >::getSingleton(void)" (__imp_?getSingleton@?$QxSingleton@V?$QxClass@VJpmCds@@@qx@@@qx@@SAPAV?$QxClass@VJpmCds@@@2@XZ) referenced in function "public: virtual void __thiscall qx::QxSqlQueryBuilder<class boost::shared_ptr<class JpmCds> >::init(void)" (?init@?$QxSqlQueryBuilder@V?$shared_ptr@VJpmCds@@@boost@@@qx@@UAEXXZ)
driver.t.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class qx::QxDataMemberX<class AirBb> * __thiscall qx::QxClass<class AirBb>::dataMemberX(void)const " (__imp_?dataMemberX@?$QxClass@VAirBb@@@qx@@QBEPAV?$QxDataMemberX@VAirBb@@@2@XZ) referenced in function "public: virtual void __thiscall qx::QxSqlQueryBuilder<class boost::shared_ptr<class AirBb> >::init(void)" (?init@?$QxSqlQueryBuilder@V?$shared_ptr@VAirBb@@@boost@@@qx@@UAEXXZ)
driver.t.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class qx::QxClass<class AirBb> * __cdecl qx::QxSingleton<class qx::QxClass<class AirBb> >::getSingleton(void)" (__imp_?getSingleton@?$QxSingleton@V?$QxClass@VAirBb@@@qx@@@qx@@SAPAV?$QxClass@VAirBb@@@2@XZ) referenced in function "public: virtual void __thiscall qx::QxSqlQueryBuilder<class boost::shared_ptr<class AirBb> >::init(void)" (?init@?$QxSqlQueryBuilder@V?$shared_ptr@VAirBb@@@boost@@@qx@@UAEXXZ)
F:/afung/dev/qfr/trunk/builds/dal/unittest/win32_vc100_debug/driver.t.exe : fatal error LNK1120: 8 unresolved externals

So, there are 2 categories of errors, the first group concerning the unresolved staticMetaObject methods, e.g., from QxDaoSync, QxThread, QxThreadPool, etc., and the second arising from the Qx-related template classes that my user code created. I may have some clue how to resolve the second class of errors (by omitting the __declspec(dllimport) prefix in the static build), but I don't know about the unresolved staticMetaObject symbols. Any clues to either problem are much appreciated. Thanks.
alqfr
 
Posts: 17
Joined: Thu Jul 19, 2012 3:47 pm

Re: Unresolved symbols when linking VC2010 app with QxOrm 1.

Postby alqfr » Wed Apr 10, 2013 6:35 pm

To help you diagnose at least the second linker error, I am attaching a smaller but similar project. You will have to edit the boost path in the Makefile and include VC10/bin in your path. Then, you should be able to just type make (on Cygwin) to build this project on Windows.

I have also attached the logged output of my terminal when I ran make.
Attachments
make-log.zip
logged output of my terminal after running make
(2.09 KiB) Downloaded 600 times
FirstTest.zip
Project
(28.23 KiB) Downloaded 680 times
alqfr
 
Posts: 17
Joined: Thu Jul 19, 2012 3:47 pm

Re: Unresolved symbols when linking VC2010 app with QxOrm 1.

Postby qxorm » Thu Apr 11, 2013 7:40 am

Sorry but I don't have any problem to build QxOrm library and all samples (in ./test/ directory) using MSVC2010 !
So you have something wrong in your dev environment. Have you tried all samples in ./test/ directory ?

Here are some basics steps to follow to install correctly your dev environment.
Just verify all those steps for your case :
1- Download and install Qt 4.8 (or Qt5) for MSVC2010 ;
2- Add Qt 'bin' directory to the PATH of Windows ;
3- Download my boost 1.51 package and unzip it : http://www.qxorm.com/lib/boost_1_51.zip ;
4- Add 'lib_shared' directory from my boost package to the PATH of Windows ;
5- Download QxOrm package and unzip it ;
6- Open 'QxOrm.pri' file and modify boost parameters (QX_BOOST_INCLUDE_PATH, QX_BOOST_LIB_PATH, etc.) ;
7- Open './test/qxBlog/qxBlog.sln' for example with MSVC2010, then try to build it and execute it ;
8- Test all examples from './test/' directory of QxOrm package.


Note about your code : to export your TestTable class, you use the macro QX_DLL_EXPORT.
It is not correct, you have to define your own macro.
Please read the tutorial qxBlog to understand : http://www.qxorm.com/qxorm_en/tutorial.html (there is a part about export.h file).
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am

Re: Unresolved symbols when linking VC2010 app with QxOrm 1.

Postby alqfr » Fri Apr 12, 2013 3:06 pm

Thanks for your help. As I mentioned, I saw 2 different groups of errors. I could resolve the second group of errors caused by inconsistent use of __declspec(dllimport) by defining my own QX_TEST_DLL_EXPORT in export.h. The key was to add it as a -D option in my compiler command.

The first group of errors remains however. I was able to build qxBlog using the dynamic version of the QxOrm library I built with VC2010 and Qt 4.8.4. Then, I copied the compiler and linker commands to my Makefile (included in the package), but I am still observing these linker errors, each having to do with an unresolved external symbol bearing the name of staticMetaObject.

I have included both the zipped package and the make log for your review. I have spent quite some time on this. Any help will be much appreciated. You can see how my build process goes by looking at the Makefile. (I am just using Cygwin's make, not nmake, but it shouldn't make a difference.)

link /NOLOGO /DYNAMICBASE /NXCOMPAT /SUBSYSTEM:WINDOWS /DEBUG /MANIFEST /MANIFESTFILE:"../../debug/QxOrmd.intermediate.manifest" /NODEFAULTLIB:MSVCRT.LIB orm.obj TestTable.obj /OUT:orm.exe /LIBPATH:"c:\Qt\4.8.4\lib" c:/Qt/4.8.4/lib/qtmain.lib /LIBPATH:../../lib QxOrm.lib /LIBPATH:../../../../../../qfr/trunk/3rdParty/win32/boost/1.50/libs boost_serialization-vc100-mt-gd-1_50.lib c:/Qt/4.8.4/lib/QtSqld4.lib c:/Qt/4.8.4/lib/QtXmld4.lib c:/Qt/4.8.4/lib/QtGuid4.lib c:/Qt/4.8.4/lib/QtNetworkd4.lib c:/Qt/4.8.4/lib/QtCored4.lib
Creating library orm.lib and object orm.exp
orm.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const qx::dao::detail::QxDaoAsyncRunner::staticMetaObject" (?staticMetaObject@QxDaoAsyncRunner@detail@dao@qx@@2UQMetaObject@@B)
TestTable.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const qx::dao::detail::QxDaoAsyncRunner::staticMetaObject" (?staticMetaObject@QxDaoAsyncRunner@detail@dao@qx@@2UQMetaObject@@B)
orm.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const qx::QxDaoAsync::staticMetaObject" (?staticMetaObject@QxDaoAsync@qx@@2UQMetaObject@@B)
TestTable.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const qx::QxDaoAsync::staticMetaObject" (?staticMetaObject@QxDaoAsync@qx@@2UQMetaObject@@B)
orm.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const qx::service::QxThread::staticMetaObject" (?staticMetaObject@QxThread@service@qx@@2UQMetaObject@@B)
TestTable.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const qx::service::QxThread::staticMetaObject" (?staticMetaObject@QxThread@service@qx@@2UQMetaObject@@B)
orm.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const qx::service::QxThreadPool::staticMetaObject" (?staticMetaObject@QxThreadPool@service@qx@@2UQMetaObject@@B)
TestTable.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const qx::service::QxThreadPool::staticMetaObject" (?staticMetaObject@QxThreadPool@service@qx@@2UQMetaObject@@B)
orm.exe : fatal error LNK1120: 4 unresolved externals
Attachments
make-log.txt.zip
(1.14 KiB) Downloaded 582 times
FirstTest.zip
(5.52 KiB) Downloaded 631 times
alqfr
 
Posts: 17
Joined: Thu Jul 19, 2012 3:47 pm

Re: Unresolved symbols when linking VC2010 app with QxOrm 1.

Postby alqfr » Fri Apr 12, 2013 3:21 pm

Just in case I built QxOrm in a wrong manner, I am also attaching my QxOrm.pri, which is used by qmake to build the Makefiles.
Attachments
QxOrm.pri.zip
(2.13 KiB) Downloaded 606 times
alqfr
 
Posts: 17
Joined: Thu Jul 19, 2012 3:47 pm

Re: Unresolved symbols when linking VC2010 app with QxOrm 1.

Postby qxorm » Fri Apr 12, 2013 3:29 pm

Sorry, but I have no time to debug your MakeFile !
The problem is not with QxOrm library (since you are able to build correctly qxBlog project), but with your MakeFile.
Why do you not want to use qmake to build the MakeFile ?
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am

Re: Unresolved symbols when linking VC2010 app with QxOrm 1.

Postby alqfr » Fri Apr 12, 2013 3:36 pm

I have my own build system, and your QxOrm is but one of the third-party software in it. I used qmake to build QxOrm though.

For what it is worth, my last experiment is to place my Makefile in qxBlog as Makefile.vc10, adapt it to qxBlog, and run
make -f Makefile.vc10. I know that qxBlog builds under nmake (from inside VC solution), but now using my Makefile.vc10, it reproduces the same sort of linker errors as my own test example. You can see it for yourself, but like you, I have come to the conclusion that my makefile is the problem. Maybe, it has something to do with the manifest file or precompiled header. Do I really need the manifest file to get my app to work?
Attachments
make.log.zip
(1.48 KiB) Downloaded 631 times
Makefile.vc10.zip
(1.19 KiB) Downloaded 632 times
alqfr
 
Posts: 17
Joined: Thu Jul 19, 2012 3:47 pm

Re: Unresolved symbols when linking VC2010 app with QxOrm 1.

Postby qxorm » Fri Apr 12, 2013 3:39 pm

Do I really need the manifest file to get my app to work ?

Sorry I don't know, qmake manages it automatically !
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am

Re: Unresolved symbols when linking VC2010 app with QxOrm 1.

Postby alqfr » Fri Apr 12, 2013 5:51 pm

I found the problem. I was missing the precompiled object file when I linked, namely qxBlogd_pch.obj. The attached Makefile.vc10 would work for qxBlog. I also used the same technique to get my orm project to build. Thanks for taking a look at this.

qxBlogd_pch.obj:
cl -c -Yc -Fpdebug/qxBlogd_pch.pch -Fodebug/qxBlogd_pch.obj $(CXXFLAGS) \
$(INCPATH) -TP include/precompiled.h include/precompiled.h

%.obj: src/%.cpp
cl -c -FIprecompiled.h -Yuprecompiled.h -Fpdebug/qxBlogd_pch.pch $(CXXFLAGS) \
$(INCPATH) -Fodebug/ $<

debug/%.obj: %.obj ;

qxBlog.exe: $(ORM_OBJECTS:%=debug/%)
link $(LFLAGS) $(LIBS) /OUT:debug/qxBlogd.exe $^
Attachments
Makefile.vc10.zip
(1.38 KiB) Downloaded 644 times
alqfr
 
Posts: 17
Joined: Thu Jul 19, 2012 3:47 pm

Re: Unresolved symbols when linking VC2010 app with QxOrm 1.

Postby qxorm » Sun Apr 14, 2013 8:06 pm

I found the problem. I was missing the precompiled object file...

Great !
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 9 guests

cron