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.
Simple linking problem
I'm pretty sure the problem is in the Makefile....
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.
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.
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:vitek wrote:That is your problem. You want that line to resolve to the directory that contains the Irrlicht library.Uberbot wrote: IRRLIBDIR = ./irrlicht-1.7.1/lib/Linux/.1.7.1/
Travis
#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.
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
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
FIXED!
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.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