#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Location
    WA
    Posts
    26
    Rep Power
    0

    How to run c compiler from commandline


    I am new to this so please bear with me a moment.
    dev-c++ 5.5.3 is installed.
    I can write a "hello.c" file, compile, and then run from the ide or a command line.
    I have not been able to find the .exe to compile from the command line (dos prompt I used to call it).
    I looked in the MinGW32\bin and elsewhere.
    I have read about needing to specify something in PATH, but I do not understand. My config.sys and autoexec.bat files are empty. Using windows xp.
    Again I can use the IDE, I want to also be able to do everything from the command line. I think this is compile and link and debug if necessary.
    Also what I have found online is usually for C++, but I am writing in c.
    thank you.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Location
    WA
    Posts
    26
    Rep Power
    0

    I figured it out


    I really have been searching for hours.Now I figured it out just after posting the question.
    c:\MinGW32\bin\gcc.exe c:\01\hello.c -o c:\01\hello.exe
    the examples I read left out:
    c:\MinGW32\bin c:\01\ c:\01\
    I always seem to get tripped up on simple things.
    Thanks anyhow.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Location
    Saint-Petersburg, Russia
    Posts
    237
    Rep Power
    29
    Very well you overcome it yourself. Congratulations!

    If you set up your PATH environment variable to include the folder where gcc.exe resides, you will make things much easier for you.

    The other not-too-bad idea is to setup virtual machine (VirtualBox will do all right) and install Ubuntu in it, for example (download disk image and start virtual machine with it).

    gcc is preexisting here with all paths set up. You can also use Ubuntu from bootable CD to try if you like it. Though if you do not want to install it and only run from CD for your exercises - Knoppix could be bit nicer.

    Installing and using many developer tools under linux is somewhat easier in my opinion. They are included in repositories so you are usually only need to tell the system to install g++ or python or java, git or svn - and you have it in a few seconds.
    CodeAbbey - programming problems for novice coders
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Location
    WA
    Posts
    26
    Rep Power
    0
    PATH environment variable. Nice. Now I work from the C:\ prompt.

    I have Ubuntu 10.10 on a partition. It is old for my old computer, but I can compile in a terminal, and go online.

    Ubuntu seems to "mount" in / but I am working in / home username (or / /home /username).
    I do not know how my computer's name fits in, and I think this means I am not "running in root(as root?)"(not the folder root); but this is probably a question for a thread in the linux section of this forum.

    Anyways, thank you very much!
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Location
    WA
    Posts
    26
    Rep Power
    0
    Actuall I have now put "C:\MinGW32\bin;" instead of "C:\MinGW32\bin\gcc.exe" into my PATH. Works better now.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    2
    Rep Power
    0
    Sorry not trying to hijack your thread but I reg'd here to post a similar question..:

    I'm trying to compile a hello.c type thing too but am getting an error.

    Using TCC (tiny compiler) Maybe I should be using something else?

    1: /* Hello.c: This is my first C program */
    2: #include <stdio.h>
    4: main()
    5: {
    6: printf ("Hello. This is my first C program.\n");
    7: return 0;
    8: }

    have this saved Hello.c in c:\tcc\
    I type tcc Hello.c
    and get "1:error: declaration expected"

    Any ideas? When I use the tcc examples this way it compiles fine.
    Thank you
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    2
    Rep Power
    0
    whoops figured it out

    When I took out the line numbers at the beginning of each line it worked.

IMN logo majestic logo threadwatch logo seochat tools logo