Unsolved OSG integration with QT...Trouble linking libraries.
-
I have had trouble linking OSG to QT. I am trying to use .pro file over CMakelists.
I have tried the -L<path> -l<library> to import all the OSG libraries.
At first i receive multiple LNK2001 errors , which were resolved by building OSG in QT.
This resolved most of the LNK2001 erros.
Now I still receive plenty of LNK2019 errors similar to below. I understand it is a linking problem but I can wrap my head around what I am missing. I have made sure Im using the correct release/debug libraries.myFiles.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: static class osg::Matrixd __cdecl osg::Matrixd::rotate(double,class osg::Vec3f const &,double,class osg::Vec3f const &,double,class osg::Vec3f const &)" (_imp?rotate@Matrixd@osg@@SA?AV12@NAEBVVec3f@2@N0N0@Z) referenced in function "public: virtual void __cdecl myFiles::saveAs(void)" (?saveAs@myFiles@@UEAAXXZ)
-
Hi and welcome to devnet,
Then are you sure that you are linking to all the required libraries from OSG ?
-
@SGaist yes.
Yes. I link ALL of the libraries. I left out the wrappers and plugins but those dont seem related.LIBS += -Lpath/to/osg-3.5.1-qtcreator/lib -lot20-OpenThreads
-losg141-osgAnimation
-losg141-osgDB
-losg141-osgFX
-losg141-osgGA
-losg141-osgManipulator
-losg141-osgParticle
-losg141-osgPresentation
-losg141-osgQt
-losg141-osgShadow
-losg141-osgSim
-losg141-osgTerrain
-losg141-osgText
-losg141-osgUI
-losg141-osgUtil
-losg141-osgViewer
-losg141-osgVolume
-losg141-osg -
Ok, then check the corresponding header file to see if that symbol is properly exported.
-
@SGaist Can you explain what you mean more?
I checked all the include headers and for example Matrixd is present in the include folder and should be part of the osg141-osg.lib -
With Visual Studio, if you have a shared library and you want to be able to use a class/method from another application/library, you have to export it properly.
You can see more details about that here.
-
@SGaist it was to my understanding I was building OSG as a static lib.
I am able to build and execute the application using CMakelists, but I'm trying to convert it to a .pro file for experimental reason. -
Ok, then are you linking them in the correct order ?
-
This post is deleted! -
@SGaist I would like to think so. I was linking them the way i commented above but that was wrong so i went and changed it. But no results. same errors
LIBS += -L"C:/Packages/VC14/osg-3.5.1-qtcreator/lib" -losg141-osg
-lot20-OpenThreads
-losg141-osgAnimation
-losg141-osgDB
-losg141-osgFX
-losg141-osgGA
-losg141-osgManipulator
-losg141-osgParticle
-losg141-osgPresentation
-losg141-osgQt
-losg141-osgShadow
-losg141-osgSim
-losg141-osgTerrain
-losg141-osgText
-losg141-osgUI
-losg141-osgUtil
-losg141-osgViewer
-losg141-osgVolume
-losg141-osgWidget -
And the exact same application builds properly with cmake ?
-
@SGaist
Yes. With CMake I can run it just fine.
Could it be because I have not linked the plugins? -
Which plugins are you referring to ?
-
First is the page of lib folder
2nd is the plugins.Fixing the order of the libraries got rid of the remaining LNK2001 errors i had.
Now all I have left is 7 LNK2019 errors similar to the original post -
@SGaist i thought i attached the images but i hadnt seen they arent visible. I will link them first hting in the morning. I appreciate the input greatly.
Thank you -
The upload feature is currently broken so you have to use an image sharing site in between.
-
@SGaist [url=https://postimg.org/image/a2npfn1en/][img]https://s3.postimg.org/a2npfn1en/osglib.png[/img][/url]
[url=https://postimg.org/image/w341w9k2n/][img]https://s3.postimg.org/w341w9k2n/plugins.png[/img][/url]
[url=https://postimage.org/]image hosting over 5mb[/url]
there are more plugins but the ones I use are
osgdb_osg
osgdb_serializers_osg
osgdb_ply
osgdb_3ds
osgdb_stl
osgdb_obj)
osgdb_bmp
osgdb_bvh
osgdb_cfg
osgdb_dxf
osgdb_glsl
osgdb_tga
osgdb_png
osgdb_jpeg
osgdb_tiff
osgdb_gif
osgdb_freetype -
-
Can you compare the link line you have between your cmake project and your qmake project ?
-
@SGaist I went an added all the plugins in the order the CMakelist does it and it didnt fix any errors. The problems seem. THe remaining errors have to do with
osg::Matrixd
osg::MatrixfosgVolume::Volume
osgVolume::Layer
osg::Group
osg::BoundingSphereImplI was able to eliminate another error by simply linking the libraries before certain statements in the .pro file but im still at 6 errors
I had 2 additional errors previously at
osg::Sphere
osg::Vec3f
but I was able to get this remove by simply moving my LIBS statement higher up in the .pro.
What i dont understand is that even though im using a .pri file and including in every subproject, unless i directly add the libraries to the .pro file more errors persist