LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Problem in creating a software package in linux? (https://www.linuxquestions.org/questions/programming-9/problem-in-creating-a-software-package-in-linux-817766/)

jeremy28 07-03-2010 02:08 AM

Problem in creating a software package in linux?
 
Hi all

I have a project that includes a file called “main.cpp” that the “main” function is defined in it and also has a series of header and source files that each one has defined a special class to do a special task!
Now, I want to make a software package for this project;

Frankly, this is my first experience!
Thus, I want to write a Makefile that compiles the project and runs it;

I’ve created a folder named “project” containing all of project’s files and folders. Inside it, I have:

1 - a folder named “MainSrv” containing “main.cpp” file.
2 - a folder named “include” containing all of header files.
3 –a folder named “lib” containing all of object files(.o), shared objects(.so) and archive files(.a).
4 –a folder named “src” containing all of “.cpp” files.
5 –a folder named “config” containing “config.cfg” file of the project.

At the beginning of “main.cpp” file, I should include some of that header files. I want to know how should be the include operation?
For example, one of them is “ptsocket.h”, I do so for including it:

Code:

#Include "include/ptsocket.h"
But I know it is wrong, because my “main.cpp” file is in a folder named MainSrv and when I could do so that the “include” folder was inside this folder (MainSrv) and beside the main.cpp!

What I want, is that I return back from “MainSrv” folder(which gets into “project” folder) and there, from “include” folder, add the ptsocket.h file to the program. But I don’t know how could be this task in “#include” directive?

Is this correct in your opinion:
Code:

#include “../include/ptsocket.h”
If so, how many should be the dots number (2 or 3)?

(I mean, I have problem with applying file paths in #include for each .cpp file!)

Also, I want to write a Makefile to compile these files and also to install the produced libraries in the system (so that, these path definitions are done in it…)

I ask you help me with that or introduce me a complete document to build a software package in linux and correct setting of a Makefile according to it.

TIA.

zirias 07-03-2010 02:19 AM

A quick answer: If you want to build libraries (.so), you're probably better off using a build system than writing your Makefile per hand. You could use the GNU autotools, but they're kind of hard to learn. People tell that cmake is easier, but I do not have own experience using it...

And, btw, ../ is correct to refer the parent path.

Sergei Steshenko 07-03-2010 02:42 AM

Quote:

Originally Posted by jeremy28 (Post 4022455)
...
(I mean, I have problem with applying file paths in #include for each .cpp file!)
...

No, it's not a problem - that's what scripting languages (like Perl) were made for and that's why editors (e.g. my favorite NEdit) have multiple files "Find and replace" operation.

...

Anyway, though it's not easy, start learning GNU autotools - as it has already been suggested. Start, say, from here: www.lrde.epita.fr/~adl/dl/autotools.pdf ; you'll probably need the official documentation too.

...

With GNU autotools your project can become really cross-platform.

knudfl 07-03-2010 02:48 AM

No three times period. ../ , as said by @zirias.
And ../../ , etc.


About auto tools , makefiles
http://www.gnu.org/software/autoconf/
http://www.gnu.org/software/automake/
http://sourceware.org/autobook/

http://www.freesoftwaremagazine.com/..._gnu_autotools
http://www.freesoftwaremagazine.com/...with_autotools
http://www.freesoftwaremagazine.com/..._with_autoconf

http://www.wlug.org.nz/MakefileHowto
http://www.eng.hawaii.edu/Tutor/Make/
http://www.linuxplanet.com/linuxplan...orials/7093/1/


All times are GMT -5. The time now is 01:13 PM.