Visual Studio 2008 OpenMP and LabWindows/CVI 9
NI has announced new version of LabWindows/CVI 9.0 that now supports the use of Visual Studio 2008 (MSVC 9.0) compiler (to create release executables and DLLs within the LabWindows/CVI environment) which also brings the potential support of OpenMP into LabWindows/CVI applications as it had before with Visual Studio 2005 (MSVC 8.0). It is important for me because in my own project I intensively use the OpenMP; and from my knowledge, the integration of Visual Studio compiler is the easiest way to provide OpenMP support into LabWindows/CVI applications.
LabWindows/CVI 9.0 recompiled my project with OpenMP support using Visual Studio 2005 (MSVC 8.0) without any problems; meanwhile, the same compilation failed in case of Visual Studio 2008 (MSVC 9.0). I used /openmp option for Visual Studio C-compiler as usual, I defined _OPENMP macro as the omp.h include statement; so, I did everything to ensure the correct compilation by Visual Studio C-compiler, but LabWindows/CVI 9.0 reported errors and refused to link object files into binary executable.
The investigation uncovered the reason of failure; it was the problem with unresolved symbol "__You_must_link_with_Microsoft_OpenMP_library"; this symbol is undefined also by vcomp90.dll library that caused abuses from LabWindows. Ok, the problem was isolated. The solution became not so obvious.
First, the object code for symbol "__You_must_link_with_Microsoft_OpenMP_library" is included inside vcomp.lib while the vcomp.lib is not static library. It is very strange to mix static code with dynamic, but Microsoft is Microsoft, and it was reason why LabWindows could not link my project. In Visual Studio 2005 (MSVC 8.0) vcomp.lib is only dynamic, and VC 8.0 compiler does not include symbol "__You_must_link_with_Microsoft_OpenMP_library" inside object files; thus, in case of Visual Studio 2005 (MSVC 8.0) LabWindows is happy. Hereby, we need to teach LabWindows to resolve symbol "__You_must_link_with_Microsoft_OpenMP_library". For this, I manually extracted the object code responsible for symbol "__You_must_link_with_Microsoft_OpenMP_library" from vcomp.lib and saved it as unique.obj file. After that, I included this object file unique.obj inside my project and LabWindows/CVI recompiled it successfully.
Second, to extract unique.obj (it contains the object code for symbols __You_must_link_with_Microsoft_OpenMP_library and __You_must_link_with_exactly_one_OpenMP_library) from vcomp.lib I used command:
"lib.exe vcomp.lib /EXTRACT:f:\dd\vctools\openmprt\build\release\objr\i386\unique.obj /OUT:unique.obj"
Thereby, the moral of story is: first, extract unique.obj from vcomp.lib; second, include obtained unique.obj into LabWindows/CVI project that uses the OpenMP; third, the errors with unreferenced, unresolved, undefined symbol "__You_must_link_with_Microsoft_OpenMP_library" will be gone.
©2009 Rosmir - Stepan A. Baranov
$Id: labwindows9.html 449 2009-01-30 18:06:55Z rosmir $