Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Can't compile code in linux

  1. #11
    Join Date
    Apr 2009
    Location
    Germany
    Beans
    2,134
    Distro
    Ubuntu Development Release

    Re: Can't compile code in linux

    unfortunately you're leading him at the wrong track
    the above errors have nothing to do with header files

  2. #12
    Join Date
    Oct 2006
    Beans
    323

    Re: Can't compile code in linux

    Quote Originally Posted by MadCow108 View Post
    A header file won't solve the linking problem
    undefined reference is an error in the linking stage, not the compile stage.

    What the compiler did in Sim's line is following:
    gcc -c math.cpp -o math.o //compile math.cpp to object file
    gcc -c main.cpp -o main.o //compile main.cpp to object file
    gcc main.o math.o -o math // link main.o and math.o to math executable


    so far I know geany has no (yet) got a good way to do this without makefiles.
    A makefile is a file containing all the build rules executed with the command make
    http://www.gnu.org/software/make/manual/make.html
    i am using header files because of a programming course i am currently taking at university.

    The exersice i had to do was mainly for windows but i tried compiling the code on linux just to learn, and i don't really know what a makefile is,but i will try to learn

  3. #13
    Join Date
    Oct 2006
    Beans
    323

    Re: Can't compile code in linux

    Can you suggest another linux IDE that can help,except the command line?

  4. #14
    Join Date
    Apr 2009
    Location
    Germany
    Beans
    2,134
    Distro
    Ubuntu Development Release

    Re: Can't compile code in linux

    Quote Originally Posted by fasoulas View Post
    i am using header files because of a programming course i am currently taking at university.

    The exersice i had to do was mainly for windows but i tried compiling the code on linux just to learn, and i don't really know what a makefile is,but i will try to learn
    this is the advantage of the command line.
    IDE's hide how the process of building a program actually works.
    Using the command line teaches you a lot about that.

    Of course it can be debatable if this knowledge is useful when you have a professional IDE at your disposal which handles all that for you.
    I personally consider it something one should at least have a look at especially if you want to develop in linux.
    It also helps a lot when something in the IDE does not work how its supposed to work.

    I have little experience with free linux IDE's but the most suggested are Netbeans, Eclipse and code::blocks but as all more complex IDE's they have a bit of a learning curve.
    I mostly use geany for its simplicity and speed or just the editor vim for quick hacking.

  5. #15
    Join Date
    Apr 2008
    Location
    Australia
    Beans
    237
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Can't compile code in linux

    Quote Originally Posted by fasoulas View Post
    Can you suggest another linux IDE that can help,except the command line?
    Honestly, why are people so scared of the command line?

    Most IDEs just hide their compilation, but they are all working at the command line. The debugging too.
    As a user, the difference is we're given this in a widget as opposed to white text on a black background (or whatever colour scheme you're using).

    It just means we'll probably have to read a bit more. But really, if we're interested in software development, we won't get far if we're not willing to read much, we could consider it training for later.

    Just as MadCow has said, I honestly feel programmers should start with the command line first - I'm not saying IDEs are useless; quite the opposite in fact.
    But it's important to understand what it is an IDE is doing.

    I would strongly suggest using Emacs. Learn gdb, and learn about Makefiles too. I wouldn't recommend these unless there was a reason to use them.

    There's a learning curve to using the above tools - and I don't mention this to scare you off, but rather so you'll keep at it. Just go through the Emacs tutorial (which comes with Emacs) and then keep using Emacs, after less then a week you'll be comfortable.

  6. #16
    Join Date
    Oct 2006
    Beans
    323

    Re: Can't compile code in linux

    Quote Originally Posted by matthew.ball View Post
    Honestly, why are people so scared of the command line?

    Most IDEs just hide their compilation, but they are all working at the command line. The debugging too.
    As a user, the difference is we're given this in a widget as opposed to white text on a black background (or whatever colour scheme you're using).

    It just means we'll probably have to read a bit more. But really, if we're interested in software development, we won't get far if we're not willing to read much, we could consider it training for later.

    Just as MadCow has said, I honestly feel programmers should start with the command line first - I'm not saying IDEs are useless; quite the opposite in fact.
    But it's important to understand what it is an IDE is doing.

    I would strongly suggest using Emacs. Learn gdb, and learn about Makefiles too. I wouldn't recommend these unless there was a reason to use them.

    There's a learning curve to using the above tools - and I don't mention this to scare you off, but rather so you'll keep at it. Just go through the Emacs tutorial (which comes with Emacs) and then keep using Emacs, after less then a week you'll be comfortable.
    I followed your advise.I played a little with the terminal and the g++ compiler and it seems very easy to use and it's also very fast.

Page 2 of 2 FirstFirst 12

Tags for this Thread

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
  •