Simple linking problem

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
Uberbot
Posts: 31
Joined: Thu Dec 13, 2007 4:07 am

Simple linking problem

Post by Uberbot »

Hi all.

I'm finally getting back to Irrlicht after way too long away, and I can't get my program to link!

I've stripped my code down to the bare minimum that demonstrates my problem:

=======================================================
#include <irrlicht.h>
#include "globals.h"

using namespace irr;

irr::IrrlichtDevice *device;
video::IVideoDriver *driver;
scene::ISceneManager *smgr;

void g_init () {

device = irr::createDevice(video::EDT_OPENGL,
core::dimension2d<u32>(640, 480), 16, 0, 0, 0, 0);
}
=======================================================

When I compile this, I get:

graphics.o: In function `g_init()':
graphics.c:(.text+0x120): undefined reference to `createDevice'
collect2: ld returned 1 exit status

I am using -lIrrlicht on the g++ command line. So, what am I missing? I'm sure its a simple one.

Also, I'm wanting to put all of my graphics, and Irrlicht-specific stuff, in a single file with it's own namespace. Will this be a problem?

TIA,
Mike.
kazymjir
Posts: 727
Joined: Sat Feb 20, 2010 4:05 pm
Location: Munich, Bayern

Post by kazymjir »

try add to g++ -L/your/path/to/irrlicht_libs before -l
Uberbot
Posts: 31
Joined: Thu Dec 13, 2007 4:07 am

I'm pretty sure the problem is in the Makefile....

Post by Uberbot »

Yes, I'm pretty sure the problem is in the Makefile, but I sure can't find it.
Here are the relevant parts:

SHAREDOBJ = events.o protocol.o file_xfer.o
SHAREDFLAGS = -lenet

IRRINCDIR = ./libs/irrlicht-1.7.1/include/
IRRLIBDIR = ./irrlicht-1.7.1/lib/Linux/.1.7.1/

CLIENTOBJ = client.o client_config.o graphics.o headsup.o sound.o client_db.o client_net.o client_script.o input.o world.o
CLIENTFLAGS = -Wall -L$(IRRLIBDIR) -L/usr/X11R6/lib$(LIBSELECT) -lIrrlicht -lGL -lXxf86vm -lXext -lX11 -lenet -ljpeg -lpng -I$(IRRINCDIR) -lopenal -lalut

all: server client

client: main.c globals.h $(CLIENTOBJ) $(SHAREDOBJ)
g++ $(CLIENTFLAGS) $(SHAREDFLAGS) -DCLIENT $(CLIENTOBJ) $(SHAREDOBJ) -o client

The variable names may not be standard, but I'm trying to use much of the same src to build a client and server. What am I missing?

TIA.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Uberbot wrote: IRRLIBDIR = ./irrlicht-1.7.1/lib/Linux/.1.7.1/
That is your problem. You want that line to resolve to the directory that contains the Irrlicht library.

Travis
Uberbot
Posts: 31
Joined: Thu Dec 13, 2007 4:07 am

Post by Uberbot »

vitek wrote:
Uberbot wrote: IRRLIBDIR = ./irrlicht-1.7.1/lib/Linux/.1.7.1/
That is your problem. You want that line to resolve to the directory that contains the Irrlicht library.

Travis
I checked this out and had to make a change to make it right. However, the program still doesn't compile. Same error message. I even hardcoded the actual .h file in the source:

#include "./libs/irrlicht-1.7.1/include/irrlicht.h"

Same error message. This is getting embarrassing, but I'm just missing a detail, I'm sure.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The problem is not with includes. It is with linking. You need to set IRRLIBDIR to the path that contains the Irrlicht library. i.e., If the Irrlicht library archive is ./libs/irrlicht-1.7.1/bin/win32-gcc/Irrlicht.a, you want to use -L./libs/irrlicht-1.7.1/bin/win32-gcc.

You should really just try to look at the Irrlicht examples makefile. If you can build the examples using that makefile, you should be able to reproduce the compile and link lines and get the same thing...

Travis
Uberbot
Posts: 31
Joined: Thu Dec 13, 2007 4:07 am

FIXED!

Post by Uberbot »

vitek wrote:The problem is not with includes. It is with linking. You need to set IRRLIBDIR to the path that contains the Irrlicht library. i.e., If the Irrlicht library archive is ./libs/irrlicht-1.7.1/bin/win32-gcc/Irrlicht.a, you want to use -L./libs/irrlicht-1.7.1/bin/win32-gcc.

You should really just try to look at the Irrlicht examples makefile. If you can build the examples using that makefile, you should be able to reproduce the compile and link lines and get the same thing...

Travis
Got it! The problem was that the .so file in the lib directory was actually called libIrrlicht.so.1.7.0-SVN. A couple of symlinks later and it compiled like a champ. thanks for your patience.
Post Reply