Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check to prevent compilation in Debug on Windows with conda-forge dependencies #1622

Merged
merged 1 commit into from
Mar 25, 2024

Conversation

traversaro
Copy link
Member

@traversaro traversaro commented Mar 25, 2024

When compiling on Windows with conda-forge dependencies, it is not supported compiling in Debug. The problem is that if a users try to compile in Debug, a really difficult to interpret error occurs, something like:

FAILED: bin/idjl_camera_model.dll lib/idjl_camera_model.lib
cmd.exe /C "cmd.exe /C "C:\Users\straversaro\AppData\Local\miniforge3\envs\idjlenv\Library\bin\cmake.exe -E __create_def C:\src\idjl-software\build\cxx\libraries\idjl-camera-model\CMakeFiles\idjl_camera_model.dir\.\exports.def C:\src\idjl-software\build\cxx\libraries\idjl-camera-model\CMakeFiles\idjl_camera_model.dir\.\exports.def.objs && cd C:\src\idjl-software\build" && C:\Users\straversaro\AppData\Local\miniforge3\envs\idjlenv\Library\bin\cmake.exe -E vs_link_dll --intdir=cxx\libraries\idjl-camera-model\CMakeFiles\idjl_camera_model.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests  -- C:\PROGRA~2\MICROS~4\2019\BUILDT~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\idjl_camera_model.rsp  /out:bin\idjl_camera_model.dll /implib:lib\idjl_camera_model.lib /pdb:bin\idjl_camera_model.pdb /dll /version:0.0 /machine:x64 /debug /INCREMENTAL  /DEF:cxx\libraries\idjl-camera-model\CMakeFiles\idjl_camera_model.dir\.\exports.def  && cd ."
LINK Pass 1: command "C:\PROGRA~2\MICROS~4\2019\BUILDT~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\idjl_camera_model.rsp /out:bin\idjl_camera_model.dll /implib:lib\idjl_camera_model.lib /pdb:bin\idjl_camera_model.pdb /dll /version:0.0 /machine:x64 /debug /INCREMENTAL /DEF:cxx\libraries\idjl-camera-model\CMakeFiles\idjl_camera_model.dir\.\exports.def /MANIFEST /MANIFESTFILE:cxx\libraries\idjl-camera-model\CMakeFiles\idjl_camera_model.dir/intermediate.manifest cxx\libraries\idjl-camera-model\CMakeFiles\idjl_camera_model.dir/manifest.res" failed (exit code 1120) with the following output:
LINK : warning LNK4044: unrecognized option '/lpthreads'; ignored
   Creating library lib\idjl_camera_model.lib and object lib\idjl_camera_model.exp
idjl_camera_model.cpp.obj : error LNK2019: unresolved external symbol "public: __cdecl cv::debug_build_guard::_InputArray::_InputArray(class cv::MatExpr const &)" (??0_InputArray@debug_build_guard@cv@@QEAA@AEBVMatExpr@2@@Z) referenced in function "public: __cdecl IDJL::CameraModel::CameraModel(class cv::Size_<int>,float,float,float,float,class cv::debug_build_guard::_InputArray const &)" (??0CameraModel@IDJL@@QEAA@V?$Size_@H@cv@@MMMMAEBV_InputArray@debug_build_guard@3@@Z)
idjl_camera_model.cpp.obj : error LNK2019: unresolved external symbol "public: class cv::Mat __cdecl cv::debug_build_guard::_InputArray::getMat_(int)const " (?getMat_@_InputArray@debug_build_guard@cv@@QEBA?AVMat@3@H@Z) referenced in function "public: class cv::Mat __cdecl cv::debug_build_guard::_InputArray::getMat(int)const " (?getMat@_InputArray@debug_build_guard@cv@@QEBA?AVMat@3@H@Z)
idjl_camera_model.cpp.obj : error LNK2019: unresolved external symbol "public: enum cv::debug_build_guard::_InputArray::KindFlag __cdecl cv::debug_build_guard::_InputArray::kind(void)const " (?kind@_InputArray@debug_build_guard@cv@@QEBA?AW4KindFlag@123@XZ) referenced in function "public: class cv::Mat __cdecl cv::debug_build_guard::_InputArray::getMat(int)const " (?getMat@_InputArray@debug_build_guard@cv@@QEBA?AVMat@3@H@Z)
idjl_camera_model.cpp.obj : error LNK2019: unresolved external symbol "public: int __cdecl cv::debug_build_guard::_InputArray::cols(int)const " (?cols@_InputArray@debug_build_guard@cv@@QEBAHH@Z) referenced in function "public: void __cdecl IDJL::CameraModel::setMatrix(class cv::debug_build_guard::_InputArray const &)" (?setMatrix@CameraModel@IDJL@@QEAAXAEBV_InputArray@debug_build_guard@cv@@@Z)
idjl_camera_model.cpp.obj : error LNK2019: unresolved external symbol "public: int __cdecl cv::debug_build_guard::_InputArray::rows(int)const " (?rows@_InputArray@debug_build_guard@cv@@QEBAHH@Z) referenced in function "public: void __cdecl IDJL::CameraModel::setMatrix(class cv::debug_build_guard::_InputArray const &)" (?setMatrix@CameraModel@IDJL@@QEAAXAEBV_InputArray@debug_build_guard@cv@@@Z)
idjl_camera_model.cpp.obj : error LNK2019: unresolved external symbol "public: class cv::Size_<int> __cdecl cv::debug_build_guard::_InputArray::size(int)const " (?size@_InputArray@debug_build_guard@cv@@QEBA?AV?$Size_@H@3@H@Z) referenced in function "public: class cv::Point_<float> __cdecl IDJL::CameraModel::project(class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_InputArray const &)const " (?project@CameraModel@IDJL@@QEBA?AV?$Point_@M@cv@@AEBV_InputArray@debug_build_guard@4@0@Z)
idjl_camera_model.cpp.obj : error LNK2019: unresolved external symbol "public: int __cdecl cv::debug_build_guard::_InputArray::type(int)const " (?type@_InputArray@debug_build_guard@cv@@QEBAHH@Z) referenced in function "public: void __cdecl IDJL::CameraModel::correct_points(class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_OutputArray const &)const " (?correct_points@CameraModel@IDJL@@QEBAXAEBV_InputArray@debug_build_guard@cv@@AEBV_OutputArray@45@@Z)
idjl_camera_model.cpp.obj : error LNK2019: unresolved external symbol "public: bool __cdecl cv::debug_build_guard::_InputArray::empty(void)const " (?empty@_InputArray@debug_build_guard@cv@@QEBA_NXZ) referenced in function "public: __cdecl IDJL::CameraModel::CameraModel(class cv::Size_<int>,float,float,float,float,class cv::debug_build_guard::_InputArray const &)" (??0CameraModel@IDJL@@QEAA@V?$Size_@H@cv@@MMMMAEBV_InputArray@debug_build_guard@3@@Z)
idjl_camera_model.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl cv::debug_build_guard::_InputArray::copyTo(class cv::debug_build_guard::_OutputArray const &)const " (?copyTo@_InputArray@debug_build_guard@cv@@QEBAXAEBV_OutputArray@23@@Z) referenced in function "public: void __cdecl IDJL::CameraModel::correct_points(class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_OutputArray const &)const " (?correct_points@CameraModel@IDJL@@QEBAXAEBV_InputArray@debug_build_guard@cv@@AEBV_OutputArray@45@@Z)
idjl_camera_model.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl cv::debug_build_guard::_OutputArray::createSameSize(class cv::debug_build_guard::_InputArray const &,int)const " (?createSameSize@_OutputArray@debug_build_guard@cv@@QEBAXAEBV_InputArray@23@H@Z) referenced in function "public: void __cdecl IDJL::CameraModel::correct_points(class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_OutputArray const &)const " (?correct_points@CameraModel@IDJL@@QEBAXAEBV_InputArray@debug_build_guard@cv@@AEBV_OutputArray@45@@Z)
idjl_camera_model.cpp.obj : error LNK2019: unresolved external symbol "class cv::debug_build_guard::_InputOutputArray const & __cdecl cv::noArray(void)" (?noArray@cv@@YAAEBV_InputOutputArray@debug_build_guard@1@XZ) referenced in function "public: class cv::Point_<float> __cdecl IDJL::CameraModel::project(class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_InputArray const &)const " (?project@CameraModel@IDJL@@QEBA?AV?$Point_@M@cv@@AEBV_InputArray@debug_build_guard@4@0@Z)
idjl_camera_model.cpp.obj : error LNK2019: unresolved external symbol "int __cdecl cv::countNonZero(class cv::debug_build_guard::_InputArray const &)" (?countNonZero@cv@@YAHAEBV_InputArray@debug_build_guard@1@@Z) referenced in function "public: void __cdecl IDJL::CameraModel::correct_image(class cv::Mat const &,class cv::Mat &)const " (?correct_image@CameraModel@IDJL@@QEBAXAEBVMat@cv@@AEAV34@@Z)
idjl_camera_model.cpp.obj : error LNK2019: unresolved external symbol "void __cdecl cv::Rodrigues(class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_OutputArray const &,class cv::debug_build_guard::_OutputArray const &)" (?Rodrigues@cv@@YAXAEBV_InputArray@debug_build_guard@1@AEBV_OutputArray@31@1@Z) referenced in function "public: class cv::Point_<float> __cdecl IDJL::CameraModel::project(class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_InputArray const &)const " (?project@CameraModel@IDJL@@QEBA?AV?$Point_@M@cv@@AEBV_InputArray@debug_build_guard@4@0@Z)
idjl_camera_model.cpp.obj : error LNK2019: unresolved external symbol "void __cdecl cv::projectPoints(class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_OutputArray const &,class cv::debug_build_guard::_OutputArray const &,double)" (?projectPoints@cv@@YAXAEBV_InputArray@debug_build_guard@1@0000AEBV_OutputArray@31@1N@Z) referenced in function "public: class cv::Point_<float> __cdecl IDJL::CameraModel::project(class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_InputArray const &)const " (?project@CameraModel@IDJL@@QEBA?AV?$Point_@M@cv@@AEBV_InputArray@debug_build_guard@4@0@Z)
idjl_camera_model.cpp.obj : error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::getOptimalNewCameraMatrix(class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_InputArray const &,class cv::Size_<int>,double,class cv::Size_<int>,class cv::Rect_<int> *,bool)" (?getOptimalNewCameraMatrix@cv@@YA?AVMat@1@AEBV_InputArray@debug_build_guard@1@0V?$Size_@H@1@N1PEAV?$Rect_@H@1@_N@Z) referenced in function "public: void __cdecl IDJL::CameraModel::updateCorrectionMaps(void)" (?updateCorrectionMaps@CameraModel@IDJL@@QEAAXXZ)
idjl_camera_model.cpp.obj : error LNK2019: unresolved external symbol "void __cdecl cv::initUndistortRectifyMap(class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_InputArray const &,class cv::Size_<int>,int,class cv::debug_build_guard::_OutputArray const &,class cv::debug_build_guard::_OutputArray const &)" (?initUndistortRectifyMap@cv@@YAXAEBV_InputArray@debug_build_guard@1@000V?$Size_@H@1@HAEBV_OutputArray@31@2@Z) referenced in function "public: void __cdecl IDJL::CameraModel::updateCorrectionMaps(void)" (?updateCorrectionMaps@CameraModel@IDJL@@QEAAXXZ)
idjl_camera_model.cpp.obj : error LNK2019: unresolved external symbol "void __cdecl cv::undistortPoints(class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_OutputArray const &,class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_InputArray const &)" (?undistortPoints@cv@@YAXAEBV_InputArray@debug_build_guard@1@AEBV_OutputArray@31@0000@Z) referenced in function "public: void __cdecl IDJL::CameraModel::correct_points(class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_OutputArray const &)const " (?correct_points@CameraModel@IDJL@@QEBAXAEBV_InputArray@debug_build_guard@cv@@AEBV_OutputArray@45@@Z)
idjl_camera_model.cpp.obj : error LNK2019: unresolved external symbol "void __cdecl cv::remap(class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_OutputArray const &,class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_InputArray const &,int,int,class cv::Scalar_<double> const &)" (?remap@cv@@YAXAEBV_InputArray@debug_build_guard@1@AEBV_OutputArray@31@00HHAEBV?$Scalar_@N@1@@Z) referenced in function "public: void __cdecl IDJL::CameraModel::correct_image(class cv::Mat const &,class cv::Mat &)const " (?correct_image@CameraModel@IDJL@@QEBAXAEBVMat@cv@@AEAV34@@Z)
bin\idjl_camera_model.dll : fatal error LNK1120: 18 unresolved externals

or

    2>Link:
    2>  ClassificationFramework.lib(SampleClass.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
    2>ClassificationFramework.lib(SampleClass.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
    2>ClassificationFramework.lib(SampleNamesSet.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
    2>ClassificationFramework.lib(SampleSet.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
    2>ClassificationFramework.lib(DirectoryReader.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
    2>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
    2>C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Transformer\Debug\Tester.exe : fatal error LNK1319: 4 mismatches detected

This PR make sure that if a user sets the build type to Debug, there is a clear error early. For multiple-config generators, instead we simply remove Debug from the possible build types, to prevent users to build in debug at all.

@traversaro traversaro requested a review from S-Dafarra March 25, 2024 09:31
@traversaro
Copy link
Member Author

I do not think it make sense to add this check in all libraries, but I thought it could make sense to at least have it in the robotology-superbuild.

Copy link
Collaborator

@S-Dafarra S-Dafarra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

@traversaro traversaro merged commit c86927d into master Mar 25, 2024
36 of 37 checks passed
@traversaro traversaro deleted the traversaro-patch-8 branch March 25, 2024 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants