LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-03-2010, 02:08 AM   #1
jeremy28
Member
 
Registered: Sep 2009
Posts: 48

Rep: Reputation: 15
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.
 
Old 07-03-2010, 02:19 AM   #2
zirias
Member
 
Registered: Jun 2010
Posts: 361

Rep: Reputation: 59
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.
 
Old 07-03-2010, 02:42 AM   #3
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by jeremy28 View Post
...
(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.
 
  


Reply

Tags
autotools



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem creating rkhunter 1.3.6 package using slackbuild jrecortel Slackware 2 05-26-2010 09:37 PM
LXer: Pretending a Package is Installed by Creating an Empty Package with Checkinstal LXer Syndicated Linux News 0 05-03-2009 03:10 PM
Problem with superblock when creating a software raid 5 array halfjack Linux - Server 0 10-18-2006 08:06 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration