Installing C++CSP2

Installing on Linux

Boost

The first step is to install the boost libraries. There are two easy ways to do this, and one harder way.

The first easy way is to use your package manager to install boost. If there are two versions available (often boost and boost-devel), you want the development version (boost-devel).

The second easy way is to download the latest boost zip/tar from http://www.boost.org/ (at the time of writing, follow the Download link on the top right of the page - then on the SourceForge page, select simply "boost"). Inside this zip (at the time of writing) is a versioned boost directory (e.g. boost_1_33_1). Inside that is a boost directory. Copy this boost directory to somewhere on your include path (e.g. /usr/include). That's finished - C++CSP2 only uses parts of boost that are entirely contained within the header files, so there is no need to compile the full libraries.

The harder way is to do a proper full install of boost. To do so, follow the instructions on the boost website. At the time of writing, the relevant page is here.

C++CSP2

Once boost is installed, download the C++CSP2 tar, and unpack it into a temporary location. Then perform the usual autotools steps - run "./configure" followed by "make". This will compile the library (for which you will need, obviously, a C++ compiler such as the GCC C++ compiler). It should not give any warnings or errors. If you do receive an error, please contact me so that I can help to resolve it. Although C++CSP2 compiles correctly on my machine, different versions of Linux or of GCC could cause some warnings or errors.

After make has completed successfully, it is wise to run "make test". This will compile and run the C++CSP2 in-built test suite. You should see a lot of green, and no red! The summary at the bottom shows how many tests have passed and failed. None should fail. If you have any failures, please contact me so that we can resolve the problem. You may also be interested in running "make testperf" which will run the normal tests and a group of performance tests. These tests may take a minute or so to complete, but they may be of interest to you (although currently their meaning is not well-documented).

After you have tested that the library is working, the command "make install" will then install the files to the appropriate directory (you may want to run that as root or using sudo, to install for all users).

Then you will be ready to start writing a C++CSP2 program. Please read the Guide for a brief guide to getting started.

Installing Boost on Windows

Whichever method you use to install C++CSP2 on Windows, you will still need to install the Boost libraries first, if you do not already have them on your system.

The easy way is to download the latest boost zip/tar from http://www.boost.org/ (at the time of writing, follow the Download link on the top right of the page - then on the SourceForge page, select simply "boost"). Inside this zip (at the time of writing) is a versioned boost directory (e.g. boost_1_33_1). Inside that is a boost directory. Copy this boost directory to somewhere already on your include path or a new directory that you will add to your include path. For details on adding a directory to your include path, see the next section. That's finished - C++CSP2 only uses parts of boost that are entirely contained within the header files, so there is no need to compile the full libraries.

The harder way is to do a proper full install of boost. To do so, follow the instructions on the boost website. At the time of writing, the relevant page is here. If you are going to use Visual C++ for C++CSP2, you will need to use Visual C++ to compile the boost library, and similarly if you want to use MinGW, you will need to compile boost using MinGW.

Installing on Windows (Visual C++, using pre-compiled library)

Using the given pre-compiled libraries is by far the easiest way for Visual C++ users to install C++CSP2. You will still need to install boost (see the section on installing boost on Windows. If you download the zip file from the main website, you should find inside the header files (in the "include" directory) and two .lib files (in the "lib" directory).

Copy the cppcsp directory from inside the include directory to somewhere that is in your include path, and put the two lib files (or just one, if you only want x86 or only want x64) somewhere in your library path. If you want to put it somewhere new - for example, you unzip the whole zip to c: - then go to (in VS2005):

That is all you need to do to have installed C++CSP2. In each new project, you will want to include <cppcsp/cppcsp.h> and link with either cppcsp2-x86.lib or cppcsp2-x64.lib, depending on whether you are compiling a 32-bit or 64-bit program. If you don't know which you are compiling, you are almost certainly compiling a 32-bit program (link with cppcsp2-x86.lib). To add a library to link with (in VS2005):

Installing on Windows (Visual C++, re-compiling the library)

If you do want to install C++CSP2 by recompiling the code yourself under Visual C++, this section describes how to set up the project. Installing without re-compiling (see the previous section) is much easier, but if you really want to compile it yourself for some reason, here's how to do it (instructions are for VS2005).

In the source distribution on the C++CSP2 website you should find a zip with two directories in - "src" and "test". Unzip that to somewhere where the files can reside permanently (e.g. "c:\work\cppcsp2").

In Visual Studio, select File->New->Project... A window will appear. On the left hand side, select Visual C++ and then the Win32 sub-item. On the right, select "Win32 Project". Name the project as you please (I'm going to assume you name it "C++CSP2") and put in whatever directory you want. You will probably want to create a new solution for it, but it is up to you.

Click OK, and a Wizard will appear. Click Next to get past the first information screen. Select "Static Library" from the list of options on the next screen, and make sure that "Precompiled header" is NOT ticked. Then click Finish. You will now have an empty C++CSP2 project. Go to the Project menu and select "Add Existing Item...". Navigate to the source directory (e.g. "c:\work\cppcsp2\src") and add all the items inside it. Then "Add Existing Item..." again and select everything inside the src/common directory (e.g. "c:\work\cppcsp2\src\common").

You should now have a project in the "Solution Explorer" window, containing files such as run.h, process.h, alt.h, alt.cpp, barrier_bucket.h. You should not have files like alt_test.cpp or barrier_test.cpp. Go to the Project menu and select "C++CSP2 Properties" (the first word will be the name of your project). You should now have a window of properties displayed. On the left-hand bar, under "Configuration Properties", then under "C/C++" click on Preprocessor. Look at the (semi-colon-separated) list of "Preprocessor Definitions". If you are running on 32-bit Windows XP (if you don't know, then you're almostly certainly running 32-bit, even on a 64-bit CPU) "WIN32" should be in the list. If it is not, add it. If you are running on 64-bit Windows XP, make sure that both WIN32 and WIN64 are in the list.

Under "Configuration Properties", "C/C++", "General" you will see "Additional Include Directories". You should add the boost directory here if you have not set it as a system-wide include directory. If you look in the boost headers, you will find a "boost" directory with "version.hpp" and many other headers in it. On my system this is "C:\boost\include\boost-1_33_1\boost". You do not want to set this directory in your include path - instead use its parent directory, e.g. "C:\boost\include\boost-1_33_1". This is because everything includes "boost/blah.hpp", so it is not the boost directory you want to add, but its parent. Also under "Configuration Properties", "C/C++", "General", set "Detect 64-bit portability warnings" to "No". There are no portability issues, but Visual Studio spuriously detects some.

Under "Configuration Properties", "C/C++", "Precompiled Headers", make sure the "Create/Use Precompiled Headers" option is set to "Not Using Precompiled Headers". Under "Configuration Properties", "C/C++", "Code Generation", for "Runtime Library" select "Multi-Threaded DLL" or "Multi-Threaded Debug DLL" (the former in the Release configuration, the latter in the Debug configuration).

All the above properties will need to be changed for both the Debug and the Release configurations. Hopefully, if you are familiar with Visual Studio you should be familiar with this.

If you then Build Solution, the C++CSP2 library should build with many warnings but no errors. If you get any errors, please email them to me so I can help fix them.

Now you should have the C++CSP2 library ready to be used. A good idea now is to also build the C++CSP test program, to check that the library is working properly on your machine. This can be done as follows.

Once more select "File->New->"Project..." Select "Win32 Project" again (just as for the first project). Call the project something different, such as "C++CSP2-Test" and place the project file where you like. Select "Add to Solution" (NOT "Create new solution"). Then click OK. On the Wizard that comes up, click Next, then Select "Windows application" and tick "Empty Project".

Right click on the C++CSP2-Test project in the Solution Explorer and select "Add" then "Existing Item...". Navigate to the test directory (e.g. "c:\work\cppcsp2\test") and add everything in there EXCEPT for the "test_perf.cpp" file.

Right click on the C++CSP2-Test project in the Solution Explorer, and select Properties. Under "Common Properties" select "References". Select "Add New Reference..." in the middle of the window. A list should appear that only contains your C++CSP2 project. Select this, and press OK.

Under "Configuration Properties", "C/C++", "General" you will see "Additional Include Directories". Fill this in with the directory where your C++CSP2 source files live. Using the earlier example, this would be "c:\work\cppcsp2\src". Also add the directory for the test sources (e.g. "c:\work\cppcsp2\test") You may also need to add the boost libraries to this setting (all entries separated by a semi-colon), for example "C:\boost\include\boost-1_33_1".

Just as in the C++CSP2 project: On the left-hand bar, under "Configuration Properties", then under "C/C++" click on Preprocessor. Look at the (semi-colon-separated) list of "Preprocessor Definitions". If you are running on 32-bit Windows XP (if you don't know, then you're almostly certainly running 32-bit, even on a 64-bit CPU) "WIN32" should be in the list. If it is not, add it. If you are running on 64-bit Windows XP, make sure that both WIN32 and WIN64 are in the list.

Just as in the C++CSP2 project: Under "Configuration Properties", "C/C++", "Precompiled Headers", make sure the "Create/Use Precompiled Headers" option is set to "Not Using Precompiled Headers". Under "Configuration Properties", "C/C++", "Code Generation", for "Runtime Library" select "Multi-Threaded DLL" or "Multi-Threaded Debug DLL" (the former in the Release configuration, the latter in the Debug configuration).

Finally, look under "Configuration Properties", "Linker", "Advanced". If you are running 32-bit Windows, the "Target Machine" setting should be "MachineX86". If you are running 64-bit Windows, the setting should be "MachineX64". Note that the setting is related (as far as I know) to the Windows version you are using, not to the actual underlying CPU.

If you now Build Solution, the C++CSP2-Test (or whatever the name of your project is) EXE should be built without errors (but with some warnings). You can then run the EXE (pressing F5 should do it). The EXE should run invisibly in the background for about 2-3 seconds. Then a webpage should open up in your default browser, showing the results. All the tests should pass, and at the time of writing there should be 151 of them. If any fail, or if the program does not finish within about 10 seconds, something has gone wrong! Email me the list of failed tests if possible.

If the compilation fails complaining about a redefined main function, you probably included "test_perf.cpp" in your project by accident. Remove this file and re-build.

Installing on Windows using MinGW/MSYS or Cygwin

Installing using MinGW/MSYS or Cygwin should be the same process as installing under Linux, except that you have less options on how to install boost (no package manager!) - see the Installing Boost on Windows section.
Generated on Mon Aug 20 12:24:28 2007 for C++CSP2 by  doxygen 1.4.7