![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Feb 2006
Posts: 154
Rep Power: 3
![]() |
c-unix-ignorance
so i have to write a c code in unix using gcc, now i was wondering if i can write the code in c in a regular windows compiler first, then run it on unix. but i dont know any good compilers for that!
also, if i try to do that, how would system calls like fork() etc would work, coz arent these calls inherent to unix? see, i am totally new to c, but i am assuming it'll be a lot like c++. |
|
|
|
|
|
#2 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
I'm pretty certain that you'll have to compile it using Unix to get it to work on that system. You can write it wherever you want, but the compilation should be done on Unix.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower Last edited by Mjordan2nd; Sep 13th, 2006 at 3:31 PM. |
|
|
|
|
|
#3 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
MJ is correct. Despite our talk about 'portable' code, code as it runs isn't truly portable. It must comply with both the platform (uP type and other hardware design) and the OS, which usually deals with these things in different ways. Portability usually refers to the source code, and not all source is portable. No reason you can't write it in Windows, it's just text, but you probably can't fully compile it correctly. Certainly not if you use Unix things that aren't available under Windows.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Aug 2006
Location: Alabama
Posts: 26
Rep Power: 0
![]() |
It is very possible to build a compiler to compile code for one machine on another. This is the way, however, I'll warn you. . . it isn't easy.
|
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Feb 2006
Posts: 154
Rep Power: 3
![]() |
i agree with you all, thats what i was thinking.
but just for the heck of it and future assignments, may I dare ask the name of a good windows c compiler? I could google it, but your valuable experience will help me! |
|
|
|
|
|
#6 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
The Mingw port of gcc works. I like the Code::Blocks IDE, although another great alternative is Dev-C++.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower |
|
|
|
|
|
#7 |
|
Expert Programmer
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 550
Rep Power: 4
![]() |
Dev-C++ uses Mingw port of GCC as its compiler. I suggest Dev-C++.
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4 |
|
|
|
|
|
#8 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Well, Kennedy, cross-compilers are used all the time in embedded work, but I don't think that was what the OP was seeking....
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#9 |
|
Programmer
|
If you want to target windows and unix, you should IMHO compile with gcc all the way or at least regularly test with gcc when developing on windows. If you want to write for unix on windows, using cygwin might work for testing. If you use Code::Blocks, you can just as well scratch windows for writing and leave it for testing.
|
|
|
|
|
|
#10 |
|
Newbie
Join Date: Oct 2006
Posts: 16
Rep Power: 0
![]() |
I suggest using cygwin to write your c on the windows box. Most likely, all you would need to do is recompile on the unix box.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Unix commands compatible with Windows? | titaniumdecoy | Bash / Shell Scripting | 7 | Oct 5th, 2006 7:25 AM |
| Best Linux or Unix Desktop? | Prm753 | Coder's Corner Lounge | 23 | Apr 8th, 2006 10:17 AM |
| Importing from DLL's on Unix | Kaja Fumei | Existing Project Development | 5 | Jan 9th, 2006 6:35 PM |
| How to run Jave Applets on Unix? | sham | Other Programming Languages | 5 | Apr 30th, 2005 6:28 PM |
| Email a txt file using C in UNIX? | willz99ta | C | 6 | Apr 5th, 2005 5:27 PM |