openenergysolutions / modbus-cpp

Modbus TCP master library in modern C++
https://aegis4ics.github.io/modbus-cpp/
Apache License 2.0
2 stars 0 forks source link

Build error - catch2 #24

Closed C1Ron closed 3 months ago

C1Ron commented 3 months ago

When following the build instructions in the README.md, I got dependency issues and needed to build with the following argument:

$ cmake -DMODBUS_VENDORED_DEPS=ON ..
$ cmake --build .
...
[ 40%] Built target modbus-cpp
[ 41%] Building CXX object lib/tests/unit/CMakeFiles/modbus_tests.dir/main.cpp.o
In file included from /usr/include/signal.h:328,
                 from /home/c1ron/github/modbus-cpp/build/_deps/catch2-src/single_include/catch2/catch.hpp:8042,
                 from /home/c1ron/github/modbus-cpp/lib/tests/unit/main.cpp:17:
/home/c1ron/github/modbus-cpp/build/_deps/catch2-src/single_include/catch2/catch.hpp:10830:58: error: call to non-‘constexpr’ function ‘long int sysconf(int)’
10830 |     static constexpr std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ;
      |                                                          ^~~~~~~~~~~
In file included from /home/c1ron/github/modbus-cpp/lib/tests/unit/main.cpp:17:
/home/c1ron/github/modbus-cpp/build/_deps/catch2-src/single_include/catch2/catch.hpp:10889:45: error: size of array ‘altStackMem’ is not an integral constant-expression
10889 |     char FatalConditionHandler::altStackMem[sigStackSize] = {};
      |                                             ^~~~~~~~~~~~
gmake[2]: *** [lib/tests/unit/CMakeFiles/modbus_tests.dir/build.make:76: lib/tests/unit/CMakeFiles/modbus_tests.dir/main.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:381: lib/tests/unit/CMakeFiles/modbus_tests.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2 

PS - I'm building on WSL2 - Ubuntu 22.04 using cmake 3.22 and gcc 9.5 :)

C1Ron commented 3 months ago

I was able to build successfully with MODBUS_VENDORED_DEPS=ON and MODBUS_BUILD_TESTS=OFF.

corynguyenfl commented 3 months ago

Updated Cache2