Thanks, thats a great help. That is exactly what was happening.
Question:
What year are you doing now?
Academic year 3
Historic year 4
I changed degrees...
have installed Cygwin on Win7 as well as Eclipse and CDT 6.0
If I want to compile in Eclipse, how would it know to use Cigwyn and compile for Linux? Should eclipse be installed as a Linux IDE?
If the code compiles on Windows with Cygwin, then it will compile EXACTLY like that in Linux, so let's say you have a file open in Eclipse called main.cpp:
Code:
#include <iostream>
using namespace std;
int main()
{
string stackString = "This string is located on the Stack!";
string *heapString = new string("This string is located on the Heap!");
string *pointerToVariableOnTheStack = &stackString;
(*pointerToVariableOnTheStack) = "I've changed stackString!";
delete heapString;
return 0;
}
That code compiles on Cygwin and therefore compiles on Linux, so I have that file open in Eclipse, I click build, build was successful, now I take that file, just like that, main.cpp, copy it on my flash-drive.
Log onto my Linux machine and in the console, go to the directory where main.cpp is located, type:
gcc main.cpp
ls
now run the executable, most likely it'll be:
./main.out
gcc main.cpp compiles the application
ls shows the files in the current directory, the executable will most likely be listed in green. Linux is CASE SENSITIVE. The ./ is so that Linux is aware of the executable files context, otherwise main.out can be located anywhere on the system.
main.out won't run on Windows because it is a Linux binary but it'll most likely run on other versions of Linux.
On Windows that file will compile to main.exe, it will once again only run on MS based OS's like DOS,Windows,etc.
As you can see the .cpp files (IE. the source code) stays EXACTLY the same, only the binary changes, so to be clear, source needs no change, you only recompile in Linux. You don't even need Eclipse to recompile you can simply use the console and a Make file or if you have plenty of energy compile each file on it's own, etc. etc.
You only upload your source to the auto marker so it'll run just like that, just keep in mind, once again, Linux is case sensitive so if you call linkedlist.h then the file name should be linkedlist.h not Linkedlist.h or any other variation.