Undefined Reference to createDevice from example

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
enalios
Posts: 4
Joined: Thu Feb 08, 2007 1:38 am

Undefined Reference to createDevice from example

Post by enalios »

Mkay, so I just started using Irrlicht. I downloaded and installed and followed directions as best i could.

Then I go to the .chm document copy the little example there.

i go to the Terminal (i'm on a Ubuntu machine) and type:

g++ -c example.cpp
g++ example.o -o example

the second command gives me the following error:

example.o: In function `main':
example.cpp:(.text+0x6c): undefined reference to `irr::createDevice(irr::video::E_DRIVER_TYPE, irr::core::dimension2d<int> const&, unsigned int, bool, bool, bool, irr::IEventReceiver*, char const*)'
collect2: ld returned 1 exit status

This is also my first dive into not using an IDE (just vi and g++) so any help is appreciated. Thanks alot, and sorry if I need to post more info.
zeno60
Posts: 342
Joined: Sun May 21, 2006 2:48 am
Location: NC, USA
Contact:

Post by zeno60 »

Make sure you are linking the correct lib.
enalios
Posts: 4
Joined: Thu Feb 08, 2007 1:38 am

Post by enalios »

how would i do that?

Well, i'll be more specific. which is the correct lib and where would (or should) it be?

also, while i'm being noobish, how would i make sure i'm linking to it?

haha. this is so humbling. once again thanks for the help.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

It depends on what platform you are on. Since you are using gcc, you want to link to the library in the lib/Win32-gcc or the Linux directory. You need to pass the appropriate flags to your linker to tell it where to find the library and what library to look for.

Code: Select all

g++ -c example.cpp 
g++ example.o -o example
In your example, pasted above, you are compiling on one step and then linking on the next. You can pass additional command line flags to the linker. You use the -L flag to specify the name of the directory to look for, and you would use the -l [that is an ell or lowercase L] to specify the name of the library to link.

Assuming that you extracted the distribution to /tmp/irrlicht/ and you are on Linux, you could compile and link your entire example in one line, like this...

Code: Select all

g++ example.cpp -o example -L/tmp/irrlicht/lib/Linux/ -lirrlicht 
Travis
enalios
Posts: 4
Joined: Thu Feb 08, 2007 1:38 am

Post by enalios »

thanks a ton! I had no idea i could do that! (just started using linux a few months ago)


well i don't think i'm getting that error anymore... instead it's another


several several lines that i won't bother to copy but the last 20-30 of which are undefined references in COpenGLTexture.cpp

sigh. Perhaps after a night's rest i can attack the problem better. i fiddle with it in the morning and update this post.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You may need to link to other libraries like the opengl library. I advise that you have a look at the makefiles that are provided with the example programs. If you are in the directory with the example source file you should just have to type 'make' and it would compile and link the example for you.

Travis
Post Reply