[Irrlicht] Problem with linkage.

For people working on the C++ code.
User avatar
Andrey01
Member
 
Posts: 2338
Joined: Wed Oct 19, 2016 15:18
Location: Russia, Moscow
GitHub: Andrey2470T
In-game: Andrey01

[Irrlicht] Problem with linkage.

by Andrey01 » Thu Nov 28, 2019 10:50

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
 

User avatar
rubenwardy
Moderator
 
Posts: 5937
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: [Irrlicht] Problem with linkage.

by rubenwardy » Thu Nov 28, 2019 11:45

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
 

User avatar
Andrey01
Member
 
Posts: 2338
Joined: Wed Oct 19, 2016 15:18
Location: Russia, Moscow
GitHub: Andrey2470T
In-game: Andrey01

Re: [Irrlicht] Problem with linkage.

by Andrey01 » Thu Nov 28, 2019 13:10

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.
 

User avatar
Andrey01
Member
 
Posts: 2338
Joined: Wed Oct 19, 2016 15:18
Location: Russia, Moscow
GitHub: Andrey2470T
In-game: Andrey01
 

neoh4x0r
Member
 
Posts: 69
Joined: Wed Aug 29, 2018 20:16
GitHub: neoh4x0r

Re: [Irrlicht] Problem with linkage.

by neoh4x0r » Fri Dec 27, 2019 21:15

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)
 

User avatar
Andrey01
Member
 
Posts: 2338
Joined: Wed Oct 19, 2016 15:18
Location: Russia, Moscow
GitHub: Andrey2470T
In-game: Andrey01

Re: [Irrlicht] Problem with linkage.

by Andrey01 » Tue Jan 14, 2020 14:47

Thanks, neoh4x0r! I`ve understood how I need to correctly link the lib and the source and it got worked.
 


Return to Partly official engine development



Who is online

Users browsing this forum: No registered users and 1 guest