Closed garfeng closed 3 years ago
which mingw version is it ?
8.1.0 here can handle c++14 "out-of-the-box", so you might not need the -DENABLE_CXX11=ON
flag
i don' have ceres here, but a small example:
#include <math.h>
int main(int argc, char* argv[])
{
j0(13);
return 0;
}
g++ my.cpp // compiles fine g++ -std=c++11 my.cpp // error: 'j0' was not declared in this scope
so, can you try, if removing the flag from the cmake cmdline helps ?
Hello, thank you for your help.
I use the toolchain installed in Msys2.
mingw32 mingw-w64-i686-arm-none-eabi-gcc 10.1.0-2
mingw32 mingw-w64-i686-avr-gcc 8.4.0-4
mingw32 mingw-w64-i686-gcc 10.3.0-5 [installed]
mingw32 mingw-w64-i686-gcc-ada 10.3.0-5
mingw32 mingw-w64-i686-gcc-fortran 10.3.0-5
mingw32 mingw-w64-i686-gcc-libgfortran 10.3.0-5 [installed]
mingw32 mingw-w64-i686-gcc-libs 10.3.0-5 [installed]
mingw32 mingw-w64-i686-gcc-objc 10.3.0-5
mingw32 mingw-w64-i686-libgccjit 10.3.0-5
mingw32 mingw-w64-i686-riscv64-unknown-elf-gcc 10.1.0-2
mingw64 mingw-w64-x86_64-arm-none-eabi-gcc 10.1.0-2
mingw64 mingw-w64-x86_64-avr-gcc 8.4.0-4
mingw64 mingw-w64-x86_64-gcc 10.3.0-5 [installed]
mingw64 mingw-w64-x86_64-gcc-ada 10.3.0-5 [installed]
mingw64 mingw-w64-x86_64-gcc-fortran 10.3.0-5 [installed]
mingw64 mingw-w64-x86_64-gcc-libgfortran 10.3.0-5 [installed]
mingw64 mingw-w64-x86_64-gcc-libs 10.3.0-5 [installed]
mingw64 mingw-w64-x86_64-gcc-objc 10.3.0-5 [installed]
mingw64 mingw-w64-x86_64-libgccjit 10.3.0-5 [installed]
mingw64 mingw-w64-x86_64-riscv64-unknown-elf-gcc 10.1.0-2
ucrt64 mingw-w64-ucrt-x86_64-gcc 10.3.0-5
ucrt64 mingw-w64-ucrt-x86_64-gcc-fortran 10.3.0-5
ucrt64 mingw-w64-ucrt-x86_64-gcc-libgfortran 10.3.0-5
ucrt64 mingw-w64-ucrt-x86_64-gcc-libs 10.3.0-5
ucrt64 mingw-w64-ucrt-x86_64-gcc-objc 10.3.0-5
ucrt64 mingw-w64-ucrt-x86_64-libgccjit 10.3.0-5
msys gcc 10.2.0-1
msys gcc-fortran 10.2.0-1
msys gcc-libs 10.2.0-1 [installed]
msys mingw-w64-cross-gcc 10.2.0-1
8.1.0 here can handle c++14 "out-of-the-box", so you might not need the -DENABLE_CXX11=ON flag
When I remove the -DENABLE_CXX11=ON, the error still appears.
Use make VERBOSE=1
to see actual compiler's command line of failed step (check for -std=
option)
I have the same problem。 Windows 10 x64 ,Msys2 ,g++ 10.3.0,opencv4.5.3 .
I Use make VERBOSE=1
:
`
$ mingw32-make.exe VERBOSE=1
C:\msys64\mingw64\bin\cmake.exe -SD:\opencv\opencv -BD:\opencv\opencv4_mingw64build --check-build-system CMakeFiles\Makefile.cmake 0
C:\msys64\mingw64\bin\cmake.exe -E cmake_progress_start D:\opencv\opencv4_mingw64build\CMakeFiles D:\opencv\opencv4_mingw64build\CMakeFiles\progress.marks
C:/msys64/mingw64/bin/mingw32-make.exe -f CMakeFiles\Makefile2 all
mingw32-make[1]: Entering directory 'D:/opencv/opencv4_mingw64build'
C:/msys64/mingw64/bin/mingw32-make.exe -f CMakeFiles\gen-pkgconfig.dir\build.make CMakeFiles/gen-pkgconfig.dir/depend
mingw32-make[2]: Entering directory 'D:/opencv/opencv4_mingw64build'
C:\msys64\mingw64\bin\cmake.exe -E cmake_depends "MinGW Makefiles" D:\opencv\opencv D:\opencv\opencv D:\opencv\opencv4_mingw64build D:\opencv\opencv4_mingw64build D:\opencv\opencv4_mingw64build\CMakeFiles\gen-pkgconfig.dir\DependInfo.cma
mingw32-make[2]: Leaving directory 'D:/opencv/opencv4_mingw64build'
C:/msys64/mingw64/bin/mingw32-make.exe -f CMakeFiles\gen-pkgconfig.dir\build.make CMakeFiles/gen-pkgconfig.dir/build
mingw32-make[2]: Entering directory 'D:/opencv/opencv4_mingw64build'
mingw32-make[2]: Nothing to be done for 'CMakeFiles/gen-pkgconfig.dir/build'.
mingw32-make[2]: Leaving directory 'D:/opencv/opencv4_mingw64build'
[ 0%] Built target gen-pkgconfig
`
……………………………………
…………………………………… `
Consolidate compiler generated dependencies of target multiview mingw32-make[2]: Leaving directory 'D:/opencv/opencv4_mingw64build' C:/msys64/mingw64/bin/mingw32-make.exe -f modules\sfm\src\libmv\libmv\multiview\CMakeFiles\multiview.dir\build.make modules/sfm/src/libmv/libmv/multiview/CMakeFiles/multiview.dir/build mingw32-make[2]: Entering directory 'D:/opencv/opencv4_mingw64build' [ 88%] Building CXX object modules/sfm/src/libmv/libmv/multiview/CMakeFiles/multiview.dir/fundamental.cc.obj cd /d D:\opencv\opencv4_mingw64build\modules\sfm\src\libmv\libmv\multiview && C:/msys64/mingw64/bin/ccache.exe C:\msys64\mingw64\bin\g++.exe -DCERES_EXPORT_INTERNAL_SYMBOLS -DCERES_FOUND=1 -DGFLAGS_IS_A_DLL=1 -DGLOG_NO_ABBREVIATED_SEVERILD=1 -DSTDC_CONSTANT_MACROS -DSTDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS @CMakeFiles/multiview.dir/includes_CXX.rsp -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Weno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibilityeclarations -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-unused-function -Wno-suggest-override -Wno-suggest-override -Wno-class-memaccess -Wno-deprecated-copy -O3 -DNDEBUG -DNDEBUG -std=c++14 -MD -MT modules/sfm/src/libmv/libw.dir\fundamental.cc.obj.d -o CMakeFiles\multiview.dir\fundamental.cc.obj -c D:\opencv\opencv_contrib\modules\sfm\src\libmv_light\libmv\multiview\fundamental.cc In file included from C:/msys64/mingw64/include/ceres/internal/autodiff.h:153, from C:/msys64/mingw64/include/ceres/autodiff_cost_function.h:130, from C:/msys64/mingw64/include/ceres/ceres.h:37, from D:\opencv\opencv_contrib\modules\sfm\src\libmv_light\libmv\multiview\fundamental.cc:24: C:/msys64/mingw64/include/ceres/jet.h: In function 'double ceres::BesselJ0(double)': C:/msys64/mingw64/include/ceres/jet.h:603:10: error: 'j0' was not declared in this scope; did you mean 'V0'? 603 | return j0(x); | ^~ | V0 C:/msys64/mingw64/include/ceres/jet.h: In function 'double ceres::BesselJ1(double)': C:/msys64/mingw64/include/ceres/jet.h:610:10: error: 'j1' was not declared in this scope; did you mean 'V1'? 610 | return j1(x); | ^~ | V1 C:/msys64/mingw64/include/ceres/jet.h: In function 'double ceres::BesselJn(int, double)': C:/msys64/mingw64/include/ceres/jet.h:617:10: error: 'jn' was not declared in this scope; did you mean 'n'? 617 | return jn(n, x); | ^~ | n mingw32-make[2]: [modules\sfm\src\libmv\libmv\multiview\CMakeFiles\multiview.dir\build.make:106: modules/sfm/src/libmv/libmv/multiview/CMakeFiles/multiview.dir/fundamental.cc.obj] Error 1 mingw32-make[2]: Leaving directory 'D:/opencv/opencv4_mingw64build' mingw32-make[1]: [CMakeFiles\Makefile2:8317: modules/sfm/src/libmv/libmv/multiview/CMakeFiles/multiview.dir/all] Error 2 mingw32-make[1]: Leaving directory 'D:/opencv/opencv4_mingw64build' mingw32-make: *** [Makefile:165: all] Error 2 `
I have test g++:
this is Ok
$ g++ -std=gnu++14 hello.cpp
,but error when
`
$ g++ -std=c++14 hello.cpp
hello.cpp: In function 'int main(int, char**)':
hello.cpp:4:2: error: 'j0' was not declared in this scope
4 | j0(13);
| ^~
`
p.s.
when BUILD_opencv_sfm is off ,I can build successful .
Could you try these options:
cmake ... -DOPENCV_EXTRA_CXX_FLAGS=-std=gnu++14
cmake -DCMAKE_CXX_EXTENSIONS=ON
I make all both cmake ... -DOPENCV_EXTRA_CXX_FLAGS=-std=gnu++14 and cmake -DCMAKE_CXX_EXTENSIONS=ON
·
Consolidate compiler generated dependencies of target multiview
[ 91%] Building CXX object modules/sfm/src/libmv/libmv/multiview/CMakeFiles/multiview.dir/robust_estimation.cc.obj
In file included from D:\opencv\opencv_contrib\modules\sfm\src\libmv_light\libmv\multiview\robust_estimation.cc:26:
D:/opencv/opencv_contrib/modules/sfm/src/libmv_light/libmv/multiview/robust_estimation.h:57:8: error: 'uint' does not name a type; did you mean 'rint'?
57 | static uint IterationsRequired(int min_samples,
| ^~~~
| rint
D:/opencv/opencv_contrib/modules/sfm/src/libmv_light/libmv/multiview/robust_estimation.h: In function 'typename Kernel::Model libmv::Estimate(const Kernel&, const Scorer&, libmv::vector~~~~~
D:/opencv/opencv_contrib/modules/sfm/src/libmv_light/libmv/multiview/robust_estimation.h:138:26: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
mingw32-make[2]: [modules\sfm\src\libmv\libmv\multiview\CMakeFiles\multiview.dir\build.make:196: modules/sfm/src/libmv/libmv/multiview/CMakeFiles/multiview.dir/robust_estimation.cc.obj] Error 1
mingw32-make[1]: [CMakeFiles\Makefile2:8224: modules/sfm/src/libmv/libmv/multiview/CMakeFiles/multiview.dir/all] Error 2
·~~~~~~~~
verbose=1
`
[ 92%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/seam_finders.cpp.obj
cd /d D:\opencv\opencv4_mingw64build\modules\stitching && C:/msys64/mingw64/bin/ccache.exe C:\msys64\mingw64\bin\g++.exe -DCVAPI_EXPORTS -DVK_NO_PROTOTYPES -D_USE_MATH_DEFINES -D_WIN32_WINNT=0x0601 -D__OPENCV_BUILD=1 -DSTDC_CONSTANT_MACROS -DSTDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS @CMakeFiles/opencv_stitching.dir/includes_CXX.rsp -std=gnu++14 -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -O3 -DNDEBUG -DNDEBUG -std=gnu++11 -MD -MT modules/stitching/CMakeFiles/opencv_stitching.dir/src/seam_finders.cpp.obj -MF CMakeFiles\opencv_stitching.dir\src\seam_finders.cpp.obj.d -o CMakeFiles\opencv_stitching.dir\src\seam_finders.cpp.obj -c D:\opencv\opencv\modules\stitching\src\seam_finders.cpp
In file included from D:\opencv\opencv_contrib\modules\sfm\src\libmv_light\libmv\multiview\robust_resection.cc:22:
D:/opencv/opencv_contrib/modules/sfm/src/libmv_light/libmv/multiview/robust_estimation.h:57:8: error: 'uint' does not name a type; did you mean 'rint'?
57 | static uint IterationsRequired(int min_samples,
| ^~~~
| rint
D:/opencv/opencv_contrib/modules/sfm/src/libmv_light/libmv/multiview/robust_estimation.h: In function 'typename Kernel::Model libmv::Estimate(const Kernel&, const Scorer&, libmv::vector~~~~~
D:/opencv/opencv_contrib/modules/sfm/src/libmv_light/libmv/multiview/robust_estimation.h:138:26: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
D:/opencv/opencv_contrib/modules/sfm/src/libmv_light/libmv/multiview/robust_estimation.h: In instantiation of 'typename Kernel::Model libmv::Estimate(const Kernel&, const Scorer&, libmv::vector~~~~^~~
139 | outliers_probability,
| ~~~~~
140 | best_inlier_ratio);
| ~~~~~~
mingw32-make[2]: [modules\sfm\src\libmv\libmv\multiview\CMakeFiles\multiview.dir\build.make:226: modules/sfm/src/libmv/libmv/multiview/CMakeFiles/multiview.dir/robust_resection.cc.obj] Error 1
mingw32-make[2]: Leaving directory 'D:/opencv/opencv4_mingw64build'
mingw32-make[1]: [CMakeFiles\Makefile2:8224: modules/sfm/src/libmv/libmv/multiview/CMakeFiles/multiview.dir/all] Error 2
mingw32-make[1]: *** Waiting for unfinished jobs....
`
Now there are several -std
options. That isn't good.
g++.exe -std=gnu++14 ... -std=gnu++11 ...
Please try this only:
cmake ... -DCMAKE_CXX_EXTENSIONS=ON -DCMAKE_CXX_STANDARD=14
(please check installed Ceres version and its prerequisites about required C++ mode)
Now there are several
-std
options. That isn't good.g++.exe -std=gnu++14 ... -std=gnu++11 ...
Please try this only:
cmake ... -DCMAKE_CXX_EXTENSIONS=ON -DCMAKE_CXX_STANDARD=14
(please check installed Ceres version and its prerequisites about required C++ mode)
@alalek thank you for your answer.
cmake ... -DCMAKE_CXX_EXTENSIONS=ON -DCMAKE_CXX_STANDARD=14
works!!!
System information (version)
Detailed description
Steps to reproduce
I edit the
F:\msys64\mingw64\x86_64-w64-mingw32\include\math.h
by adding#undef __STRICT_ANSI__
to the top of the file, then the error disappears.Please refer to this question : https://stackoverflow.com/questions/42231558/mingw-c-wont-compile-j0-funciton
Please fix it or tell me whether should I report the issue to Mingw64/Msys2
Issue submission checklist