Question

I'm trying to compile The Point Cloud Library (PCL) from sources in Visual Studio 2013 (with v120 toolset and MSCL18 of course) because I need this library for a VS2013 project. It turned out a tricky task, though.

  • On one hand, PCL sources aren't compiled in VS2013 because of breaking changes in new C++ standard templates in VS2013
  • On the other hand, when compiled in VS2012, PCL DLLs have their own CRT and even simplest PCL related code crashes

For example, in VS2013 this code snippet:

pcl::console::print_highlight(stdout, "Begin");

throws an exception at "EnterCriticalSection(&(((_FILEX *) pf)->lock));", which is described in this question, due to different CRTs in PCL DLLs and my EXE.

As a last resort I'm trying to change C++ frontend from MSCL18 to MSCL17 in order to receive object or assembler files and link them on the further build step with the CL18 linker. I didn't find a good way to do it yet.

So my question is if anybody may share their experience in such a two-step compilation, how to substitute the previous compiler version frontend or what may be another solution in this problem?

Was it helpful?

Solution

I tried a few approaches to compile this 3rd party library without changing the library source code. The one, which turned out to work OK, was substituting VS2013 C++ front-end (toolset v120, MSCL18) with the previous one (VS2012, toolset v110, MSCL17) for some files, which don't go through VS2013, and afterwards using resulting OBJ files in further compilation in VS2013.

The James McNellis's remarks did a great job as they helped me better understand and carefully fix compilation errors in VS2013 STL stream and string objects and come out with my subset of VS2013 STL which compiled fine with VS2012 native toolset.

Actually, I created a Custom Build Tool (C++ Project -> Properties) for different configuration and platforms:

Debug|Win32
$(ComSpec) /c ""$(ProgramFiles)\Microsoft Visual Studio 11.0\Common7\Tools\vsvars32.bat" x86   && cl.exe /c %(FullPath) /IC:\Src\PCLCompilation\local_stl /IC:/Src/PCLCompilation/boost_1_55_0 /IC:/Src/PCLCompilation/eigen/include /I"C:/Src/PCLCompilation/flann-1.8.4.v120/include" /I"$(SolutionDir)include" /I"C:/Src/PCLCompilation/pcl-master/common/include" /I"C:/Src/PCLCompilation/pcl-master/octree/include" /I"C:/Src/PCLCompilation/pcl-master/io/include" /I"C:/Src/PCLCompilation/pcl-master/filters/include" /nologo /W3 /WX- /MP4 /Od /Ob0 /Oy- /Zi /D_MSC_VER=1800 /D WIN32 /D _WINDOWS /D _WINDLL /D _MBCS /D _DEBUG /D BOOST_DISABLE_ASSERTS /D EIGEN_NO_DEBUG /D BOOST_ALL_NO_LIB /D _SCL_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_WARNINGS /D NOMINMAX /D BOOST_LIB_DIAGNOSTIC /D EIGEN_USE_NEW_STDVECTOR /D EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET /D FLANN_STATIC /D CMAKE_INTDIR=$(Configuration) /D PCLAPI_EXPORTS /Gm- /EHsc /RTC1 /MDd /GS /arch:SSE2 /fp:precise /Zc:wchar_t /Zc:forScope /GR /openmp /Fo"$(IntDir)\" /Fd"$(TargetDir)$(TargetName).pdb" /Gd /TP /wd4800 /wd4521 /wd4251 /wd4275 /wd4305 /wd4355 /wd4800 /wd4521 /wd4251 /wd4275 /wd4305 /wd4355 /analyze- /errorReport:prompt /bigobj"
Debug|x64
$(ComSpec) /c ""$(ProgramFiles)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" amd64           && cl.exe /c %(FullPath) /IC:\Src\PCLCompilation\local_stl /IC:/Src/PCLCompilation/boost_1_55_0 /IC:/Src/PCLCompilation/eigen/include /I"C:/Src/PCLCompilation/flann-1.8.4.v120/include" /I"$(SolutionDir)include" /I"C:/Src/PCLCompilation/pcl-master/common/include" /I"C:/Src/PCLCompilation/pcl-master/octree/include" /I"C:/Src/PCLCompilation/pcl-master/io/include" /I"C:/Src/PCLCompilation/pcl-master/filters/include" /nologo /W3 /WX- /MP4 /Od /Ob0      /Zi /D_MSC_VER=1800 /D WIN32 /D _WINDOWS /D _WINDLL /D _MBCS /D _DEBUG /D BOOST_DISABLE_ASSERTS /D EIGEN_NO_DEBUG /D BOOST_ALL_NO_LIB /D _SCL_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_WARNINGS /D NOMINMAX /D BOOST_LIB_DIAGNOSTIC /D EIGEN_USE_NEW_STDVECTOR /D EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET /D FLANN_STATIC /D CMAKE_INTDIR=$(Configuration) /D PCLAPI_EXPORTS /Gm- /EHsc /RTC1 /MDd /GS /arch:SSE2 /fp:precise /Zc:wchar_t /Zc:forScope /GR /openmp /Fo"$(IntDir)\" /Fd"$(TargetDir)$(TargetName).pdb" /Gd /TP /wd4800 /wd4521 /wd4251 /wd4275 /wd4305 /wd4355                                                           /errorReport:prompt /bigobj"

Release|Win32
$(ComSpec) /c ""$(ProgramFiles)\Microsoft Visual Studio 11.0\Common7\Tools\vsvars32.bat" x86   && cl.exe /c %(FullPath) /IC:\Src\PCLCompilation\local_stl /IC:/Src/PCLCompilation/boost_1_55_0 /IC:/Src/PCLCompilation/eigen/include /I"C:/Src/PCLCompilation/flann-1.8.4.v120/include" /I"$(SolutionDir)include" /I"C:/Src/PCLCompilation/pcl-master/common/include" /I"C:/Src/PCLCompilation/pcl-master/octree/include" /I"C:/Src/PCLCompilation/pcl-master/io/include" /I"C:/Src/PCLCompilation/pcl-master/filters/include" /nologo /W3 /WX- /MP4 /O2 /Ob2 /Oy- /GL /D_MSC_VER=1800 /D WIN32 /D _WINDOWS /D NDEBUG /D BOOST_DISABLE_ASSERTS /D EIGEN_NO_DEBUG /D BOOST_ALL_NO_LIB /D _SCL_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_WARNINGS /D NOMINMAX /D BOOST_LIB_DIAGNOSTIC /D EIGEN_USE_NEW_STDVECTOR /D EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET /D FLANN_STATIC /D CMAKE_INTDIR=$(Configuration) /D PCLAPI_EXPORTS /D _WINDLL /D _MBCS /Gm- /EHsc /MD /GS /arch:AVX /fp:precise /Zc:wchar_t /Zc:forScope /GR /openmp /Fo"$(IntDir)\" /Fd"$(TargetDir)$(TargetName).pdb" /Gd /TP /wd4800 /wd4521 /wd4251 /wd4275 /wd4305 /wd4355 /analyze- /errorReport:prompt  /bigobj"
Release|x64
$(ComSpec) /c ""$(ProgramFiles)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" amd64           && cl.exe /c %(FullPath) /IC:\Src\PCLCompilation\local_stl /IC:/Src/PCLCompilation/boost_1_55_0 /IC:/Src/PCLCompilation/eigen/include /I"C:/Src/PCLCompilation/flann-1.8.4.v120/include" /I"$(SolutionDir)include" /I"C:/Src/PCLCompilation/pcl-master/common/include" /I"C:/Src/PCLCompilation/pcl-master/octree/include" /I"C:/Src/PCLCompilation/pcl-master/io/include" /I"C:/Src/PCLCompilation/pcl-master/filters/include" /nologo /W3 /WX- /MP4 /O2 /Ob2      /GL /D_MSC_VER=1800 /D WIN32 /D _WINDOWS /D NDEBUG /D BOOST_DISABLE_ASSERTS /D EIGEN_NO_DEBUG /D BOOST_ALL_NO_LIB /D _SCL_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_WARNINGS /D NOMINMAX /D BOOST_LIB_DIAGNOSTIC /D EIGEN_USE_NEW_STDVECTOR /D EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET /D FLANN_STATIC /D CMAKE_INTDIR=$(Configuration) /D PCLAPI_EXPORTS /D _WINDLL /D _MBCS /Gm- /EHsc /MD /GS /arch:AVX /fp:precise /Zc:wchar_t /Zc:forScope /GR /openmp /Fo"$(IntDir)\" /Fd"$(TargetDir)$(TargetName).pdb" /Gd /TP /wd4800 /wd4521 /wd4251 /wd4275 /wd4305 /wd4355 /errorReport:prompt /bigobj"

With the following Outputs:

$(IntDir)%(Filename).obj

I changed the tool for uncompilable files to this Custom Build Tool (C++ file -> Properties -> General -> Item Type -> Custom Build Tool) and it nicely went along with the whole compilation process. The string object binary representation looked identical, the resulting binary DLLs worked no problem and all the system passed all our QA tests. This small hack helped us to move all our system to VS2013, which was delayed because of a few files in a library, we were dependent of.

March 30 UPDATE: We didn't find any error with this approach for a few month on several dev and test boxes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top