Code and Executables

All the code can be downloaded as a single .zip file, or .tar file, as you prefer :

sg_code.zip

sg_code.tar [ To untar the (uncompressed) tar file, use tar -xvf sg_code.tar ]

To compile the code I used the Eclipse editor on Windows, and I think that editors like this are the best option for writing and compiling small projects.
More importantly, I used MinGW compiler, and linked 3 libraries : opengl32, glu32 and glut32, which are all necessary for rendering. Some files are needed to be added to the MinGW directory, and can be found for example in this tutorial, which is also avaliable at the References section. In Eclipse, adding the libraries is done using the GUI, but if one is interested in compiling via command line, it is best to use the followin commands.

On Windows :

g++ -c *.cpp
g++ -static-libgcc -static-libstdc++ *.o -o sg.exe -lopengl32 -lglu32 -lglut32


The 2 "static..." flags are important for executing the file in other machines that do not have MinGW installed.
Anyhow, one must have glut32.dll either in the c:\windows\system32 folder, or in the same folder as the resulting .exe file. There supposed to be a way to link glut32 library statically too, but it's not such a good thing to do, since the library upgrades from time to time, and also, what I have tried didn't work.

On Linux, the same code will comile, except for one command that is Windows specific and thus should be removed, named FreeConsole(), that closes the textual window before opening the graphic one, and is called only once in the file SGinit.cpp. A good idea will be to also execute the command dos2unix *.* inside the source folder before compiling, but it seldom makes any difference. Graphic libraries flags are also a bit different, so the commands take the form :

g++ -c *.cpp
g++ -static-libgcc *.o -o sg.ex -lGL -lGLU -lglut


Also, of course, the .dll is Windows specific, and is not used in Linux. A tutorial for OpenGL in Linux is linked from the References section.

Anyway, the executable hereinafter was compiled in windows 7 64bit and therfore will not necessarily work even on other versions of Windows. As mentioned above, if you don't have glut.dll in your system, download it and place it in the same folder as the .exe file before running the program.

SternGerlachSimulation.exe
glut32.dll

If you encounter any problem with the .dll file, try replacing it with one that suits your system from the internet.

For your convenience, there is also an executable for Linux, which doesn't need anything but itself :

SternGerlachSimulationLinux.ex




Feel free to nevigate between the different sections of the website through the menu in the left side of the screen.
If you don't see it, please start again at the Project Index Page