Linker error

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
akaz
Posts: 9
Joined: Sun Nov 01, 2009 7:52 pm

Linker error

Post 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.
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Re: Linker error

Post 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
"Whoops..."
akaz
Posts: 9
Joined: Sun Nov 01, 2009 7:52 pm

Post 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
Last edited by akaz on Sun Nov 01, 2009 8:38 pm, edited 1 time in total.
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Post 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
"Whoops..."
akaz
Posts: 9
Joined: Sun Nov 01, 2009 7:52 pm

Post by akaz »

Thank you, randomMesh!
I added -lXxf86vm to linker and now compilling secesfully.

Thank you again!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Who wrote this miserable Makefile without taking a look into the official Irrlicht Makefiles?
akaz
Posts: 9
Joined: Sun Nov 01, 2009 7:52 pm

Post by akaz »

This Makefile was generated by my IDE (NetBeans), i am so lazy
Post Reply