DragonMaci Posted July 3, 2008 Report Share Posted July 3, 2008 I want to learn C, but I don't know how to compile C in Linux. How do I do it? Quote Link to comment Share on other sites More sharing options...
eriatarka Posted July 3, 2008 Report Share Posted July 3, 2008 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. Quote Link to comment Share on other sites More sharing options...
DragonMaci Posted July 3, 2008 Author Report Share Posted July 3, 2008 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. Quote Link to comment Share on other sites More sharing options...
Chops Posted July 9, 2008 Report Share Posted July 9, 2008 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). Quote Link to comment Share on other sites More sharing options...
DragonMaci Posted July 9, 2008 Author Report Share Posted July 9, 2008 (edited) 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 July 9, 2008 by DragonMaci Quote Link to comment Share on other sites More sharing options...
DragonMaci Posted July 9, 2008 Author Report Share Posted July 9, 2008 I just checked. CodeBlocks is not available through the package manager, so unless someone knows a package repository with it that I can add to my package manager I won't be able to try it. Quote Link to comment Share on other sites More sharing options...
John Kintaro Posted July 25, 2008 Report Share Posted July 25, 2008 http://downloads.sourceforge.net/codeblock...ntu1.deb.tar.gz That package should be what you want to install. Quote Link to comment Share on other sites More sharing options...
DragonMaci Posted July 27, 2008 Author Report Share Posted July 27, 2008 (edited) 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 July 27, 2008 by DragonMaci Quote Link to comment Share on other sites More sharing options...
Prometheus98876 Posted July 28, 2008 Report Share Posted July 28, 2008 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? Quote Link to comment Share on other sites More sharing options...
goldstandard Posted September 8, 2008 Report Share Posted September 8, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.