Find the answer to your Linux question:
Results 1 to 2 of 2
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 ...
  1. #1
    Just Joined!
    Join Date
    Sep 2009
    Posts
    27

    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.

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    This is not how I would structure my source code.

    Source code is usually only structured this way after installation on a computer. The include/ directory contains header files that will be installed on the machine. Header files that are used only by the program itself should usually be included with the source code.

    Most source code packages will have a single src/ directory that contains all of the source (*.c, *.cpp, *.java, etc.) files AND all of the header files together. This also vastly simplifies including a header file:
    Code:
    #include "header.h"
    As far as writing a Makefile goes, I highly suggest using autoconf and automake. They make life very easy:
    Autoconf - GNU Project - Free Software Foundation (FSF)
    Automake - GNU Project - Free Software Foundation (FSF)
    DISTRO=Arch
    Registered Linux User #388732

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...