🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Compiling/Linking Raknet in Linux

Started by
0 comments, last by hplus0603 9 years, 2 months ago

Hello there, I know this topic has been posted here before, but thatdidn't help me much sad.png and was too old, so i thought i would rather start a new thread.

I ran the following commands in RakNet root directory(not /Source)


cmake -i

It asks about the install directory whick is by default pointed to 'usr/local/'. I keep it as it is.

Final line of output is Build Successfull. So i Guess no problem here


make && make install

Output looks fine. The fils are attached below

[attachment=27001:cmk.txt]

[attachment=27002:mk.txt]

[attachment=27003:mkinstall.txt]

now, when i compile the file with the command -


g++ main.cpp -lRakNet -lpthread -lrt

Aside from some deprecated warnings, it gives me the error -


/usr/bin/ld: cannot find -lRakNet

So, When i looked into /usr/local, there wasn't a single file or folder of RakNet there.

Hence, I tried


g++ main.cpp -lpthread -lrt -L/pat-to-lib/libRakNetLibStatic.a

Still no luck, got some undefined function errors(i.e. Didn't link at all).

I also tried what was prescribed in Raknet Readme.

Running cmake in /Source appears to be fine, but dosen't solve the problem when I compile it.

Running the following in /Source


g++ -lpthread -g *.cpp

gives


usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11

Which usually occurs when there is no main() in program.

So, finally, my question is -

How to Compile / Link Raknet properly in Linux ?

According to best of my knowledge, i have compiled just fine, but am not able to link the file properly.

Advertisement
First, when you make install, you need to "sudo make install" because /usr/local/ isn't writable by regular accounts.
Second, after installing or updating shared libraries, you often need to run "sudo ldconfig" to make them globally visible.
Third, /usr/local/lib isn't always enabled as a default search location, so you may need to link with -L/usr/local/lib (and compile with -I/usr/local/include)
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement