Jump to content
  • Advertisement
Sign in to follow this  
graveyard filla

compiling my project in Linux

This topic is 4976 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, i am working on a 2d persistant MORPG. anyway, i want to compile the server on linux. im running on the latest version of Fedora, and using Kdevelop. but i just cant figure out the basics of this.. for example, how do i add a new library to my project? also, what happend to .dll and .lib files? im pretty sure neither of these exist on linux, so what is there replacement? i think its .a and .so, or something like that, but what are the differences exactly, and how do i add one to my project? next, must i build all libraries from scratch now? most libs come with .dll and .lib files, but i dont see any .a or .so files... so i should build the library myself then? how do i set up the compiler to build a library so it gives me the proper output i want? thanks for any help... PS, im a very very big linux newbie, so go easy on the commands and stuff =).

Share this post


Link to post
Share on other sites
Advertisement
You have .a for libraries (an archive, basically a container for a bunch of object files), and .so (shared object) for dynamic link libraries.

I don't like most IDEs, I usually write my makefiles by hand, something like:

program: something.o somethingelse.o
TAB g++ $^ -o$@ -la_library -lanother_library

%.o: %.cpp:
TAB g++ -c $< -o$@


and then just type 'make'. I'm sure whatever KDevelop can do whatever it is you want though, just look around. And the forums ate my whitespace. All well.

Some libraries will come with programs to print out the correct commands to use, with SDL for example you would invoke g++ `sdl-config --libs`.

I'm sure that was confusing. Just ignore me and explore your IDE some more.

Fruny: Edit - actions must be prefixed with a TAB character. make is anal in that respect.

[Edited by - Fruny on February 8, 2005 3:53:13 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by graveyard filla

for example, how do i add a new library to my project?


Depends on how you're using KDevelop. I don't have much experience with it myself - I just wrote a makefile and set all my command-line stuff in there by hand... KDevelop just runs gmake on it.

Quote:
also, what happend to .dll and .lib files? im pretty sure neither of these exist on linux, so what is there replacement? i think its .a and .so, or something like that, but what are the differences exactly, and how do i add one to my project?


If you want to link with libfoo.a or libfoo.so, you add -lfoo to the list of parameters you pass to GCC. It'll automatically pick the dynamic library (.so) if it is available, otherwise, or if you add the -static switch, it'll grab the static library (.a)

Most of the libraries live under /usr/lib.

Quote:
Original post by graveyard filla
next, must i build all libraries from scratch now? most libs come with .dll and .lib files, but i dont see any .a or .so files... so i should build the library myself then? how do i set up the compiler to build a library so it gives me the proper output i want?


In most cases, installing a library from the source can be done in 3 instructions (and some waiting).

./configure (execute the configure script provided by the library developer)
make (builds the library)
make install (put the files in the appropriate locations)

The configure script accepts options regarding where to install the library, and things like that (read the README, INSTALL, CONFIGURE or ... files that should come with the source).

Share this post


Link to post
Share on other sites
Quote:
Original post by graveyard filla
hi,

i am working on a 2d persistant MORPG. anyway, i want to compile the server on linux.


we like clients, too :)

Quote:

im running on the latest version of Fedora, and using Kdevelop. but i just cant figure out the basics of this..

for example, how do i add a new library to my project?


I have never really used kdevelop, so I can't help you with specifics here.

Quote:

also, what happend to .dll and .lib files? im pretty sure neither of these exist on linux, so what is there replacement? i think its .a and .so, or something like that, but what are the differences exactly, and how do i add one to my project?


You are correct, they work similarly to Win32. The ".so" files are dynamic libs (like a DLL), ".a" files are static libs (like a .LIB). As far as adding a library to your project, that will be specific to whatever project management tools you are using (kdevelop in this case). You should probably read the kdevelop docs if this is going to be your chosen tool.



Quote:

next, must i build all libraries from scratch now? most libs come with .dll and .lib files, but i dont see any .a or .so files...


"most libs" will come with a .a or a .so if they are compiled for linux.


Quote:

so i should build the library myself then? how do i set up the compiler to build a library so it gives me the proper output i want?


This depends on what library you are talking about specifically.

EDIT: you guys are quick :)

Share this post


Link to post
Share on other sites
thanks everyone for your replies.

ok, i think i managed to build RakNet. i also believe SDL comes already set up on this distro, so now i only have to build MySQL++.

however, im having some problems. i cant figure out how to add the .a file to the project.. anyone have any clue how to do this in kdevelop?

also, does anyone know how i can specify an "includes directory"? VS.net has this. basically, i specify a folder and the compiler / IDE will check this folder automatically for header files when i #include them.

thanks for any more help.

Share this post


Link to post
Share on other sites
Here's how the whole magic works:

there's /usr/include which has lots of include files.
there's /usr/lib which has lots of library files.

when you compile and install a library, it puts things in /usr/include and /usr/lib.

To include that libraries headers, they're probably installed either in /usr/include itself or a subdir. You include like so (respectively)
#include <include.h>
#include <subdir/include.h>

To link the library, you add -lLIBNAME to the linker line. This is what you'll really look for in kdevelop. Linker options or Additional libraries or something like that. Add -lSDL to get sdl, for example. -lSDL tells the compiler to go find some horrendous file called something like libSDL.0.so.2.0.1 off in /usr/lib someplace, and make your executable dynamically link with that.

If you're targeting fedora for this server, I suggest you first look to see if there are fedora packages for the libraries you use, or already made port of those libraries for fedora (there probably are). Install these and just mark your final server as depending on these other packages, rather than compiling the libraries yourself.

Share this post


Link to post
Share on other sites
thanks for the reply. however im still getting errors about missing header files. i checked usr/include and dont see either RakNet nor MySQL++ header files in here. for Raknet, i just did "make static" and then "make install". for MySQL++ i did "./configure", "make", "su", "make install". this is what the README's told me to do, but im still getting a million errors.

also, i searched for linker options but no luck. about finding Fedora packages, it came with SDL but i couldnt find one for MySQL++ and the RakNet site is down (plus i doubt it would have it anyway).

thanks for any more help.

Share this post


Link to post
Share on other sites
Check /usr/local/include and /usr/local/lib for the files. If they're not ther, try find /usr | grep mysql, which should return all of the mysql-related files (replace "mysql" with whatever you want to look for).

Since you're using fedora, there's a good chance you'll be able to find RPMs (Red Hat Package Manager) for any major library you need. Make sure you also get the developer RPMs as well.

Share this post


Link to post
Share on other sites
thanks! you were right - i found the MySQL++ includes and .a files in the usr/local versions.. still no sign of the RakNet versions though, but im guessing that i have to put them in their myself? still have no clue on why kdevelop is not recognizing any of this though... im starting to think about wussing out and just installing windows 2000 on this box [grin]. although after sitting through the downloading / burning / installing of this four CD monster i really dont want to do that.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!