Undefined reference when using "Hello world" of Irrlicht library

171 Views Asked by At

I'm trying to compile the very first code given by Irrlicht library website.

As said in the title, I get an undefined reference. I'm using 8.2 netbeans IDE.

This is what I've done so far : Installed Irrlicht library from the Linux repository (I'm using Ubuntu 18.04). Using these command lines : sudo apt-get install libirrlicht1.8 libirrlicht1.8-dbg libirrlicht-dev libirrlicht-doc

In the "project properties", I've added the include directory, as well as the include headers (e.g all the files contained in /usr/include/irrlicht. Also, in the "Additional Options" (the linker part, I guess ?) , I've seen online that I should add -lIrrlicht command line, and it still got me the undefined reference.

I've tried also the following command line : -L /usr/include/irrlicht -lIrrlicht, still got me the undefined reference.

I know that the compiler finds the library, as it does not make a compilation error saying that it doesn't know "irrlicht.h", so the problem is coming from the linker. What command line does the linker expects ?

Note : I'm not able to make any update. Talking about irrlicht, it seems that I have 363 packages outdated. Could the problem be from there ?

Edit : Here is the minimum code, as requested. There is no point showing it, as the error comes from the linker command line :

#include <cstdlib>
#include <iostream>
#include <irrlicht.h>

using namespace std;
using namespace irr;
using namespace core;

int main(int argc, char** argv) {

    IrrlichtDevice *device=createDevice(video::EDT_SOFTWARE,dimension2d<u32>(640,480),16,false,false,false,0);
return 0;
}
1

There are 1 best solutions below

1
s.blnc On

I had a similar problem with another library. I fixed it by changing the path in the linker?

according to https://de.wikibooks.org/wiki/Irrlicht_-_from_Noob_to_Pro:_C%2B%2B_f%C3%BCr_Irrlicht_einrichten

you have to link lIrrlicht like:

LIBS += -L/.../Irrlicht/irrlicht-1.7.1/lib/Linux
LIBS += -lIrrlicht 

instead of -L /usr/include/irrlicht -lIrrlicht (for unix).

Did you try that?