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

Need C++17 flags for Ceres #111

Open
yaoyuhan opened this issue Oct 27, 2024 · 6 comments
Open

Need C++17 flags for Ceres #111

yaoyuhan opened this issue Oct 27, 2024 · 6 comments

Comments

@yaoyuhan
Copy link

Hi,

I followed the README file and tried to run make, but had the error messages copied below.
My ceres-solver was installed with home brew.

May I ask if you have insights on how to fix the errors?

Thanks,
Yuhan

python3 setup.py build_ext --inplace --with-ceres --with-cython
Compiling tractor/galaxy.py because it changed.
[1/1] Cythonizing tractor/galaxy.py
Compiling tractor/patch.pyx because it changed.
Compiling tractor/basics.py because it changed.
Compiling tractor/brightness.py because it changed.
Compiling tractor/ceres_optimizer.py because it changed.
Compiling tractor/constrained_optimizer.py because it changed.
Compiling tractor/dense_optimizer.py because it changed.
Compiling tractor/ducks.py because it changed.
Compiling tractor/ellipses.py because it changed.
Compiling tractor/engine.py because it changed.
Compiling tractor/image.py because it changed.
Compiling tractor/imageutils.py because it changed.
Compiling tractor/lsqr_optimizer.py because it changed.
Compiling tractor/mixture_profiles.py because it changed.
Compiling tractor/motion.py because it changed.
Compiling tractor/optimize.py because it changed.
Compiling tractor/pointsource.py because it changed.
Compiling tractor/psf.py because it changed.
Compiling tractor/psfex.py because it changed.
Compiling tractor/sersic.py because it changed.
Compiling tractor/sfd.py because it changed.
Compiling tractor/shifted.py because it changed.
Compiling tractor/sky.py because it changed.
Compiling tractor/splinesky.py because it changed.
Compiling tractor/tractortime.py because it changed.
Compiling tractor/utils.py because it changed.
Compiling tractor/wcs.py because it changed.
[ 1/26] Cythonizing tractor/basics.py
[ 2/26] Cythonizing tractor/brightness.py
[ 3/26] Cythonizing tractor/ceres_optimizer.py
[ 4/26] Cythonizing tractor/constrained_optimizer.py
[ 5/26] Cythonizing tractor/dense_optimizer.py
[ 6/26] Cythonizing tractor/ducks.py
[ 7/26] Cythonizing tractor/ellipses.py
[ 8/26] Cythonizing tractor/engine.py
[ 9/26] Cythonizing tractor/image.py
[10/26] Cythonizing tractor/imageutils.py
[11/26] Cythonizing tractor/lsqr_optimizer.py
[12/26] Cythonizing tractor/mixture_profiles.py
[13/26] Cythonizing tractor/motion.py
[14/26] Cythonizing tractor/optimize.py
[15/26] Cythonizing tractor/patch.pyx
[16/26] Cythonizing tractor/pointsource.py
[17/26] Cythonizing tractor/psf.py
[18/26] Cythonizing tractor/psfex.py
[19/26] Cythonizing tractor/sersic.py
[20/26] Cythonizing tractor/sfd.py
warning: tractor/sersic.py:601:16: Unreachable code
[21/26] Cythonizing tractor/shifted.py
[22/26] Cythonizing tractor/sky.py
[23/26] Cythonizing tractor/splinesky.py
[24/26] Cythonizing tractor/tractortime.py
[25/26] Cythonizing tractor/utils.py
[26/26] Cythonizing tractor/wcs.py
Running echo "git_version = '$(git describe)'" > tractor/gitversion.py && cat tractor/gitversion.py tractor/version_post.py > tractor/version.py
Return value: 0
Set version 10.4.dev11
In file included from tractor/mix_wrap.c:4124:
tractor/gauss_masked.c:63:15: warning: variable 'ampsum' set but not used [-Wunused-but-set-variable]
63 | float ampsum = 0.;
| ^
1 warning generated.
ld: warning: duplicate -rpath '/Users/yuhanyao/miniforge3/lib' ignored
In file included from tractor/emfit_wrap.c:3565:
tractor/emfit2.c:31:9: warning: variable 'nexp' set but not used [-Wunused-but-set-variable]
31 | int nexp = 0;
| ^
1 warning generated.
ld: warning: duplicate -rpath '/Users/yuhanyao/miniforge3/lib' ignored
ld: warning: duplicate -rpath '/Users/yuhanyao/miniforge3/lib' ignored
tractor/ceres.i:343: Warning 401: Nothing known about base class 'ceres::IterationCallback'. Ignored.
In file included from tractor/ceres-tractor.cc:21:
In file included from tractor/ceres-tractor.h:1:
In file included from /opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/ceres.h:38:
In file included from /opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/autodiff_cost_function.h:130:
In file included from /opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/autodiff.h:147:
In file included from /opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/array_selector.h:38:
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:46:1: error: unknown type name 'constexpr'
46 | constexpr static auto kFixedArrayUseDefault = static_cast<size_t>(-1);
| ^
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:46:18: error: cannot combine with previous 'static' declaration specifier
46 | constexpr static auto kFixedArrayUseDefault = static_cast<size_t>(-1);
| ^
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:58:57: error: a space is required between consecutive right angle brackets (use '> >')
58 | Eigen::aligned_allocator>::type;
| ^
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:85:52: error: a space is required between consecutive right angle brackets (use '> >')
85 | typename A = FixedArrayDefaultAllocator>
| ^
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:90:10: error: unknown type name 'constexpr'
90 | static constexpr size_t kInlineBytesDefault = 256;
| ^
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:90:26: error: expected ';' at end of declaration list
90 | static constexpr size_t kInlineBytesDefault = 256;
| ^
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:99:10: error: unknown type name 'constexpr'
99 | static constexpr bool DefaultConstructorIsNonTrivial() {
| ^
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:117:10: error: unknown type name 'constexpr'
117 | static constexpr size_type inline_elements =
| ^
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:117:29: error: expected ';' at end of declaration list
117 | static constexpr size_type inline_elements =
| ^
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:148:19: error: no template named 'initializer_list' in namespace 'std'
148 | FixedArray(std::initializer_list<value_type> init_list,
| ~~~~~^
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:163:16: error: expected ';' at end of declaration list
163 | ~FixedArray() noexcept {
| ^
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:184:3: error: unknown type name 'constexpr'
184 | constexpr size_type max_size() const {
| ^
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:184:13: error: duplicate member 'size_type'
184 | constexpr size_type max_size() const {
| ^
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:110:9: note: previous declaration is here
110 | using size_type = typename AllocatorTraits::size_type;
| ^
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:184:22: error: expected ';' at end of declaration list
184 | constexpr size_type max_size() const {
| ^
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:366:33: error: use of undeclared identifier 'StorageElementWrapper'
366 | StorageElementWrapper<value_type>,
| ^
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:370:30: error: no template named 'StorageElementWrapper'
370 | static pointer AsValueType(StorageElementWrapper<value_type>* ptr) {
| ^
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:374:24: error: use of undeclared identifier 'StorageElement'
374 | static_assert(sizeof(StorageElement) == sizeof(value_type));
| ^
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:375:52: error: unexpected type name 'value_type': expected expression
375 | static_assert(alignof(StorageElement) == alignof(value_type));
| ^
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/internal/fixed_array.h:375:25: error: use of undeclared identifier 'StorageElement'
375 | static_assert(alignof(StorageElement) == alignof(value_type));
| ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
error: command '/usr/bin/clang' failed with exit code 1
make: *** [setup] Error 1

@dstndstn
Copy link
Owner

This looks like you're using an old C++ compiler that doesn't have C++11, or C++11 mode isn't the default.
https://en.cppreference.com/w/cpp/language/constexpr

Note that ceres is not required.

@yaoyuhan
Copy link
Author

Thank you so much!
I added the following lines:
export CXXFLAGS="-std=c++14"
export CFLAGS="-std=c++14"
and have a new set of errors copied below.

Changing to
export CXXFLAGS="-std=c++11"
export CFLAGS="-std=c++11"
gives me the same errors.

May I ask if you have any further suggestions?

python3 setup.py build_ext --inplace --with-ceres --with-cython
Running echo "git_version = '$(git describe)'" > tractor/gitversion.py && cat tractor/gitversion.py tractor/version_post.py > tractor/version.py
Return value: 0
Set version 10.4.dev11
tractor/ceres.i:343: Warning 401: Nothing known about base class 'ceres::IterationCallback'. Ignored.
In file included from tractor/ceres-tractor.cc:21:
In file included from tractor/ceres-tractor.h:1:
In file included from /opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/ceres.h:48:
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/dynamic_autodiff_cost_function.h:281:1: error: a type specifier is required for all declarations
281 | DynamicAutoDiffCostFunction(CostFunctor* functor, Ownership ownership)
| ^
In file included from tractor/ceres-tractor.cc:21:
In file included from tractor/ceres-tractor.h:1:
In file included from /opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/ceres.h:67:
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/product_manifold.h:274:36: error: no template named 'void_t' in namespace 'std'; did you mean '__void_t'?
274 | struct IsDereferenceable<T, std::void_t<decltype(*std::declval())>>
| ~~~~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__type_traits/void_t.h:26:1: note: '__void_t' declared here
26 | using __void_t = void;
| ^
In file included from tractor/ceres-tractor.cc:21:
In file included from tractor/ceres-tractor.h:1:
In file included from /opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/ceres.h:67:
/opt/homebrew/Cellar/ceres-solver/2.2.0_1/include/ceres/product_manifold.h:314:1: error: a type specifier is required for all declarations
314 | ProductManifold(Manifold0&&, Manifold1&&, Manifolds&&...)
| ^
3 errors generated.
error: command '/usr/bin/clang' failed with exit code 1
make: *** [setup] Error 1

@dstndstn
Copy link
Owner

I haven't seen that before. It looks like it's coming from within the ceres header files.

What versions of everything are you using - ceres, compilers, mac, etc

@dstndstn
Copy link
Owner

can you try adding any debugging / verbose flags to see what commands setup.py is actually running? It uses swig to connect the ceres C++ and Python code - what version of swig do you have, and does it support c++?

I'm super busy this week so unfortunately won't have much time to chase down this error.

@yaoyuhan
Copy link
Author

Thank you so much!
I did the following:
export CXXFLAGS="-std=c++17"
export CFLAGS="-std=c++17"
export LDFLAGS="-L//opt/homebrew/Cellar/ceres-solver/2.2.0_1/lib -lceres"
and then setup.py somehow worked!

Now I am able to run tractor-sdss-synth.py without errors.

@dstndstn
Copy link
Owner

Thanks for the report!!

I'm going to re-open this issue until I get a chance to update the documentation.

@dstndstn dstndstn reopened this Oct 28, 2024
@dstndstn dstndstn changed the title cannot install tractor Need C++17 flags for Ceres Oct 28, 2024
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

No branches or pull requests

2 participants