Python Forum
C code under linux - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Forum & Off Topic (https://python-forum.io/forum-23.html)
+--- Forum: Bar (https://python-forum.io/forum-27.html)
+--- Thread: C code under linux (/thread-658.html)



C code under linux - elico - Oct-27-2016

Hi 

I need to code some program in C
Do I have to compile it under linux ?
Can  I compile it under WINDOWS and when verifid can I upload and run the 
compiled C code to my linux and run it under linux?

Thanks 
elico


RE: C code under linux - Ofnuts - Oct-27-2016

No, you can find find C compilers for Windows. The canonical free compiler is GCC, and you'll find Windows version for it, but they come with whole command-line environments that emulate the Linux one (MinGW or Cywgwin).

The code you compile on Windows to debug on Windows won't run as is on Linux, it will have to be recompiled for Linux (different formats for executable code). If you create a makefile this will be quick and easy.

This said if the code targets Linux better develop it on Linux... What keeps you on Windows? A text editor?


RE: C code under linux - Skaperen - Oct-29-2016

all major linux distributions come with a free C compiler ... except the tiny ones for special purposes like network firewalls.

learn to do things on linux. you can even use python there. if you are into multi-lingual programming, you should also do multi-platform stuff. this will make it easier to get a better job.


RE: C code under linux - Larz60+ - Oct-29-2016

I have used both of the compilers that Ofnuts suggested.

Both (from all that I've done with them(a lot)) are bug free as far as I can tell
Cygwin is pretty much a complete UNIX/POSIX system, and when you bring it up,
you would think you're on a UNIX system. You might like this. It is a bit quirky to
install, and may ruffle your feathers a bit, but that's a one time frustration, and there
are some good installation write-ups available.

MinGW on the other hand doesn't require all the dll's that Cygwin requires, and installs very
easily with just MSVC.

MinGw is here or here

Cygwin is here
[url=https://www.cygwin.com/][/url]


RE: C code under linux - Skaperen - Oct-29-2016

the executable and library file formats are different between linux and windows.  if you want to make one run on the other, you will need to cause the tool programs that build these to build for the other using the other's format.   the simpler way is for each to build its own format.  if you only have one physical machine, i suggest running a virtual machine program and in there run the other OS.  this can be done both ways (windows on linux and linux on windows).


RE: C code under linux - metulburr - Oct-29-2016

(Oct-29-2016, 06:38 AM)Skaperen Wrote: if you only have one physical machine, i suggest running a virtual machine program and in there run the other OS.  this can be done both ways (windows on linux and linux on windows).
Ive had problems in the past using this method (specifically with py2exe on a windows virutal machine running in linux). Its been so long i could not say why though. My fix was to dual boot windows/linux.


RE: C code under linux - sparkz_alot - Oct-29-2016

If you are working on a Windows machine and don't want to invest in a new linux machine, create virtual environments or make a dual boot system, there are online tools that will do the conversion for you (depending on the complexity of your program). Here is just one example: http://www.onlinecompiler.net/ . There are many others as well.  I would be interested if this or another site proved satisfactory for your purpose.  Smile


RE: C code under linux - metulburr - Oct-29-2016

(Oct-29-2016, 01:17 PM)sparkz_alot Wrote: don't want to invest in a new linux machine, 
At this point i have a few desktops and i no longer even hassle with dual booting. I keep newer machines for windows as i game on them, and older ones for linux. I snag old desktops from yard sales for next to nothing. Libraries are at this point giving away XP machines in place for newer. Old machines running XP and wiping it out with Arch Linux can be a nice fast running linux machine. Even better if a later system.


RE: C code under linux - nilamo - Nov-07-2016

The newest version of Visual Studio Community has a ton of features, and is almost the same as the Pro version.  I actually use the Community version every day at work.  The old Express versions were mostly trash, stripped down versions of Pro that were barely usable, but Community is the real deal.

There's a pretty rad guy that streams daily his progress at building a video game from scratch in C, and he uses Visual Studio Community as his debugger/compiler (but not his editor... he uses emacs for that.  ...and uses shell scripts for compiling.  ...he's a pretty hardcore guy).  Handmade Hero, for those interested.


RE: C code under linux - Larz60+ - Nov-07-2016

I'm with metluburr (In a LAN)