[SOLVED] C++ unresolved external

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
Taygete
Full Member
Posts: 50
Joined: Wed May 14, 2014 8:53 am

[SOLVED] C++ unresolved external

Post by Taygete » Sun Jan 25, 2015 5:58 pm

Hi Andrew,

I have had an issue for a while now whenever I try to use setProperty within C++ code, I've previously managed to work around it but I wanted to flag it up with you to see if you have a solution.

If I use the following code as an example

Code: Select all

QSharedPointer<REntity> entity = docInterface->getDocument().queryEntity(id);
if (entity.isNull()) {
    continue;
}

entity->setProperty(REntity::PropertyLayer, "layer-name");
If I then compile it I end up with an LNK2019.

Code: Select all

CreateModulesInRunForm.obj:-1: error: LNK2019: unresolved external symbol "public: static class RPropertyTypeId REntity::PropertyLayer" (?PropertyLayer@REntity@@2VRPropertyTypeId@@A)
I have double checked I am including all libraries and also had a couple of other devs look over it and the setProperty method always gives a linker error because of the RPropertyTypeId REntity::PropertyLayer class. It has done this since I started developing in QCAD (around 3.5.0 I think). setProperty works fine in a script by the way but I need to be able to do this in C++ as well.

Any ideas what might be causing this?

Thanks,

Andrew.
Last edited by Taygete on Tue Jan 27, 2015 9:27 am, edited 2 times in total.

User avatar
andrew
Site Admin
Posts: 9059
Joined: Fri Mar 30, 2007 6:07 am

Re: C++ unresolved external

Post by andrew » Mon Jan 26, 2015 9:50 am

Please indicate what platform and platform version you are on (Windows, Linux, Mac OS X) and what compiler and compiler version you are using (gcc, clang, mingw, msvc, etc). Thanks.

Taygete
Full Member
Posts: 50
Joined: Wed May 14, 2014 8:53 am

Re: C++ unresolved external

Post by Taygete » Mon Jan 26, 2015 11:15 am

andrew wrote:Please indicate what platform and platform version you are on (Windows, Linux, Mac OS X) and what compiler and compiler version you are using (gcc, clang, mingw, msvc, etc). Thanks.
Sorry Andrew, forgot that info.

I am building on Windows 7 x64, VS2010.
Qt Version: 4.7.4
Compiler: MSVC++ 10.0 (2010)

Thanks,

Andrew.

User avatar
andrew
Site Admin
Posts: 9059
Joined: Fri Mar 30, 2007 6:07 am

Re: C++ unresolved external

Post by andrew » Mon Jan 26, 2015 11:24 am

OK, thanks. Did you compile the QCAD sources yourself or are you using the DLLs from one of our downloadable packages?

Taygete
Full Member
Posts: 50
Joined: Wed May 14, 2014 8:53 am

Re: C++ unresolved external

Post by Taygete » Mon Jan 26, 2015 11:30 am

andrew wrote:OK, thanks. Did you compile the QCAD sources yourself or are you using the DLLs from one of our downloadable packages?
I have built them myself, however this is the only issue (and has always been an issue since I started working with QCAD) I have with regards link errors.

I am currently building against 3.6.3 sources, I wanted to get the current dev cycle finished before updating to the latest version of QCAD.

Thanks,

Andrew.

User avatar
andrew
Site Admin
Posts: 9059
Joined: Fri Mar 30, 2007 6:07 am

Re: C++ unresolved external

Post by andrew » Mon Jan 26, 2015 11:42 am

Strange. It sure looks like the qcadcore is not loaded or that the symbols are not being exported. Are you using the default .pro files provided with the QCAD sources or your own setup? Are you linking against the QCAD DLLs or static libraries?

Taygete
Full Member
Posts: 50
Joined: Wed May 14, 2014 8:53 am

Re: C++ unresolved external

Post by Taygete » Mon Jan 26, 2015 12:24 pm

andrew wrote:Strange. It sure looks like the qcadcore is not loaded or that the symbols are not being exported. Are you using the default .pro files provided with the QCAD sources or your own setup? Are you linking against the QCAD DLLs or static libraries?
Hi Andrew,

I am using the default .pro files as provided with the QCAD sources.

I just double checked because it is a while since I created our projects .pro file but we are definitely dynamically linking against the dlls.

Thanks,

Andrew.

User avatar
andrew
Site Admin
Posts: 9059
Joined: Fri Mar 30, 2007 6:07 am

Re: C++ unresolved external

Post by andrew » Mon Jan 26, 2015 1:23 pm

OK, thanks.
Are you compiling / linking a plugin, an additional library or an application?
Are you including qcad/shared.pri in your .pro?

Taygete
Full Member
Posts: 50
Joined: Wed May 14, 2014 8:53 am

Re: C++ unresolved external

Post by Taygete » Mon Jan 26, 2015 3:24 pm

andrew wrote:OK, thanks.
Are you compiling / linking a plugin, an additional library or an application?
Are you including qcad/shared.pri in your .pro?
Hi Andrew,

I am building a qt plugin which runs within the QCAD application.

I am not including the qcad/shared.pri in our .pro file, I didn't realise I needed too, I will have a look now.

Thanks,

Andrew.

User avatar
andrew
Site Admin
Posts: 9059
Joined: Fri Mar 30, 2007 6:07 am

Re: C++ unresolved external

Post by andrew » Mon Jan 26, 2015 3:38 pm

Taygete wrote:I am not including the qcad/shared.pri in our .pro file, I didn't realise I needed too, I will have a look now.
It's not strictly required but should make things easier. Otherwise, you will have to add some defines to your pro file, most notably:
DEFINES += QCAD_DLL
This ensures that classes, member functions, static members, etc are imported correctly under MSVC (Q_DECL_IMPORT, Q_DECL_EXPORT)

Taygete
Full Member
Posts: 50
Joined: Wed May 14, 2014 8:53 am

Re: C++ unresolved external

Post by Taygete » Mon Jan 26, 2015 5:50 pm

Hi Andrew,

Including the qcad/shared.pri into my .pro file has solved the link error so thanks for that, I am however not seeing what I thought would happen with setProperty method call so I will create a new thread regarding that issue.

For anyone interested with regards the solution:
Include the qcad/shared.pri to your .pro

Code: Select all

include ($$PWD/../../qcad-3.6.3/shared.pri)
Change the path appropriately.

Thanks,

Andrew.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”