Page 1 of 1

Linker error

Posted: Sun Nov 01, 2009 8:07 pm
by akaz
I'm Adam and that is my fist post here.
Hello :)

I tried compile very easy program that doing nothing to test compiler:

Code: Select all

#include "irrlicht.h"

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;


int main()
{
   createDevice( video::EDT_OPENGL, dimension2d<u32>(640, 480), 16, false, false, false, 0);
   return 0;
}
I got tons of errors from linker:

Code: Select all

g++    -c -g -I/home/adam/Libraries/irrlicht-1.6/include -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.cpp
mkdir -p dist/Debug/GNU-Linux-x86
g++     -o dist/Debug/GNU-Linux-x86/irrlicht_nauka build/Debug/GNU-Linux-x86/main.o -L/home/adam/Libraries/irrlicht-1.6/lib/Linux /home/adam/Libraries/irrlicht-1.6/lib/Linux/libIrrlicht.a 
/home/adam/Libraries/irrlicht-1.6/lib/Linux/libIrrlicht.a(CIrrDeviceLinux.o): In function `irr::CIrrDeviceLinux::initXAtoms()':
/home/adam/Desktop/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:1787: undefined reference to `XInternAtom'
/home/adam/Desktop/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:1788: undefined reference to `XInternAtom'
/home/adam/Desktop/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:1789: undefined reference to `XInternAtom'
/home/adam/Desktop/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:1790: undefined reference to `XInternAtom'
/home/adam/Libraries/irrlicht-1.6/lib/Linux/libIrrlicht.a(CIrrDeviceLinux.o): In function `irr::CIrrDeviceLinux::copyToClipboard(char const*) const':

(...)
I don't know what is wrong.
I tried using 1.5.1 and 1.6 version of Irrlicht, still same errors.

Re: Linker error

Posted: Sun Nov 01, 2009 8:24 pm
by randomMesh
akaz wrote:undefined reference to `XInternAtom'
XInternAtom belongs to Xlib, so just install its dev package.

Further reading:
http://www.irrlicht3d.org/wiki/index.php?n=Main.CompilingOnLinux

Posted: Sun Nov 01, 2009 8:32 pm
by akaz
Thanks for fast reply, randomMesh.

I've got installed both glutg3-dev and libxxf86vm-dev,
but I still receiving same error.
The question is, why demos are compiling ok and my program not?

EDIT:
I added some additional commands to linker:
"-L/usr/X11R6/lib$(LIBSELECT) -L../../lib/Linux -lIrrlicht -lGL -lGLU -lXrandr -lXext -lX11"

Not i got only these errors:

Code: Select all

g++     -L/usr/X11R6/lib -L../../lib/Linux -lIrrlicht -lGL -lGLU -lXrandr -lXext -lX11 -o dist/Debug/GNU-Linux-x86/irrlicht_nauka build/Debug/GNU-Linux-x86/main.o -L/home/adam/Libraries/irrlicht-1.6/lib/Linux /home/adam/Libraries/irrlicht-1.6/lib/Linux/libIrrlicht.a 
/home/adam/Libraries/irrlicht-1.6/lib/Linux/libIrrlicht.a(CIrrDeviceLinux.o): In function `irr::CIrrDeviceLinux::getGammaRamp(float&, float&, float&, float&, float&)':
/home/adam/Libraries/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:1683: undefined reference to `XF86VidModeQueryExtension'
/home/adam/Libraries/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:1686: undefined reference to `XF86VidModeGetGamma'
/home/adam/Libraries/irrlicht-1.6/lib/Linux/libIrrlicht.a(CIrrDeviceLinux.o): In function `irr::CIrrDeviceLinux::setGammaRamp(float, float, float, float, float)':
/home/adam/Libraries/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:1636: undefined reference to `XF86VidModeQueryExtension'
/home/adam/Libraries/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:1642: undefined reference to `XF86VidModeSetGamma'
/home/adam/Libraries/irrlicht-1.6/lib/Linux/libIrrlicht.a(CIrrDeviceLinux.o): In function `irr::CIrrDeviceLinux::getVideoModeList()':
/home/adam/Libraries/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:1235: undefined reference to `XF86VidModeQueryExtension'
/home/adam/Libraries/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:1241: undefined reference to `XF86VidModeGetAllModeLines'
/home/adam/Libraries/irrlicht-1.6/lib/Linux/libIrrlicht.a(CIrrDeviceLinux.o): In function `irr::CIrrDeviceLinux::createWindow()':
/home/adam/Libraries/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:237: undefined reference to `XF86VidModeQueryExtension'
/home/adam/Libraries/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:243: undefined reference to `XF86VidModeGetAllModeLines'
/home/adam/Libraries/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:260: undefined reference to `XF86VidModeSwitchToMode'
/home/adam/Libraries/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:261: undefined reference to `XF86VidModeSetViewPort'
/home/adam/Libraries/irrlicht-1.6/lib/Linux/libIrrlicht.a(CIrrDeviceLinux.o): In function `~CIrrDeviceLinux':
/home/adam/Libraries/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:150: undefined reference to `XF86VidModeSwitchToMode'
/home/adam/Libraries/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:151: undefined reference to `XF86VidModeSetViewPort'
/home/adam/Libraries/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:150: undefined reference to `XF86VidModeSwitchToMode'
/home/adam/Libraries/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:151: undefined reference to `XF86VidModeSetViewPort'
/home/adam/Libraries/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:150: undefined reference to `XF86VidModeSwitchToMode'
/home/adam/Libraries/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp:151: undefined reference to `XF86VidModeSetViewPort'
collect2: ld returned 1 exit status

Posted: Sun Nov 01, 2009 8:36 pm
by randomMesh
akaz wrote:The question is, why demos are compiling ok and my program not?
Ah, so you've got all neccessary libraries installed but forgot to tell your IDE.

Just add the following libs to your linker settings:

Irrlicht
GL
Xxf86vm

Posted: Sun Nov 01, 2009 8:40 pm
by akaz
Thank you, randomMesh!
I added -lXxf86vm to linker and now compilling secesfully.

Thank you again!

Posted: Sun Nov 01, 2009 10:36 pm
by hybrid
Who wrote this miserable Makefile without taking a look into the official Irrlicht Makefiles?

Posted: Sun Nov 08, 2009 2:33 pm
by akaz
This Makefile was generated by my IDE (NetBeans), i am so lazy