Jump to content
Objectivism Online Forum

Linux C Compilation

Rate this topic


DragonMaci

Recommended Posts

Why do you want to learn C? If its your first language then it definitely isnt the best choice.

But specifically, what are you having trouble with? Do you need to know which compiler to use (GCC)? Or are you having trouble linking multiple source files together? Or dont you understand headers?

Generally youd compile with:

gcc file1.c file2.c file3.c -o outputfile

where file1.c etc are the various source files. For anything moderately large you'd be better off having a look at makefiles though.

Link to comment
Share on other sites

I am learning C on the advice of my cousin, who is going to employ me to help him with his software projects in return for him developing a website I need built later this year. My problem is that once I have done the tutorial projects from the website I am going to use to learn C, I do not know how to compile the .c file into a program. I only need one file compiled at a time - at least for now (I don't know about later tutorials). My version of Linux (Kubuntu 8.10) has GCC installed.

As for makefiles, I don't know how to create them or what to put in them.

Link to comment
Share on other sites

For compiling a single c file (or a few), eriatarka nailed it.

Makefiles are a completely different monster, and I honestly have forgotten how to even make them.

One thing you could look into (if you're running Linux natively in a GUI, rather than from a remote terminal) is CodeBlocks, which is a cross-platform C++ IDE (which I believe uses G++ for compilation).

Link to comment
Share on other sites

For compiling a single c file (or a few), eriatarka nailed it.

I already said I want to compile just one at a time, not a few. My friend told me how to do that.

One thing you could look into (if you're running Linux natively in a GUI, rather than from a remote terminal)

I am using a GUI; I don't like using terminals unless I have to.

is CodeBlocks, which is a cross-platform C++ IDE (which I believe uses G++ for compilation).

My version of Linux comes with Qt for that. However, I am trying top learn C and am starting from the basics, so I am making console apps, not apps with an GUI.

Addition: Also, unless it is available through I package manager the installation of CodeBlocks won't work; installation through other means won't work for some reason.

Edited by DragonMaci
Link to comment
Share on other sites

  • 3 weeks later...
http://downloads.sourceforge.net/codeblock...ntu1.deb.tar.gz

That package should be what you want to install.

I said packages only work for me if downloaded through my package manager. Besides, I don't need it anymore. I own a copy of Windows XP Professional x64 now and am using that.

Edited by DragonMaci
Link to comment
Share on other sites

Why do you want to learn C? If its your first language then it definitely isnt the best choice.

I disagree with this. It is the first programming language I learnt after I starting studying programming seriously (the very first language I learnt even a little of was BASIC though, but no one would bother learning that as a first language anymore) and I found it a good language for this purpose.

Why do you think it would not be a suitable first language?

Link to comment
Share on other sites

  • 1 month later...

Just wanted to chime in. I had no idea how to use makefiles myself, until I read this nice manual and I was making simple makefiles in no time: GNU 'make'

The cool thing about makefiles is that even if you only have a few files it still makes compiling easier. This is because all you have to do is type "make" while in the directory your sources and makefile are in and it will automatically execute the appropriate commands for you. This manual is also nice because it gives you enough info to get started right off the bat and leaves the complicated stuff for later.

I hope this helps out.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...