Error Message

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
Heiland

Error Message

Post by Heiland »

Hey, I compiled Irrlicht using Linux.
But when i compile the 1st example "hello world" i get the following error message:

/home/michael/tmp/ccMHouiR.o: In function `main':
main.cpp:(.text+0x4c): 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

but the sourcecode is correct! Can anyone help me please?
THX, Heiland
ElementoY
Posts: 15
Joined: Sun Feb 05, 2006 3:40 am
Location: Brazil
Contact:

Re: Error Message

Post by ElementoY »

Heiland wrote: main.cpp:(.text+0x4c): 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
have you linked it to libIrrlicht.a ? :wink:
Heiland

Post by Heiland »

Yes, i did!
Heiland

Post by Heiland »

Yes, i linked it to libIrrlicht.a
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

are you using the makefile that comes with the examples?
Heiland

Post by Heiland »

No, i compiled it using "g++ main.cpp -o main"
Heiland

Post by Heiland »

Ah, thx it works with "make"!
But why do i need this makefile??
Would be glad about an anser! Thx a lot!
hybrid

Post by hybrid »

Because it will link your app against irrlicht lib. You did not!
Linking against a library makes symbols from that library known to your app such that it can use them. When using a static lib this also includes copying the needed object files (those which your app is using and all dependent) into your app making it sometimes very large. In fact, linking against a static lib is the same as if you just add all those object files collected into that lib into your compiler command (g++ -o example main.cpp a1.o a2.o a3.o).
Dynamic libs are different in that symbol resolving is deferred until runtime. All symbols from a dynamic lib are just marked to be useable, and they get a relative adress to jump to during runtime when executing or accessing such symbols.
Anyway, you have to link during compilation (well, actually during linking the app, which is automatically done by most compilers, with an external tool, though). So add the correct library search paths with -L/path/to/library and the linking commands with -lnameOfLibrary.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

Amen hybrid, Amen! :wink:
hybrid

Post by hybrid »

:lol:
I'm wondering why these people all want to build their own house while just heard it's just putting bricks onto another. :?
Now, I've started similarly, but I knew how to read good books on this first. I read K&R probably four times until today. And nowadays it's even easier to google for the error message and get thousands of answers. But it seems even simpler to just ask all over again. I hope he learned this lesson now :roll:
Post Reply