I have used OpenMP with gcc for writing parallel code. I am now using Visual C++ 2005 and am trying to figure out how to use OpenMP. There is a compiler option in the Properties->C/C++/Language menu but then it complains the library is missing. Is there a 3rd party implementation for OpenMP or am i just configuring Visual C++ incorrectly?
After some research I found out that the OpenMP libs and dlls are not included with Visual C++ 2005 or Visual C++ Express Edition 2008. But with a few workarounds you can get it working.
First you need to download the lib files from microsoft which can be found at the Windows SDK for Windows Server 2008 and .NET framework 3.5. After you download it you need to make sure that either vcomp.lib or vcompd.lib is being linked to your program.
Next you need to have the dll which can be found in the Visual C++ Redistributable Packkage. Then make sure that vcomp90.dll is somewhere in your path.
You also need to have the OpenMP compiler option enabled which can be found in the Properties->C/C++/Language menu of Visual C++.
After that you should be able to use OpenMP just fine.
I think t works out of the box with VC 2005 but I am not sure if they are provided with all versions.
If you jsut attach the
/openmp
option you also have to include the open mp header
#include <omp.h>
This is important because this header will add the manifest to your application which enables it to load the vcomp.dll from the correct system path. So it is normally no longer allowed to copy vcomp.dll or other system dlls beneath your executable but you have to pimp the manifest of your application to load the dll from the correct location. This is none automatically by the omp.h header.
So the minimum code if you do not want to modyfy your manifest on your own is:
#include <omp.h> // has to include this header to build the correct manifest to find vcom.dll or vcompd.dll
int main(int argc, char* argv[])
{
double sum;
#pragma omp parallel for
for(int i = 0; i < 10000; ++i) {
}
return 0;
}