Join 136,450 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,113 people online right now. Registration is fast and FREE... Join Now!
For reasons related to a task at hand, I must educate myself in C. Not C++, not C#, just C. This is my second language, my first being FORTRAN about 20 years ago. Point being, I'm functionally illiterate as a coder. That will change.
Re compilation, I am forced to use one of the following three. Given the choice between these compilers: 1. cygwin, 2. coLinux, or 3. VMWare which of the above is least likely to get me into difficulty and easiest to conceptualize, compile and link plain ol' vanilla C language?
I don't know what coLinux is, but Cygwin & VMware are not compilers. Cygwin is a Shell that will run on a Windows interface, & allow you to create & run Linux binaries, as well as install Linux & Unix utilities. VMWare allows you to emulate hardware in a segment of memory space, so you can boot other various operating systems. In fact right now I'm running Windows 2000 in a VMWare client.
So I'm not sure how to answer your questions, as those 2 answers are not valid to your question.
Thanks for your reply. I am beginning to understand your point. The sum total of my instruction is as follows:
QUOTE
Set Up Your Environment You need a cross-compiler and linker to build the code. Pick one of these:
Linux (or any other unix-like OS): Building the cross compiler. This describes how to build and install gcc for your target. Windows: Setup a cygwin Rockbox development environment OR Setup a coLinux development environment OR Setup a VMWare development environment.
Apparently I mistook the meaning of the phrase, "cross-compiler". Given your illustrative point, do I need to educate myself as to the difference between cross-compiler and compiler? As I feared, I'm digging a hole here, but that was inevitable. Any advice other than to stop digging?
This post has been edited by LowWaterMatk: 30 Jul, 2008 - 01:06 AM
When you cross compile you are simply compiling the code for architecture that you will move the executable to later.
A good example would be if you had a Linux/Unix development machine that you write code on, but you have Windows Servers or Workstations in the field. So you are working on a project that you will roll out to hundreds of machines, however you are running Linux/Unix, so you can't debug/troubleshoot the binary executable once it's compiled. So you cross compile it, meaning the compiler will create the executable for the desired platform (in this situation Windows) & not for the machine you are compiling it on (Linux/Unix).
In this situation, from my experience, I would suggest avoiding Cygwin, since it's simply a shell & not an environment. While it offers many similarities including the look & feel of Linux system, it is by no means a good testing environment. I would say (without knowing what coLinux is) to go with VMware, since it emulates booting.
In simple terms (so that I understand what I'm typing) a compiler translates my code into a unit of assembly language. The linker links these units into executable blocks. Please correct me if this is fundamentally wrong.
I am teaching myself and doing this project on Windows XP. If I take your advice and use VMWare cross-compiler, do I need a separate, independent compiler to use within that environment or is it included within the VMWare environment? The previous hyperlink is a Wiki site that encapsulates all I know about VMWare at this point.
Take Care.
This post has been edited by LowWaterMatk: 30 Jul, 2008 - 01:30 AM
As an extension of the above, would it be sensible for me to use a different compiler to teach myself compilation/linkage and adopt that to, say, VMWare once I am semi-functional?
If so, would you take a second to look over this list of C/C++ compilers and recommend one suitable for a guy like me in the throes of learning to program?
FWIW, in addition to Alice.exe and a couple of online C tutorials and historical documents, I'm embarking on "Absolute Beginner's Guide to C" from Amazon.
My educational history is significant for an M.D., special post-doc certification in Physics and Statistics and college scholarships in logic and linguistics/etymology. Save for FORTRAN, I forgot to learn programming and I forgot to have children.
Am I on the path here?
This post has been edited by LowWaterMatk: 30 Jul, 2008 - 02:04 AM
One common example of "cross-compilation" on Windows is building a program with a MinGW toolset compiler in a Cygwin environment. This is the reason why mingw comes with binaries named like "mingw32-gcc.exe".
QUOTE
which of the above is least likely to get me into difficulty and easiest to conceptualize, compile and link plain ol' vanilla C language?
If this is all you want to do, then there is no real need for cross-compilation. You should be able to compile a program in it's native environment with a set of native build tools (i.e. MinGW, gcc that comes with Cygwin, or gcc on Linux). The nice thing about Cygwin is that it gives you access to some standard Unix/Linux system calls (or at least, wrappers) just in case anything that you're doing is actually platform specific.
If you actually want to compile a program for use on Linux/Unix, it's easiest to compile it on those platform if possible. Cross compilation can be a pain, and it's not usually worth the effort unless one is trying to build binaries for a range of operating systems, with one of them being the one in which the program is being built on. This happens more on projects that support multiple operating systems, such as supporting both Linux and Windows, so that any binary distributions can be built using one operating system.
It would probably be nice to know more about what you are trying to accomplish other than just "learn C".
What I know: You are going to use a cross compiler, you are working in C (not C++).
This sounds like you are preparing to do some embedded work. I.e. you are compiling code to run on a PIC or other controller card.
It also sounds like your PIC comes with a cross-compiler that runs on Linux. (In this instance a "cross-compiler" is a compiler that runs on one CPU (platform) and generates code for another CPU (platform). So you cross compile your code on a PC generating instructions for the PIC).
FYI -- A Compiler generally compiles code from a high level language to machine code (it may or may not produce assembly language code in the process -- generally only if you ask it to). Now once it generates this code is stores all the information it generated into what is called an "object file". That is "A C compiler takes in C source code and generates object files".
Next step is the linker. The linker takes in the object files and "Links" it to code found in libraries (and other object files) and writes out the final file format (usually an executable file). That is "Then a linker links the object files and libraries to produce an executable".
Object files are often produces using both compilers and assemblers and *may* actually be produced by compilers for different languages. They contain "snippets" of code, as well as information on what symbols (variables and function names) are used both from this code, and from code that may be in other object files or libraries (libraries are just a bunch of object files packaged together).
It would probably be nice to know more about what you are trying to accomplish other than just "learn C".
NickDMax, I didn't mean to be cryptic. I volunteered to help on a cross-platform thing called RockBox. RockBox is an open source firmware replacement for what comes with your iPod type digital audio player. It's ported for quite a few models and I'm helping out (just for fun and self-edification) with the Cowon iAudio 7, the player I happen to use.
Why? I want to learn C and the firmware on Cowon's iAudio 7 sucks, so I have a twin opportunity.
QUOTE
You should be able to compile a program in it's native environment with a set of native build tools (i.e. MinGW, gcc that comes with Cygwin, or gcc on Linux).
PerfectlyInsane, Is this true as well for VMWare and/or coLinux environments? Do they as well come complete with tools to compile/link inside the given environment? I have the choice of all three and frankly want to use the one that is simplest to understand and become competent with (if they vary in complexity to the coder). I have enough to learn as it is with this little project.
At the risk of repeating myself, would y'all be so kind as to review my last post and comment on my plans to date.
I am having trouble seeing what you would need with VMWare or Cygwin for this project.
Did you get any documentation when you agreed to be apart of this project? I would think it would have some sort of a firmware emulator, that's how homebrew game development works.
Unless the compiler is as previously pointed out, going to run in a MinGW environment. Either way, I would think it would run on Windows. Do you have a URL with these requirements?