Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C code under linux
#1
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
Reply
#2
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?
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply
#3
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.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
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]
Reply
#5
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).
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#6
(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.
Recommended Tutorials:
Reply
#7
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
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#8
(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.
Recommended Tutorials:
Reply
#9
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.
Reply
#10
I'm with metluburr (In a LAN)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Installing the Visual Studio Code on Linux - how to do that!? apollo 4 3,261 Oct-05-2019, 09:48 PM
Last Post: apollo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020