mariokonrad / marnav

a library for MARitime NAVigation
Other
95 stars 47 forks source link

Compiling on OSX #17

Closed raffmont closed 6 years ago

raffmont commented 6 years ago

I'm trying to compile marnav under macOS High Sierra 13.10.6 with AppleClang version 9.1: Apple LLVM version 9.1.0 (clang-902.0.39.2) Target: x86_64-apple-darwin17.7.0 Thread model: posix Just adding the following lines in CMakeLists.txt : elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") message(STATUS "Compiler: AppleClang") In ### compiler check solves the issue. Unfortunately I had the following compiler error:

mmbp:build raffaelemontella$ make [ 2%] Built target extern_gmock [ 4%] Built target extern_benchmark [ 4%] Building CXX object src/CMakeFiles/marnav.dir/marnav/nmea/name.cpp.o /Users/raffaelemontella/dev/marnav/src/marnav/nmea/name.cpp:265:67: error: constexpr variable 'talkers' must be initialized by a constant expression static constexpr const std::array<entry, talker_id::num_talkers> talkers = {{ ^ ~~ /Users/raffaelemontella/dev/marnav/src/marnav/nmea/name.cpp:266:3: note: non-constexpr constructor 'pair<true, false>' cannot be used in a constant expression {talker_id::none, "used for vendor extensions"}, ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/utility:422:5: note: declared here pair(_T1 const& __t1, _T2 const& __t2) ^ 1 error generated. make[2]: [src/CMakeFiles/marnav.dir/marnav/nmea/name.cpp.o] Error 1 make[1]: [src/CMakeFiles/marnav.dir/all] Error 2 make: *** [all] Error 2

Any suggestion?

mariokonrad commented 6 years ago

I suspect the implementation of std::array differs between stdlibc++ and libc++, therefore the error in name.cpp:265. It looks like the function to_name(talker) is the only one using std::array, all others have switches, I'll rewrite the function to also use a switch. It may be not as fancy as std::array/algorithms, but it works well, the problem you mention will disappear and the function can become constexpr for C++14 or newer.

Edit: now I see why it's handled with std::array/algorithms, talker is a class, not directly usable in a switch. Maybe the whole construct is a bit silly, since talker could/should be an enum class... I'll do something about it.

mariokonrad commented 6 years ago

One thing I forgot: please note that OSX is not officially supported, and I have no plans to do so.

raffmont commented 6 years ago

Thanks @mariokonrad ! About the MacOS, I could test it. The real challenge will be compiling marnav on Android!

mariokonrad commented 6 years ago

This is very kind of you. In the past I have not supported any platform I cannot test. Also, for me it is not an use-case, therefore I do not want to invest much time into it (which I do not have too much of it anyway).

However, I'm willing to think about (no guarantees!) support of other platforms if

raffmont commented 6 years ago

@mariokonrad , usually is very no intrusive. With the change in CMakeLists.txt i can create the makefile with cmake ... and then issue the make command . This is the result:

[ 0%] Creating directories for 'extern_gmock' [ 1%] No download step for 'extern_gmock' [ 1%] No patch step for 'extern_gmock' [ 1%] No update step for 'extern_gmock' [ 1%] Performing configure step for 'extern_gmock' -- TARGET: gmock 1.7.0 @@ /Users/raffaelemontella/dev/marnav/extern/gmock-1.7.0 -- Configuring done -- Generating done -- Build files have been written to: /Users/raffaelemontella/dev/marnav/build/gmock/src/extern_gmock-build [ 2%] Performing build step for 'extern_gmock' [100%] Built target gmock [ 2%] Performing install step for 'extern_gmock' [100%] Built target gmock Install the project... -- Install configuration: "Release" -- Installing: /Users/raffaelemontella/dev/marnav/build/local/lib/libgmock.a -- Up-to-date: /Users/raffaelemontella/dev/marnav/build/local/include/gmock/gmock.h -- Up-to-date: /Users/raffaelemontella/dev/marnav/build/local/include/gtest/gtest.h [ 2%] Completed 'extern_gmock' [ 2%] Built target extern_gmock [ 2%] Creating directories for 'extern_benchmark' [ 3%] No download step for 'extern_benchmark' [ 3%] No patch step for 'extern_benchmark' [ 3%] No update step for 'extern_benchmark' [ 3%] Performing configure step for 'extern_benchmark' -- git Version: v0.8.1-ea82c58c-dirty -- Version: 0.8.1 -- Performing Test HAVE_THREAD_SAFETY_ATTRIBUTES -- Performing Test HAVE_THREAD_SAFETY_ATTRIBUTES -- failed to compile -- Performing Test HAVE_STD_REGEX -- Performing Test HAVE_STD_REGEX -- success -- Performing Test HAVE_GNU_POSIX_REGEX -- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile -- Performing Test HAVE_POSIX_REGEX -- Performing Test HAVE_POSIX_REGEX -- success -- Performing Test HAVE_STEADY_CLOCK -- Performing Test HAVE_STEADY_CLOCK -- success -- Configuring done -- Generating done -- Build files have been written to: /Users/raffaelemontella/dev/marnav/build/benchmark/src/extern_benchmark-build [ 4%] Performing build step for 'extern_benchmark' [ 30%] Built target benchmark [ 34%] Built target output_test_helper [ 38%] Built target complexity_test [ 42%] Built target cxx03_test [ 46%] Built target filter_test [ 51%] Built target user_counters_test [ 55%] Built target reporter_output_test [ 59%] Built target options_test [ 63%] Built target map_test [ 67%] Built target register_benchmark_test [ 71%] Built target multiple_ranges_test [ 75%] Built target fixture_test [ 79%] Built target donotoptimize_test [ 83%] Built target skip_with_error_test [ 87%] Built target basic_test [ 91%] Built target benchmark_test [ 95%] Built target user_counters_tabular_test [100%] Built target diagnostics_test [ 4%] Performing install step for 'extern_benchmark' [ 30%] Built target benchmark [ 34%] Built target output_test_helper [ 38%] Built target complexity_test [ 42%] Built target cxx03_test [ 46%] Built target filter_test [ 51%] Built target user_counters_test [ 55%] Built target reporter_output_test [ 59%] Built target options_test [ 63%] Built target map_test [ 67%] Built target register_benchmark_test [ 71%] Built target multiple_ranges_test [ 75%] Built target fixture_test [ 79%] Built target donotoptimize_test [ 83%] Built target skip_with_error_test [ 87%] Built target basic_test [ 91%] Built target benchmark_test [ 95%] Built target user_counters_tabular_test [100%] Built target diagnostics_test Install the project... -- Install configuration: "Release" -- Installing: /Users/raffaelemontella/dev/marnav/build/local/lib/libbenchmark.a -- Up-to-date: /Users/raffaelemontella/dev/marnav/build/local/include/benchmark -- Up-to-date: /Users/raffaelemontella/dev/marnav/build/local/include/benchmark/reporter.h -- Up-to-date: /Users/raffaelemontella/dev/marnav/build/local/include/benchmark/benchmark_api.h -- Up-to-date: /Users/raffaelemontella/dev/marnav/build/local/include/benchmark/benchmark.h -- Up-to-date: /Users/raffaelemontella/dev/marnav/build/local/lib/cmake/benchmark/benchmarkConfig.cmake -- Up-to-date: /Users/raffaelemontella/dev/marnav/build/local/lib/cmake/benchmark/benchmarkConfigVersion.cmake -- Up-to-date: /Users/raffaelemontella/dev/marnav/build/local/lib/cmake/benchmark/benchmarkTargets.cmake -- Installing: /Users/raffaelemontella/dev/marnav/build/local/lib/cmake/benchmark/benchmarkTargets-release.cmake [ 4%] Completed 'extern_benchmark' [ 4%] Built target extern_benchmark [ 4%] Building CXX object src/CMakeFiles/marnav.dir/marnav/utils/mmsi.cpp.o [ 4%] Building CXX object src/CMakeFiles/marnav.dir/marnav/utils/mmsi_country.cpp.o [ 4%] Building CXX object src/CMakeFiles/marnav.dir/marnav/geo/angle.cpp.o [ 5%] Building CXX object src/CMakeFiles/marnav.dir/marnav/geo/position.cpp.o [ 5%] Building CXX object src/CMakeFiles/marnav.dir/marnav/geo/region.cpp.o [ 5%] Building CXX object src/CMakeFiles/marnav.dir/marnav/geo/cpa.cpp.o [ 6%] Building CXX object src/CMakeFiles/marnav.dir/marnav/geo/geodesic.cpp.o [ 6%] Building CXX object src/CMakeFiles/marnav.dir/marnav/nmea/waypoint.cpp.o [ 6%] Building CXX object src/CMakeFiles/marnav.dir/marnav/nmea/tag_block.cpp.o [ 6%] Building CXX object src/CMakeFiles/marnav.dir/marnav/nmea/talker_id.cpp.o [ 7%] Building CXX object src/CMakeFiles/marnav.dir/marnav/nmea/convert.cpp.o [ 7%] Building CXX object src/CMakeFiles/marnav.dir/marnav/nmea/manufacturer.cpp.o [ 7%] Building CXX object src/CMakeFiles/marnav.dir/marnav/nmea/checks.cpp.o [ 7%] Building CXX object src/CMakeFiles/marnav.dir/marnav/nmea/split.cpp.o [ 8%] Building CXX object src/CMakeFiles/marnav.dir/marnav/nmea/angle.cpp.o [ 8%] Building CXX object src/CMakeFiles/marnav.dir/marnav/nmea/string.cpp.o [ 8%] Building CXX object src/CMakeFiles/marnav.dir/marnav/nmea/name.cpp.o [ 8%] Building CXX object src/CMakeFiles/marnav.dir/marnav/nmea/io.cpp.o [ 9%] Building CXX object src/CMakeFiles/marnav.dir/marnav/nmea/date.cpp.o [ 9%] Building CXX object src/CMakeFiles/marnav.dir/marnav/nmea/time.cpp.o [ 9%] Building CXX object src/CMakeFiles/marnav.dir/marnav/nmea/checksum.cpp.o [ 9%] Building CXX object src/CMakeFiles/marnav.dir/marnav/nmea/sentence.cpp.o [ 10%] Building CXX object src/CMakeFiles/marnav.dir/marnav/nmea/detail.cpp.o [ 10%] Building CXX object src/CMakeFiles/marnav.dir/marnav/nmea/ais_helper.cpp.o [ 10%] Building CXX object src/CMakeFiles/marnav.dir/marnav/nmea/nmea.cpp.o In file included from /Users/raffaelemontella/dev/marnav/src/marnav/nmea/nmea.cpp:27: /Users/raffaelemontella/dev/marnav/src/marnav/nmea/glc.hpp:63:64: error: implicit instantiation of undefined template 'std::1::array<marnav::utils::optional, 5>' std::array<utils::optional, max_differences> timediffs; ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/tuple:223:64: note: template is declared here template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array; ^ /Users/raffaelemontella/dev/marnav/src/marnav/nmea/nmea.cpp:110:33: error: no matching constructor for initialization of 'const std::vector' static const std::vector known_sentences = { ^ ~ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:498:9: note: candidate constructor template not viable: requires 2 arguments, but 78 were provided vector(_InputIterator first, ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:506:9: note: candidate constructor template not viable: requires at most 4 arguments, but 78 were provided vector(_InputIterator first, _InputIterator last, const allocator_type& __a, ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:513:9: note: candidate constructor template not viable: requires 2 arguments, but 78 were provided vector(_ForwardIterator first, ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:520:9: note: candidate constructor template not viable: requires at most 4 arguments, but 78 were provided vector(_ForwardIterator first, _ForwardIterator __last, const allocator_type& a, ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:496:5: note: candidate constructor not viable: requires 3 arguments, but 78 were provided vector(size_type n, const_reference __x, const allocator_type& a); ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:495:5: note: candidate constructor not viable: requires 2 arguments, but 78 were provided vector(size_type n, const_reference x); ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:535:5: note: candidate constructor not viable: requires 2 arguments, but 78 were provided vector(const vector& x, const allocator_type& a); ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:544:5: note: candidate constructor not viable: requires 2 arguments, but 78 were provided vector(initializer_list il, const allocator_type& a); ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:555:5: note: candidate constructor not viable: requires 2 arguments, but 78 were provided vector(vector&& x, const allocator_type& a); ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:479:40: note: candidate constructor not viable: requires single argument 'a', but 78 arguments were provided _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& a) ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:491:14: note: candidate constructor not viable: requires single argument '__n', but 78 arguments were provided explicit vector(size_type n); ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:534:5: note: candidate constructor not viable: requires single argument 'x', but 78 arguments were provided vector(const vector& x); ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:541:5: note: candidate constructor not viable: requires single argument 'il', but 78 arguments were provided vector(initializer_list il); ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:547:5: note: candidate constructor not viable: requires single argument 'x', but 78 arguments were provided vector(vector&& __x) ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:473:5: note: candidate constructor not viable: requires 0 arguments, but 78 were provided vector() NOEXCEPT(is_nothrow_default_constructible::value) ^ 2 errors generated. make[2]: [src/CMakeFiles/marnav.dir/marnav/nmea/nmea.cpp.o] Error 1 make[1]: [src/CMakeFiles/marnav.dir/all] Error 2 make: *** [all] Error 2

Any idea about how to fix it?

mariokonrad commented 6 years ago

Hi Raffaele.

The error appears here:

/Users/raffaelemontella/dev/marnav/src/marnav/nmea/glc.hpp:63:64: error: implicit instantiation of undefined template 'std::__1::array<marnav::utils::optional, 5>' std::array<utils::optional, max_differences> timediffs; ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1> /__tuple:223:64: note: template is declared here template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;

which indicates that your toolchain really does not like std::array. I do not know what toolchain do you have nor what it supports. Please note: the library does not support OSX. std::array is nothing specific to the library, but to the toolchain and/or the installation you are using.

Since this is not a marnav library issue, I will have to close the issue.