[Qt-interest] static library issue

Sajjad dosto.walla at gmail.com
Thu Apr 22 14:17:45 CEST 2010


Hello forum,

I have created a static library from from several header files and i am
getting linking error while creating an application
using the library.

The error are as follows:

******************************
main.cpp:(.text+0x238): undefined reference to
`tgt::ToolkitFactory::createApplication(int&, char**)'
main.cpp:(.text+0x27b): undefined reference to
`tgt::ToolkitFactory::createCanvas(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&, tgt::Vector2<int>
const&, tgt::GLCanvas::Buffers)'
main.cpp:(.text+0x33f): undefined reference to
`tgt::Camera::Camera(tgt::Vector3<float> const&, tgt::Vector3<float> const&,
tgt::Vector3<float> const&, float, float, float, float)'
main.cpp:(.text+0x34a): undefined reference to
`tgt::GLCanvas::setCamera(tgt::Camera*)'
main.cpp:(.text+0x35d): undefined reference to
`tgt::Painter::Painter(tgt::GLCanvas*)'
main.cpp:(.text+0x379): undefined reference to
`tgt::GLCanvas::setPainter(tgt::Painter*, bool)'
main.cpp:(.text+0x3af): undefined reference to `tgt::Camera::~Camera()'
main.cpp:(.text+0x460): undefined reference to `tgt::Camera::~Camera()'
Build/release/MyPainter.o: In function `MyPainter::init()':
MyPainter.cpp:(.text+0xae): undefined reference to `glEnable'
MyPainter.cpp:(.text+0xb8): undefined reference to `glShadeModel'
MyPainter.cpp:(.text+0xc2): undefined reference to `glEnable'
MyPainter.cpp:(.text+0xcc): undefined reference to `glEnable'
MyPainter.cpp:(.text+0xe5): undefined reference to
`tgt::Painter::getCamera() const'
Build/release/MyPainter.o: In function `MyPainter::paint()':
MyPainter.cpp:(.text+0x131): undefined reference to `glClear'
MyPainter.cpp:(.text+0x139): undefined reference to
`tgt::Painter::getCamera() const'
MyPainter.cpp:(.text+0x146): undefined reference to
`tgt::Camera::look(tgt::Camera::Eye)'
MyPainter.cpp:(.text+0x159): undefined reference to `glColor3f'
MyPainter.cpp:(.text+0x1c8): undefined reference to
`tgt::Bounds::addPoint(tgt::Vector3<float> const&)'
MyPainter.cpp:(.text+0x205): undefined reference to `gluNewQuadric'
MyPainter.cpp:(.text+0x275): undefined reference to `gluDeleteQuadric'
MyPainter.cpp:(.text+0x28e): undefined reference to `glIsEnabled'
MyPainter.cpp:(.text+0x2b7): undefined reference to `glMaterialfv'
MyPainter.cpp:(.text+0x2c8): undefined reference to `glMaterialfv'
MyPainter.cpp:(.text+0x2d9): undefined reference to `glMaterialfv'
MyPainter.cpp:(.text+0x2eb): undefined reference to `glMaterialf'
MyPainter.cpp:(.text+0x2fc): undefined reference to `glMaterialfv'
MyPainter.cpp:(.text+0x314): undefined reference to `gluSphere'
Build/release/MyPainter.o: In function
`MyPainter::sizeChanged(tgt::Vector2<int> const&)':
MyPainter.cpp:(.text+0x11a): undefined reference to `glViewport'
Build/release/MyPainter.o: In function `tgt::Sphere::~Sphere()':
MyPainter.cpp:(.text._ZN3tgt6SphereD0Ev[tgt::Sphere::~Sphere()]+0x10):
undefined reference to `gluDeleteQuadric'
Build/release/MyPainter.o: In function `tgt::Sphere::~Sphere()':
MyPainter.cpp:(.text._ZN3tgt6SphereD1Ev[tgt::Sphere::~Sphere()]+0x10):
undefined reference to `gluDeleteQuadric'
Build/release/MyPainter.o: In function `tgt::Quadric::~Quadric()':
MyPainter.cpp:(.text._ZN3tgt7QuadricD0Ev[tgt::Quadric::~Quadric()]+0x10):
undefined reference to `gluDeleteQuadric'
Build/release/MyPainter.o: In function `tgt::Quadric::~Quadric()':
MyPainter.cpp:(.text._ZN3tgt7QuadricD1Ev[tgt::Quadric::~Quadric()]+0x10):
undefined reference to `gluDeleteQuadric'
Build/release/MyPainter.o: In function `tgt::Quadric::render()':
MyPainter.cpp:(.text._ZN3tgt7Quadric6renderEv[tgt::Quadric::render()]+0xa):
undefined reference to `glIsEnabled'
MyPainter.cpp:(.text._ZN3tgt7Quadric6renderEv[tgt::Quadric::render()]+0x2e):
undefined reference to `glMaterialfv'
MyPainter.cpp:(.text._ZN3tgt7Quadric6renderEv[tgt::Quadric::render()]+0x3f):
undefined reference to `glMaterialfv'
MyPainter.cpp:(.text._ZN3tgt7Quadric6renderEv[tgt::Quadric::render()]+0x50):
undefined reference to `glMaterialfv'
MyPainter.cpp:(.text._ZN3tgt7Quadric6renderEv[tgt::Quadric::render()]+0x62):
undefined reference to `glMaterialf'
MyPainter.cpp:(.text._ZN3tgt7Quadric6renderEv[tgt::Quadric::render()]+0x74):
undefined reference to `glMaterialfv'
Build/release/MyPainter.o: In function `tgt::Sphere::render()':
MyPainter.cpp:(.text._ZN3tgt6Sphere6renderEv[tgt::Sphere::render()]+0x36):
undefined reference to `glIsEnabled'
MyPainter.cpp:(.text._ZN3tgt6Sphere6renderEv[tgt::Sphere::render()]+0x66):
undefined reference to `glMaterialfv'
MyPainter.cpp:(.text._ZN3tgt6Sphere6renderEv[tgt::Sphere::render()]+0x77):
undefined reference to `glMaterialfv'
MyPainter.cpp:(.text._ZN3tgt6Sphere6renderEv[tgt::Sphere::render()]+0x88):
undefined reference to `glMaterialfv'
MyPainter.cpp:(.text._ZN3tgt6Sphere6renderEv[tgt::Sphere::render()]+0x9a):
undefined reference to `glMaterialf'
MyPainter.cpp:(.text._ZN3tgt6Sphere6renderEv[tgt::Sphere::render()]+0xab):
undefined reference to `glMaterialfv'
MyPainter.cpp:(.text._ZN3tgt6Sphere6renderEv[tgt::Sphere::render()]+0xcd):
undefined reference to `gluSphere'
collect2: ld returned 1 exit status
make: *** [basicExample] Error 1



******************************


I am attaching the .pro files with which i have created the static library
and the application.


The linking error are there because the the linker cannot find the object
files. How to specify the path to  the .o files that have been generated.
the path
has to be specified in the .pro file for the application.

The .pro file for creating the library specifies the path where i put all
the generated .o file.


Looking forward to your kind feedback on that.



Regards
Sajjad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100422/96b567ff/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tgt.pro
Type: application/vnd.nokia.qt.qmakeprofile
Size: 5324 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100422/96b567ff/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: basicExample.pro
Type: application/vnd.nokia.qt.qmakeprofile
Size: 753 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100422/96b567ff/attachment-0001.bin 


More information about the Qt-interest-old mailing list