Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: C compiler for Unbuntu that can output .exe files

  1. #1
    Join Date
    Nov 2008
    Beans
    11

    C compiler for Unbuntu that can output .exe files

    Ok, I have a really strange question...Right now i am in a class that uses the C programing language. Basically we are sending in code and .exe files to be graded on. The submissions must include the executable file. At the moment this computer is functioning as a duel system boot. Just curious about how i could get a C compiler that will output into a .exe file for Ubuntu?

  2. #2
    Join Date
    Jun 2006
    Location
    Syracuse, NY
    Beans
    3,264

    Re: C compiler for Unbuntu that can output .exe files

    Quote Originally Posted by BadEyedia View Post
    Ok, I have a really strange question...Right now i am in a class that uses the C programing language. Basically we are sending in code and .exe files to be graded on. The submissions must include the executable file. At the moment this computer is functioning as a duel system boot. Just curious about how i could get a C compiler that will output into a .exe file for Ubuntu?
    I guess you might be able to install cygwin in wine to use GCC, but that just sounds weird...
    Desktop: AMD Athlon64 X2 3600+, Nvidia 8600GT, 3GB RAM, 80GB hd, Windows 7 Beta
    Lappy: Sony Vaio FW-140E, Intel P8400 2.26Ghz, 3GB Ram, 250GB HD, Intel x4500MHD, Windows 7 Beta & Kubuntu 8.10 w/ KDE 4.2

  3. #3
    Join Date
    May 2008
    Beans
    Hidden!

    Re: C compiler for Unbuntu that can output .exe files

    There is a cross compiler package for Ubuntu. Search for 'mingw' in the package manager, you may have some luck with it (I have not tried it).

    Alternatively, since you have a dual-boot, download the "real" MinGW for Windows and compile from there, it's more likely to work.

    Cygwin is another possibility (for Windows).

  4. #4
    Join Date
    Oct 2005
    Location
    De Kwakel - Holland
    Beans
    3,657

    Re: C compiler for Unbuntu that can output .exe files


  5. #5
    Join Date
    Aug 2007
    Location
    Arvada, CO
    Beans
    275
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: C compiler for Unbuntu that can output .exe files

    Quote Originally Posted by BadEyedia View Post
    Ok, I have a really strange question...Right now i am in a class that uses the C programing language. Basically we are sending in code and .exe files to be graded on. The submissions must include the executable file. At the moment this computer is functioning as a duel system boot. Just curious about how i could get a C compiler that will output into a .exe file for Ubuntu?
    The man file for gcc indicates that the -fvisibility-ms-compat option "attempts to use visibility settings to make GCC’s C++ linkage model compatible with that of Microsoft Visual Studio." I'd start there and see what I could get out of gcc.

  6. #6
    Join Date
    May 2008
    Location
    Camp Pendleton, CA
    Beans
    348
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: C compiler for Unbuntu that can output .exe files

    I'm in EXACTLY the same situation at school, I'm taking c++ and on windows everyone uses DevC++ but doesnt work that well in linux, sooo


    you just need the packages called build essentials

    search syntapic because i'm not sure of the spelling

    but
    Code:
    sudo apt-get install build essentials
    \

    and you can use any text editor.... ones that support the c language for highlighting reasons are prefered.

    I prefer Gedit because it's ubuntu's editor of choice .... and it's really powerful while being user friendly, and lightweight.

    If you choose gedit, you need to go to syntapic to download gedit plugins package.

    In gedit under preferences you can all all the plugins you want, like bracket highlighting and such. You can choose the highlight mode of the editor under view>highlight mode> source> c or c++ or any other for that matter.


    (important**** you will need to save your text files as blahblahblah.c
    so the compiler will use it correctly.*****)



    The way you compile and run things is to pull up a terminal.....

    cd (change directory ) to the folder that you have your text file saved into
    for example:
    Code:
    cd /home/sean/C/
    once in the right directory you may want to type ls to see how your files are spelled... (i know i do)

    to excute the compile command type:
    Code:
    gcc filename.c -o filename
    gcc is the compile program, the filename.c that you need to compile and -o tells it to OUTPUT the compiled excutable with the name filename if you left the -o blah blah out, then it would make an excutable called a out by default. you can always change that later but it keeps things in order.


    After you've worked out all the bugs and have compiled into an excutable.... rename the ectutiable to filename.exe

    (.exe is a ms DOS filetype that your instructor's computer should be able to excute)

    edit!!! sorry i forgot to add to run your excuted file to check if your code runs like you planed you need to type in a terminal:

    ./filename

    this will run your excutable file in the terminal.

    if you need any help just ask!
    -sean
    Last edited by Kain000; November 14th, 2008 at 08:23 PM. Reason: forgot somthing

  7. #7
    Join Date
    May 2008
    Beans
    Hidden!

    Re: C compiler for Unbuntu that can output .exe files

    Please disregard the post above. Renaming a file is not sufficient.

    Dev-Cpp may run under Wine, so I suggest you try that in addition.

    The -fvisibility-ms-compat option is also useless, since the OP appears not to be attempting to link with MSVC libraries. At any rate, he couldn't without a cross-compiler.

  8. #8
    Join Date
    Aug 2007
    Location
    Arvada, CO
    Beans
    275
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: C compiler for Unbuntu that can output .exe files

    Quote Originally Posted by Kain000 View Post
    After you've worked out all the bugs and have compiled into an excutable.... rename the ectutiable to filename.exe

    (.exe is a ms DOS filetype that your instructor's computer should be able to excute)

    if you need any help just ask!
    -sean
    Sean:

    If you're going through these steps in your class, then one of these things is true:

    1. You've performed an additional step which is not mentioned here which is causing gcc to output PE formatted binary by default
    2. Your instructor runs linux and recognizes an ELF formatted binary when he/she sees one.
    3. You're new to the class and haven't turned anything in yet, and are about to receive an unfortunate shock.

    Crossing my fingers for you and hoping it's not 3.

  9. #9
    Join Date
    Jan 2008
    Beans
    1,532

    Re: C compiler for Unbuntu that can output .exe files

    I find it really odd that your instructor is asking you to submit .exe files for grading. Most just ask for code and compile it themselves. If you wanted to be bad, that's a great opportunity .

    Anyway, since it's for a grade, I wouldn't muck around with cross-compiling; it is tricky to get working. You could easily turn in a program that won't actually run on Windows, so you would really have to test it on a Windows machine first. In which case you may as well just compile it on Windows...

    It sucks to have a class be dependent on a certain platform...

  10. #10
    Join Date
    May 2008
    Location
    Camp Pendleton, CA
    Beans
    348
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: C compiler for Unbuntu that can output .exe files

    Quote Originally Posted by Carl Hamlin View Post
    Sean:

    If you're going through these steps in your class, then one of these things is true:

    1. You've performed an additional step which is not mentioned here which is causing gcc to output PE formatted binary by default
    2. Your instructor runs linux and recognizes an ELF formatted binary when he/she sees one.
    3. You're new to the class and haven't turned anything in yet, and are about to receive an unfortunate shock.

    Crossing my fingers for you and hoping it's not 3.

    what do you mean?

    when i compile gcc spits out an executable (application/x-executable) file type but if his instructor wants a .exe file he just needs to rename and it will be recongized as a MS DOS executable.


    Our class is just printing out our code rather than uploading executables, but that would work just fine wouldnt it?

Page 1 of 3 123 LastLast

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
  •