Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: How do I compile without a program like kdevelop?

  1. #1
    Join Date
    Nov 2006
    Location
    Around JCMO
    Beans
    93
    Distro
    Lubuntu

    How do I compile without a program like kdevelop?

    I keep hearing that using kdevelop is not a wise decision.... but how on earth am I supposed to compile the rest? I know G++ is involved, but it wont work unless you have files such as configure...

    What program do I use to make the other files that G++ needs to compile with a program? If your supposed to make them manually... where can I find tutorials for this?
    Last edited by speedingbullet; January 19th, 2008 at 02:08 AM. Reason: spelling

  2. #2
    Join Date
    Oct 2006
    Location
    Austin, Texas
    Beans
    2,715

    Re: How do I compile without a program like kdevelop?

    You don't need any magic files to use gcc, just read the manual:
    Code:
    man gcc
    Maybe you're talking about makefiles, in that case hit the manual (you're probably better off looking at examples, that thing is huge, but you might want to read the first few sections).

  3. #3
    Join Date
    Oct 2006
    Beans
    513

    Re: How do I compile without a program like kdevelop?

    Numerous build systems are available: (short list)
    make: very basic, you essentially write the commands neccessary to compile/build
    autotools: automatic makefile generation
    jam: not sue
    icomplie: claims to figure out dependency automatically

    You might want to look at pkg-config too
    Donation links
    Free hardware
    Petition for free drivers
    If every forum member donated $1 to FSF, they would almost double their income

  4. #4
    Join Date
    Nov 2006
    Location
    Around JCMO
    Beans
    93
    Distro
    Lubuntu

    Re: How do I compile without a program like kdevelop?

    thanks, both of you

  5. #5
    Join Date
    Jan 2008
    Location
    Raytown, MO
    Beans
    460
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: How do I compile without a program like kdevelop?

    Just in case we have overlooked the obvious ...

    Have you installed build-essential ?

    if not:
    Code:
    sudo apt-get build-essential
    You can build a lot of stuff from the command line using gcc,
    but at some point your going to need to deal with configure,
    make, etc ...

    Steve

  6. #6
    Join Date
    Nov 2006
    Location
    Around JCMO
    Beans
    93
    Distro
    Lubuntu

    Re: How do I compile without a program like kdevelop?

    Thats my problem though... the program I am making is divided into individual files. Its a text game, so I think this is very necessary so I don't get lost trying to program it.

    Don't programs like that need files that link the files together?


    I'll probably be experimenting with GTKMM before too long... Id rather take steps before trying to learn opengl... its just that I don't think my game is suited for UNIX/MSDOS.

  7. #7
    Join Date
    Jan 2008
    Location
    Raytown, MO
    Beans
    460
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: How do I compile without a program like kdevelop?

    Quote Originally Posted by speedingbullet View Post
    Thats my problem though... the program I am making is divided into individual files. Its a text game, so I think this is very necessary so I don't get lost trying to program it.
    I understand, in general modular programming is a good thing

    Don't programs like that need files that link the files together?
    makefiles - which aren't as daunting as the first seem...

    I'll probably be experimenting with GTKMM before too long... Id rather take steps before trying to learn opengl... its just that I don't think my game is suited for UNIX/MSDOS.

    The choice of GUI programming tools, is a thing of personal
    preference. Getting the text version worked out first, is the
    right thing to do.

    HTH

    Steve

  8. #8
    Join Date
    Oct 2006
    Location
    Austin, Texas
    Beans
    2,715

    Re: How do I compile without a program like kdevelop?

    If you don't want to mess with makefiles yet, you can do this using just GCC. A shell script could easily be used to keep it all together. For a simple build...

    Compile each "cpp" file using:
    Code:
    g++ -c source.cpp -o source.o
    Which will generate your object files.

    Then, link them all using:
    Code:
    g++ source1.o source2.o source3.o -o program
    During the linking process, you may have to link to any external libraries you use. Naturally, "source" is just an example.

  9. #9
    Join Date
    Dec 2006
    Location
    Sacramento, CA
    Beans
    284
    Distro
    Ubuntu 6.10 Edgy

    Re: How do I compile without a program like kdevelop?

    Or, just throw it all together into 1 step:

    g++ source1.cpp source2.cpp source3.cpp -o myprogram

    For simple projects with just 3-4 files, this works fine.

  10. #10
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,288
    Distro
    Kubuntu

    Re: How do I compile without a program like kdevelop?

    As stevescripts pointed out, Makefiles are not a big deal. Here's a sample Makefile that you can copy and modify to fit your C++ project:

    PHP Code:
    SRCS     SourceFile1.cpp SourceFile2.cpp SourceFile3.cpp SourceFileN.cpp

    APP      
    myProgramName

    CXXFLAGS 
    = -g
    INCPATH  
    = -I../include

    OBJS     = $(SRCS:.cpp=.o)
    LIBPATH  = -L../lib
    LIBS     
    = -lTCP -lboost_thread-mt
    DEP_FILE 
    = .depend

    .PHONYclean cleanall

    # Note that from here on down, indented lines commence with a tab-space!
    #
    $(APP): $(OBJS)
        @echo 
    Makefile linking $<
        @$(
    CXX) $^ $(LIBPATH) $(LIBS) -$@

    clean:
        $(
    RM) *.o core*

    distcleanclean
        
    $(RM) $(APP)
        $(
    RM) $(DEP_FILE)

    .
    cpp.o:
        @echo 
    Makefile compiling $<
        @$(
    CXX) $(CXXFLAGS) $(INCPATH) -$< -$@

    depend:
        @$(
    RM) $(DEP_FILE)
        @for 
    i in $(SRCS) ; do \
            $(
    CXX) --MM $(INCPATH) $$i >> $(DEP_FILE); \
        
    done

    ifeq 
    (,$(findstring clean,$(MAKECMDGOALS)))
    ifeq (,$(findstring distclean,$(MAKECMDGOALS)))
    -include $(
    DEP_FILE)
    endif
    endif 
    P.S. Important thing to know... to invoke a Makefile, run this command:
    Code:
    $ make
    Last edited by dwhitney67; January 20th, 2008 at 02:38 AM.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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