Page 1 of 1

[Irrlicht] Problem with linkage.

Posted: Thu Nov 28, 2019 10:50
by Andrey01
I`ve been learning Irrlicht API lately and I`ve decided to start programming with it. Maybe it is not quite on-topic, but as this library is incorporated in Minetest and I have a tendency to use it in the contributing process to MT engine, I decided to ask on this forum. And so, the compiler throws out to me a following error in preprocessing-time after how I enter make all:

Code: Select all

gcc -c -o experimental.o /home/andrey/irrlicht/experimental.cpp g++ -c -o /home/andrey/irrlicht-1.8.4/source/Irrlicht/CAnimatedMeshMD2.o /home/andrey/irrlicht-1.8.4/source/Irrlicht/CAnimatedMeshMD2.cpp /home/andrey/irrlicht-1.8.4/source/Irrlicht/CAnimatedMeshMD2.cpp:5:10: fatal error: IrrCompileConfig.h No such file or directory 5 | #include "IrrCompileConfig.h" | ^~~~~~~~~~~~~~~~~~~~ compilation terminated
I compiled separately the irrlicht source files and here I try to compile experimental.cpp and then link it with those irrlicht objective ones. And it`s really strange, why is there incorrect path to IrrCompileConfig.h in the #include specified if it`s actually in /include directory, not in the current one?

My files:
https://ufile.io/66cmpz7d
https://ufile.io/wxqa5zwn

Re: [Irrlicht] Problem with linkage.

Posted: Thu Nov 28, 2019 11:45
by rubenwardy
You shouldn't use GCC raw, you're making your life much harder. You should use cmake or another build tool for any serious project. Using GCC or a makefile is only good for when you have small projects without many dependencies

You should follow the irrlicht tutorial on using cmake

Also, irrlicht shouldn't be used for any new projects unless your eventual aim is to contribute to minetest

Re: [Irrlicht] Problem with linkage.

Posted: Thu Nov 28, 2019 13:10
by Andrey01
rubenwardy wrote:You shouldn't use GCC raw, you're making your life much harder. You should use cmake or another build tool for any serious project. Using GCC or a makefile is only good for when you have small projects without many dependencies

You should follow the irrlicht tutorial on using cmake

Also, irrlicht shouldn't be used for any new projects unless your eventual aim is to contribute to minetest
Well, I`d like just to train with Irrlicht API to learn for a start, that`s why I use Make. And then use it in the contribution process. So, I`d like to solve that issue descripted above.

Re: [Irrlicht] Problem with linkage.

Posted: Fri Nov 29, 2019 22:28
by Andrey01
Does anybody know how to solve that issue?

Re: [Irrlicht] Problem with linkage.

Posted: Fri Dec 27, 2019 21:15
by neoh4x0r
Andrey01 wrote:I`ve been learning Irrlicht API lately and I`ve decided to start programming with it. Maybe it is not quite on-topic, but as this library is incorporated in Minetest and I have a tendency to use it in the contributing process to MT engine, I decided to ask on this forum. And so, the compiler throws out to me a following error in preprocessing-time after how I enter make all:

Code: Select all

gcc -c -o experimental.o /home/andrey/irrlicht/experimental.cpp g++ -c -o /home/andrey/irrlicht-1.8.4/source/Irrlicht/CAnimatedMeshMD2.o /home/andrey/irrlicht-1.8.4/source/Irrlicht/CAnimatedMeshMD2.cpp /home/andrey/irrlicht-1.8.4/source/Irrlicht/CAnimatedMeshMD2.cpp:5:10: fatal error: IrrCompileConfig.h No such file or directory 5 | #include "IrrCompileConfig.h" | ^~~~~~~~~~~~~~~~~~~~ compilation terminated
I compiled separately the irrlicht source files and here I try to compile experimental.cpp and then link it with those irrlicht objective ones. And it`s really strange, why is there incorrect path to IrrCompileConfig.h in the #include specified if it`s actually in /include directory, not in the current one?
You can try to make the following changes to experimental.cpp and Makefile.
When I tried your files, as is, I got a long list of errors....
Altering making these changes, it compiled correcly.

PS: you don't need to compile in all of the object files for irrlicht (these are already included in libirrlicht.a)
so you only need to link against the library that has already been compiled.


The -IPATH directive tells the compiler to look in PATH for include files
the -LPATH directive tells the compiler to look in PATH for library files

-I$(IRRLICHT_PATH)/include tells the compiler to look in that path for the include files
When <irrlicht.h> is included in the cpp file it will look in this path for it (the other includes from this will be found as well)

The reason you get an error about IrrCompileConfig.h not being found is because you did not tell the compiler where to
find it (using the -IPATH directive is how you do this).

experimental.cpp

Code: Select all

change the include at the top of the file to this:
#include <irrlicht.h>
Makefile

Code: Select all

IRRLICHT_PATH = /home/user/irrlicht-1.8.4/

SYSTEM=Linux

CPPFLAGS += -I$(IRRLICHT_PATH)/include
ifndef NDEBUG
CXXFLAGS += -g -Wall
else
CXXFLAGS += -O3
endif

# mirrored from the irrlicht example code (included in the irrlicht path: $(IRRLICHT_PATH)/examples
LIBS += -lGL -lXxf86vm  -lX11 -L$(IRRLICHT_PATH)/lib/$(SYSTEM) -lIrrlicht

TARGET = experimental

SOURCES += $(TARGET).cpp
# if more cpp files are created, add them here
#SOURCES +=  something1.cpp something2.cpp  something3.cpp


all: $(TARGET)

$(TARGET):
	g++ $(CPPFLAGS) $(CXXFLAGS) $(SOURCES) -o $(TARGET) $(LIBS)

clean:
	rm -f $(TARGET).o
	rm -f $(TARGET)

Re: [Irrlicht] Problem with linkage.

Posted: Tue Jan 14, 2020 14:47
by Andrey01
Thanks, neoh4x0r! I`ve understood how I need to correctly link the lib and the source and it got worked.