0

Short version of question: How do I get started with C programming? Note that I am not asking for a tutorial on learning C language (I can learn that easy enough). I need to setup the environment (I hope I'm asking this question clearly). Here's what I mean:

For my math thesis, I need to write a program in C on Gentoo Linux, using a library called CVODE/SUNDIALS. There is nobody (it seems) in my department who can help me set this up - my professor has left the computer work 100% to me because I have some programming background and he's a math geek. But my experience is with scripting languages (think VBA) and not full, powerful programming languages where you have to link the compiler and libraries, etc. like C.

There is no development environment on the Linux cluster - or at least not that's friendly, and has a debugger - that I've found. So, what I need to figure out how to setup a C programming environment with CVODE library on my PC (Win 7 x64, at little to no cost.

I have found plenty of tutorials on programming in C. I looked up Eclipse, which I have a little bit of experience with, as a development environment, but it's instructions say you need to install a compiler, too.

What I would like is someone to tell me, in simple language that I can understand (which might be the most difficult part of this question) the big picture of what I need and what to do (and maybe even links to where I can find what I need) to set up a C environment with CVODE. If the information is Windows/Gentoo Linux cross platform, even better.

Thank you.

P.S. I did search the site and saw lots of "How do I setup" quesitons, but no C one. Because I know someone will yell at me for that. Also, I don't want to have a convo about whether to use C#, C++, Java, etc. That just complicates the issue - and I need to get this done.

Edit: I have learned a little more since this question and now realize that I left out a key part of the question. The CVODE library and Linux cluster at school use MPI - parallel programming - which is not available on your average, run-of-the-mill PC. So all development must be done directly on the cluster.

Jeff
  • 747
  • 3
  • 8
  • 17
  • You can install something like Code::Block or only a Cygwin C compiler on your Windows, if you are on linux, you have a compiler by default cc gnu. For your externe library, i don't know! Never used it! But you pu it in your project and use it in your include header. nothing too hard at this point – neimad Jul 29 '12 at 19:16
  • 2
    Is this what you are asking for? [Setting up a Programming Environment in Linux](http://stackoverflow.com/questions/222471/setting-up-a-programming-environment-in-linux?rq=1) – Bo Persson Jul 29 '12 at 19:29
  • 1
    Try to get in touch with someone developing in C on Linux. He'll teach you a lot of useful tips. – Basile Starynkevitch Jul 29 '12 at 20:02
  • "For my math thesis, I need to write a program in C on Gentoo Linux". Install Gentoo Linux on your Windows system (dual boot). – Scooter Aug 18 '12 at 02:11
  • @Scooter Well, one thing I didn't mention in my OP was that this is an MPI program running on a Linux cluster. I actually did install Gentoo on a spare PC in my house. It takes about a day and significant Linux expertise. Thanks for the suggestion. – Jeff Aug 18 '12 at 02:15
  • @Jeff I am confused. Do you now have a working Gentoo Linux on a PC at your house on which you can write the program? Is that PC connected to the internet? Edit: Oh wait, apparently there is some software on the server you must have (MPI?), so you must dial in. – Scooter Aug 18 '12 at 02:35
  • @Scooter Right. At this point I'm using emacs to code and trying to learn gdb to debug. Those seem to be my only realistic options. – Jeff Aug 18 '12 at 03:07

4 Answers4

2

Linux: Simple way is to install gcc or g++. You can write your code in your plain text editor (nano, vim, gedit, kwrite, etc) Save your file in .c or .cpp extention and type in terminal

gcc filename.c

or

g++ filename.cpp
  • this will work on almost every linux system, also don't forget some linux systems , g++ or gcc aren't enabled by default – pyCthon Jul 29 '12 at 19:33
  • You may also want to use GNU `make` which usually exists on systems having `gcc`; for example Debian have the `build-essential` virtual package. You probably want a version control system like `git` – Basile Starynkevitch Jul 29 '12 at 19:43
2

You said that you want to write c code on Gentoo Linux, as i understand you're not familiar with Linux? The best choice in this case is to:

  1. Install virtualbox in your windows machine (https://www.virtualbox.org/), it's a free software that let you emulate in your desktop another systems like Linux...

  2. Install Gentoo linux on virtualbox, there are a lot of tutorials on the net, for example this video: http://www.youtube.com/watch?v=DUf_1wAPeyA

  3. When you install Gentoo Linux on virtualbox you have all you need to develop C (gcc compiler, gdb debugger...)

  4. Now you can download your library, and decompress it

  5. In general all (Good) Linux libraries come with a 'README' file that contain all instructions for installing the library. I think you need to do this:

    ./configure --prefix=/DIRECTORY_YOU_WANT_TO_INSTALL_THE_LIBRARY
    
    make
    
    make install
    
  6. You can now play with C and you new library, like this: suppose you create a new file test_lib_ CVODE.c you can compile it like this:

    gcc -Wall test_lib_ CVODE.c -o test_lib_ CVODE -lcvode
    

I assume that the installed library is named libcvode.so

If you have any questions, you can always get help here.

Regards.

stakx - no longer contributing
  • 83,039
  • 20
  • 168
  • 268
TOC
  • 4,326
  • 18
  • 21
0

I think you should use Code::Block in Linux, it is very similar to Window's Code::Block and it is very easy to debug and other things.

sonnet
  • 13
  • 1
  • 5
0

These were all useful answers. I tried pursuing each of them at least a little bit. However, the only reasonable solution seems to be to use emacs on a terminal window. This is because I'm using MPI - yes, I know I didn't mention that in the OP - which can only be done on a cluster.

I am new to this environment and was not aware of the MPI or the affect it would have on my attempt to develop.

I believe I can do better than this if I can figure out X/Windows using Cygwin. But I am a long way from that.

Thanks all for your effort and sorry I can't really award a best answer (I guess).

Jeff
  • 747
  • 3
  • 8
  • 17