-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
cmake: support Ceres 2.0.0 #2732
Conversation
/cc @LaurentBerger It would be nice if you can check this on Windows platform (if you still have configured build environment) |
I guess with ceres 2.0 it only compiles if you compile the whole of opencv with c++14 mode, right? By default it's C++11 I think (and ceres required 14). |
Modern CMake supports propagation of language requirements from used components (through For example,
So, OpenCV modules which uses Ceres will be automatically compiled with C++14. Forced C++11 mode causes compilation errors with error messages near BTW, Possible workaround for non-patched OpenCV is forcing |
I updated my ceres version and builded and installed it.
and I tried to build opencv : and there is a problem
I used flags -DEigen3_DIR:PATH="$myRepo"/Eigen \ to build opencv full cmakeoutput : ceres2.txt |
@LaurentBerger Thank you for checking this!
Please try PR about Eigen from the main repository: opencv/opencv#18699
Do you have glog installed? Try to pass |
Thanks for the explanation.
Yes that makes sense. I didn't realize ceres sets these properties. I'm not sure, but hopefully there are no (binary) incompatibilities if you mix the libraries compiled with C++11 and C++14. For mixing C++99 and C++14 it may be different (thinking about a possible backport to opencv3, to also make that compatible with ceres 2.0.0.
Exactly. I've been investigating over at Homebrew/homebrew-core#63596. Maybe you can also give your opinion there what would be the best solution, if you can. This patch, once released, would solve the issue with opencv 4 at least, I believe. 👍
Yes, exactly. I've added those to test with the homebrew formulas
for opencv 4 and
for opencv 3. But for homebrew that is not really an option I think, as I'm not sure if it causes some incompatibilities with users of opencv that use C++99 or C++11. |
@@ -57,23 +90,11 @@ set(LIBMV_LIGHT_LIBS | |||
if(Ceres_FOUND) | |||
add_definitions("-DCERES_FOUND=1") | |||
list(APPEND LIBMV_LIGHT_LIBS simple_pipeline) | |||
list(APPEND LIBMV_LIGHT_INCLUDES "${CERES_INCLUDE_DIR}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might this cause a build failure with ceres 1.14, if that is not in a default include path (assuming retaining compatibility with 1.14 is a goal)? It looks to me like ceres 2.0.0 sets the right target properties w.r.t. the include paths, but ceres 1.14 doesn't seem to do so. Otoh with ceres 2.0.0 CERES_INCLUDE_DIRS
is not set at all anymore, so you would need to have a conditional to avoid adding an empty include path. In any case, it should be CERES_INCLUDE_DIRS
not ..._DIR
, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed (in sfm in rgbd modules).
I update my cmake to 3.18.4 and results now is :
full output |
@LaurentBerger Please attach logs of |
@alalek where are logs of check_glog_gflags.cpp? I cannot found something in opencv build repo opencvbuild/CMakeFiles/CMakeError.log |
endif() | ||
set(SFM_GLOG_GFLAGS_TEST "${SFM_GLOG_GFLAGS_TEST}" CACHE INTERNAL "") | ||
set(SFM_GLOG_GFLAGS_TEST_CACHE_KEY "${__cache_key}" CACHE INTERNAL "") | ||
message(STATUS "Checking SFM glog/gflags deps... ${SFM_GLOG_GFLAGS_TEST}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new.txt
-- Checking SFM deps... FALSE
Logs don't correspond to the content of this patch.
Please re-check that patch is applied properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failed compilation check: G:/Lib/opencv_contrib/modules/sfm/cmake/checks/check_glog_gflags.cpp
Change Dir: G:/Lib/build/opencv/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/MSBuild.exe cmTC_32546.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=15.0 /v:m && Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 pour .NET Framework
Copyright (C) Microsoft Corporation. Tous droits réservés.
Compilateur d'optimisation Microsoft (R) C/C++ version 19.16.27041 pour x64
Copyright (C) Microsoft Corporation. Tous droits réservés.
cl /c /IG:\Lib\install\gflags\include /Zi /W4 /WX- /diagnostics:classic /MP /Od /Ob0 /Oi /D WIN32 /D _WINDOWS /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /D GFLAGS_IS_A_DLL=1 /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /EHa /RTC1 /MDd /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /Fo"cmTC_32546.dir\Debug\\" /Fd"cmTC_32546.dir\Debug\vc141.pdb" /Gd /TP /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /errorReport:queue /bigobj G:\Lib\opencv_contrib\modules\sfm\cmake\checks\check_glog_gflags.cpp
check_glog_gflags.cpp
G:\Lib\opencv_contrib\modules\sfm\cmake\checks\check_glog_gflags.cpp(1): fatal error C1083: Impossible d'ouvrir le fichier include : 'glog/logging.h' : No such file or directory [G:\Lib\build\opencv\CMakeFiles\CMakeTmp\cmTC_32546.vcxproj]
Is it good message ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see /IG:\Lib\install\gflags\include
but don't see include directory for glog from this log.
Log above requests to specify GLOG_INCLUDE_DIR
:
-- Failed to find glog - Could not find glog include directory, set GLOG_INCLUDE_DIR to directory containing glog/logging.h
Could you dump used CMake options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I added :
-DEigen3_DIR:PATH=${installRepo}/Eigen3/share/eigen3/cmake \
-Dglog_DIR:PATH=${installRepo}/glog/lib/cmake/glog -Dgflags_DIR:PATH=${installRepo}/gflags/lib/cmake/gflags \
-DGLOG_INCLUDE_DIR=${installRepo}/glog/include \
and sfm is true :
But now I have got an error building sfm :
1>------ Build started: Project: opencv_sfm, Configuration: Release x64 ------
1>simple_pipeline.cpp
1>G:\lib\install\glog\include\glog/log_severity.h(51): fatal error C1189: #error: ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail.
1>Done building project "opencv_sfm.vcxproj" -- FAILED.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fatal error C1189: #error: ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail.
Added to handle that (not really related to Ceres 2.0.0):
add_definitions(/DGLOG_NO_ABBREVIATED_SEVERITIES)
I tried this patched version of the contribs with the opencv Homebrew formula, and it seems to work fine on macOS: https://github.com/Homebrew/homebrew-core/runs/1349352444?check_suite_focus=true (the build failure is in another formula depending on ceres, rawtoaces). Would it be reasonable to backport this to opencv 3? It looks like it still gets regular releases. |
👍 |
Thanks for working on this! Opencv 3 / 4 seems to be on a ~ 3 month release schedule, so these patches should land some time in January 2021 I think? |
Hello, can you please check #2923 ? Since this PR was merged the GLOG_LIBRARIES variable is empty whenever Ceres is detected and only Glog_LIBS is defined (and contains what used to be in GLOG_LIBRARIES), to fix build with gold, I had to add Glog_LIBS into LIBMV_LIGHT_LIBS to link with glog again without unresolved symbols in lib/libopencv_sfm.so.4.5.2. |
Merge with PR: opencv/opencv#18699
https://github.com/ceres-solver/ceres-solver/releases/tag/2.0.0 (Oct 26, 2020)
resolves #2578
Validated with: