i try to create some small project on windows, but when i try to build this with cmake there are many errors occured. On linux this build up successfully. When i create dummy project with CMake all work. This is my folder structure:
extern
googletest
tests
...
CMakeLists.txt
...
CMakeLists.txt
Root CMakeLists.txt:
# Setup cmake minimal required version
cmake_minimum_required(VERSION 3.10)
# Declare project
project(mobile_speaker_driver)
# Change c++ standard
set(CMAKE_CXX_STANDARD 17)
# Adding googletest to project
option(PACKAGE_TESTS "Build the tests" ON)
if(PACKAGE_TESTS)
enable_testing()
include(GoogleTest)
add_subdirectory(tests)
endif()
# Add source files to driver library
if (WIN32)
set(SOURCE_FILES apps/main.cpp src/AudioDriver.cpp src/AudioDriverWindows.cpp)
elseif (UNIX)
set(SOURCE_FILES apps/main.cpp src/AudioDriver.cpp src/AudioDriverLinux.cpp)
endif (WIN32)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
Tests CMakeLists.txt:
set(TESTBINARY ${PROJECT_NAME}_test)
add_subdirectory("${PROJECT_SOURCE_DIR}/extern/googletest" "extern/googletest")
add_executable(${TESTBINARY} main.cpp AudioDriverTest.cpp)
target_link_libraries(${TESTBINARY} gtest gtest_main)
Errors:
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/include/gtest/internal/gtest-port.h: In function 'int testing::internal::posix::StrCaseCmp(const char*, const char*)':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/include/gtest/internal/gtest-port.h:1985:10: error: '_stricmp' was not declared in this scope; did you mean 'strncmp'?
1985 | return _stricmp(s1, s2);
| ^~~~~~~~
| strncmp
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/include/gtest/internal/gtest-port.h: In function 'char* testing::internal::posix::StrDup(const char*)':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/include/gtest/internal/gtest-port.h:1987:47: error: '_strdup' was not declared in this scope
1987 | inline char* StrDup(const char* src) { return _strdup(src); }
| ^~~~~~~
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/include/gtest/internal/gtest-port.h: In function 'int testing::internal::posix::FileNo(FILE*)':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/include/gtest/internal/gtest-port.h:1995:40: error: '_fileno' was not declared in this scope; did you mean 'file'?
1995 | inline int FileNo(FILE* file) { return _fileno(file); }
| ^~~~~~~
| file
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/include/gtest/internal/gtest-port.h: In function 'FILE* testing::internal::posix::FDOpen(int, const char*)':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/include/gtest/internal/gtest-port.h:2072:56: error: 'fdopen' was not declared in this scope; did you mean 'fopen'?
2072 | inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
| ^~~~~~
| fopen
In file included from D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-all.cc:41:
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest.cc: In static member function 'static bool testing::internal::String::CaseInsensitiveWideCStringEquals(const wchar_t*, const wchar_t*)':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest.cc:2077:10: error: '_wcsicmp' was not declared in this scope; did you mean 'wcsncmp'?
2077 | return _wcsicmp(lhs, rhs) == 0;
| ^~~~~~~~
| wcsncmp
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest.cc: In member function 'int testing::UnitTest::Run()':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest.cc:5253:21: error: '_OUT_TO_STDERR' was not declared in this scope
5253 | _set_error_mode(_OUT_TO_STDERR);
| ^~~~~~~~~~~~~~
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest.cc:5253:5: error: '_set_error_mode' was not declared in this scope
5253 | _set_error_mode(_OUT_TO_STDERR);
| ^~~~~~~~~~~~~~~
In file included from D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-all.cc:42:
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc: In function 'void testing::internal::DeathTestAbort(const string&)':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc:296:5: error: '_exit' was not declared in this scope; did you mean '_cexit'?
296 | _exit(1);
| ^~~~~
| _cexit
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc: In member function 'virtual void testing::internal::DeathTestImpl::Abort(testing::internal::DeathTest::AbortReason)':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc:527:3: error: '_exit' was not declared in this scope; did you mean '_cexit'?
527 | _exit(1); // Exits w/o any normal exit hooks (we were supposed to crash)
| ^~~~~
| _cexit
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc: In member function 'virtual testing::internal::DeathTest::TestRole testing::internal::WindowsDeathTest::AssumeRole()':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc:771:24: error: '_MAX_PATH' was not declared in this scope; did you mean 'MAX_PATH'?
771 | char executable_path[_MAX_PATH + 1]; // NOLINT
| ^~~~~~~~~
| MAX_PATH
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc:773:65: error: 'executable_path' was not declared in this scope
773 | executable_path,
| ^~~~~~~~~~~~~~~
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc:308:38: note: in definition of macro 'GTEST_DEATH_TEST_CHECK_'
308 | if (!::testing::internal::IsTrue(expression)) { \
| ^~~~~~~~~~
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc:797:11: error: 'executable_path' was not declared in this scope
797 | executable_path, const_cast<char*>(command_line.c_str()),
| ^~~~~~~~~~~~~~~
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc:308:38: note: in definition of macro 'GTEST_DEATH_TEST_CHECK_'
308 | if (!::testing::internal::IsTrue(expression)) { \
| ^~~~~~~~~~
In file included from D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-all.cc:43:
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-filepath.cc: In static member function 'static testing::internal::FilePath testing::internal::FilePath::GetCurrentDir()':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-filepath.cc:49:26: error: '_MAX_PATH' was not declared in this scope; did you mean 'MAX_PATH'?
49 | # define GTEST_PATH_MAX_ _MAX_PATH
| ^~~~~~~~~
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-filepath.cc:101:12: note: in expansion of macro 'GTEST_PATH_MAX_'
101 | char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
| ^~~~~~~~~~~~~~~
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-filepath.cc:102:27: error: 'cwd' was not declared in this scope
102 | return FilePath(_getcwd(cwd, sizeof(cwd)) == nullptr ? "" : cwd);
| ^~~
make.exe[2]: *** [tests/extern/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj] Ошибка 1
make.exe[1]: *** [tests/extern/googletest/googletest/CMakeFiles/gtest.dir/all] Ошибка 2
make.exe: *** [all] Ошибка 2
The problem is occured because i force build googletest with c++17 flags. Just place CMAKE_CXX_STANDARD after googletest include in main CMakeLists.txt.
Related
I get the following Error due to some headers from the libtorch library (DynamicCast.h, different functions) when i try to compile a simple test program:
PS C:\Users\a\Desktop\MachineLearningDemos\build> cmake --build . --config Release
[ 50%] Building CXX object CMakeFiles/MinEx.dir/MinEx.cpp.obj
In file included from C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DeviceType.h:8,
from C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/Device.h:3,
from C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/ATen/core/TensorBody.h:11,
from C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/ATen/core/Tensor.h:3,
from C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/ATen/Tensor.h:3,
from C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/torch/csrc/autograd/function_hook.h:3,
from C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/torch/csrc/autograd/cpp_hook.h:2,
from C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/torch/csrc/autograd/variable.h:6,
from C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/torch/csrc/autograd/autograd.h:3,
from C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/torch/csrc/api/include/torch/autograd.h:3,
from C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/torch/csrc/api/include/torch/all.h:7,
from C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/torch/csrc/api/include/torch/torch.h:3,
from C:/Users/Potzkai/Desktop/MachineLearningDemos/MinEx.cpp:1:
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h: In function ‘dest_t c10::fetch_and_cast(c10::ScalarType, const void*) [with dest_t = c10::qint8]’:
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h:112:1: error: ‘__assert_fail’ was not declared in this scope; did you mean ‘__assert_func’?
112 | AT_FORALL_QINT_TYPES(DEFINE_UNCASTABLE)
| ^~~~~~~~~~~~~~~~~~~~
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h: In function ‘void c10::cast_and_store(c10::ScalarType, void*, src_t) [with src_t = c10::qint8]’:
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h:112:1: error: ‘__assert_fail’ was not declared in this scope; did you mean ‘__assert_func’?
112 | AT_FORALL_QINT_TYPES(DEFINE_UNCASTABLE)
| ^~~~~~~~~~~~~~~~~~~~
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h: In function ‘dest_t c10::fetch_and_cast(c10::ScalarType, const void*) [with dest_t = c10::quint8]’:
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h:112:1: error: ‘__assert_fail’ was not declared in this scope; did you mean ‘__assert_func’?
112 | AT_FORALL_QINT_TYPES(DEFINE_UNCASTABLE)
| ^~~~~~~~~~~~~~~~~~~~
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h: In function ‘void c10::cast_and_store(c10::ScalarType, void*, src_t) [with src_t = c10::quint8]’:
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h:112:1: error: ‘__assert_fail’ was not declared in this scope; did you mean ‘__assert_func’?
112 | AT_FORALL_QINT_TYPES(DEFINE_UNCASTABLE)
| ^~~~~~~~~~~~~~~~~~~~
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h: In function ‘dest_t c10::fetch_and_cast(c10::ScalarType, const void*) [with dest_t = c10::qint32]’:
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h:112:1: error: ‘__assert_fail’ was not declared in this scope; did you mean ‘__assert_func’?
112 | AT_FORALL_QINT_TYPES(DEFINE_UNCASTABLE)
| ^~~~~~~~~~~~~~~~~~~~
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h: In function ‘void c10::cast_and_store(c10::ScalarType, void*, src_t) [with src_t = c10::qint32]’:
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h:112:1: error: ‘__assert_fail’ was not declared in this scope; did you mean ‘__assert_func’?
112 | AT_FORALL_QINT_TYPES(DEFINE_UNCASTABLE)
| ^~~~~~~~~~~~~~~~~~~~
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h: In function ‘dest_t c10::fetch_and_cast(c10::ScalarType, const void*) [with dest_t = c10::quint4x2]’:
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h:112:1: error: ‘__assert_fail’ was not declared in this scope; did you mean ‘__assert_func’?
112 | AT_FORALL_QINT_TYPES(DEFINE_UNCASTABLE)
| ^~~~~~~~~~~~~~~~~~~~
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h: In function ‘void c10::cast_and_store(c10::ScalarType, void*, src_t) [with src_t = c10::quint4x2]’:
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h:112:1: error: ‘__assert_fail’ was not declared in this scope; did you mean ‘__assert_func’?
112 | AT_FORALL_QINT_TYPES(DEFINE_UNCASTABLE)
| ^~~~~~~~~~~~~~~~~~~~
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h: In function ‘dest_t c10::fetch_and_cast(c10::ScalarType, const void*) [with dest_t = c10::quint2x4]’:
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h:112:1: error: ‘__assert_fail’ was not declared in this scope; did you mean ‘__assert_func’?
112 | AT_FORALL_QINT_TYPES(DEFINE_UNCASTABLE)
| ^~~~~~~~~~~~~~~~~~~~
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h: In function ‘void c10::cast_and_store(c10::ScalarType, void*, src_t) [with src_t = c10::quint2x4]’:
C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/include/c10/core/DynamicCast.h:112:1: error: ‘__assert_fail’ was not declared in this scope; did you mean ‘__assert_func’?
112 | AT_FORALL_QINT_TYPES(DEFINE_UNCASTABLE)
| ^~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/MinEx.dir/build.make:77: CMakeFiles/MinEx.dir/MinEx.cpp.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/MinEx.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
THe setup is as follows: libtorch cpu version for windows downloaded from the pytorch homepage. gnu 11.3.0 as compiler. The Following Code shall be compiled:
#include <torch/torch.h>
#include <iostream>
int main() {
//torch::Tensor tensor = torch::rand({2, 3});
//std::cout << tensor << std::endl;
return 0;
}
the following CMakeLists.txt is used:
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(MinEx)
set(CMAKE_PREFIX_PATH "C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu/share/cmake/Torch")
set(TORCH_DIR "C:/Users/a/Desktop/MachineLearningDemos/libtorch_cpu")
find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
add_executable(MinEx MinEx.cpp)
target_link_libraries(MinEx "${TORCH_LIBRARIES}")
set_property(TARGET MinEx PROPERTY CXX_STANDARD 14)
if (MSVC)
file(GLOB TORCH_DLLS "${TORCH_INSTALL_PREFIX}/lib/*.dll")
add_custom_command(TARGET MinEx
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${TORCH_DLLS}
$<TARGET_FILE_DIR:MinEx>)
endif (MSVC)
i compile with cmake --build . --config Release and then this error occurs.
Has anyone got an idea, where this comes from? (I tried to follow the example from https://pytorch.org/cppdocs/installing.html)
I checked if G++/make/cmake is working correctly (reinstalled everything) and if the libraries are the right ones. As soon as I try to include <torch/torch.h> the error occurs.
The newest version of OpenCV(4) does not come with createsamples feature for creating HAAR CASCADE files. It's just mind boggling. To attain this feature, there are two solutions: 1) Download an older version on a different machine or 2) Compile createsamples.cpp I am choosing item two as anyone can settle for kluge anytime. Item two comes with many errors that look the same as shown below:
harry#harry-usedmachine:/usr/include/opencv4$ sudo g++ createsamples.cpp
[sudo] password for harry:
In file included from createsamples.cpp:48:
/usr/include/opencv4/opencv2/core.hpp:2523:16: error: ‘FileStorage’ has not been declared
2523 | void write(FileStorage& fs) const;
| ^~~~~~~~~~~
/usr/include/opencv4/opencv2/core.hpp:2573:15: error: ‘FileStorage’ has not been declared
2573 | void save(FileStorage& fs) const;
| ^~~~~~~~~~~
/usr/include/opencv4/opencv2/core.hpp:2577:21: error: ‘FileStorage’ does not name a type
2577 | void load(const FileStorage& node);
| ^~~~~~~~~~~
/usr/include/opencv4/opencv2/core.hpp:3088:24: error: ‘FileStorage’ has not been declared
3088 | virtual void write(FileStorage& fs) const { CV_UNUSED(fs); }
| ^~~~~~~~~~~
/usr/include/opencv4/opencv2/core.hpp:3093:34: error: ‘FileStorage’ was not declared in this scope
3093 | CV_WRAP void write(const Ptr<FileStorage>& fs, const String& name = String()) const;
| ^~~~~~~~~~~
/usr/include/opencv4/opencv2/core.hpp:3093:45: error: template argument 1 is invalid
3093 | CV_WRAP void write(const Ptr<FileStorage>& fs, const String& name = String()) const;
| ^
/usr/include/opencv4/opencv2/core.hpp:3172:22: error: ‘FileStorage’ has not been declared
3172 | void writeFormat(FileStorage& fs) const;
| ^~~~~~~~~~~
/usr/include/opencv4/opencv2/core.hpp: In static member function ‘static cv::Ptr<_Tp> cv::Algorithm::load(const String&, const String&)’:
/usr/include/opencv4/opencv2/core.hpp:3135:9: error: ‘FileStorage’ was not declared in this scope
3135 | FileStorage fs(filename, FileStorage::READ);
| ^~~~~~~~~~~
In file included from /usr/include/opencv4/opencv2/core.hpp:55,
from createsamples.cpp:48:
/usr/include/opencv4/opencv2/core.hpp:3136:19: error: ‘fs’ was not declared in this scope; did you mean ‘ffs’?
3136 | CV_Assert(fs.isOpened());
| ^~
/usr/include/opencv4/opencv2/core/base.hpp:342:38: note: in definition of macro ‘CV_Assert’
342 | #define CV_Assert( expr ) do { if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ ); } while(0)
| ^~~~
In file included from createsamples.cpp:48:
/usr/include/opencv4/opencv2/core.hpp:3137:41: error: ‘fs’ was not declared in this scope; did you mean ‘ffs’?
3137 | FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname];
| ^~
| ffs
/usr/include/opencv4/opencv2/core.hpp:3137:18: error: ‘fn’ has incomplete type
3137 | FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname];
| ^~
In file included from /usr/include/opencv4/opencv2/core/base.hpp:58,
from /usr/include/opencv4/opencv2/core.hpp:55,
from createsamples.cpp:48:
/usr/include/opencv4/opencv2/core/cvstd.hpp:150:18: note: forward declaration of ‘class cv::FileNode’
150 | class CV_EXPORTS FileNode; //for string constructor from FileNode
| ^~~~~~~~
In file included from createsamples.cpp:48:
/usr/include/opencv4/opencv2/core.hpp: In static member function ‘static cv::Ptr<_Tp> cv::Algorithm::loadFromString(const String&, const String&)’:
/usr/include/opencv4/opencv2/core.hpp:3156:9: error: ‘FileStorage’ was not declared in this scope
3156 | FileStorage fs(strModel, FileStorage::READ + FileStorage::MEMORY);
| ^~~~~~~~~~~
/usr/include/opencv4/opencv2/core.hpp:3157:41: error: ‘fs’ was not declared in this scope; did you mean ‘ffs’?
3157 | FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname];
| ^~
| ffs
Many of the errors are coming from core.hpp and createsample.cpp. createsample.cpp is here: https://github.com/opencv/opencv/blob/master/apps/createsamples/createsamples.cpp
and core.hpp is here: https://github.com/opencv/opencv/blob/master/modules/core/include/opencv2/core.hpp
Would much appreciate any insights on fixing these errors.
Easiest way seems to be downloading an older opencv version source code like https://github.com/opencv/opencv/archive/2.4.13.6.zip and extract it to any location. In that folder perform
mkdir build
cd build
cmake ..
make
cd bin
there you will find the binaries of opencv_createsamples, opencv_traincascade etc.
It is NOT necessary to install that old version (that would happen if you use 'make install' ), just use your currently installed opencv build of any version for all tasks and if you need to create sample or train a cascade, use this build at the directory where you copy it to.
The QT Object header and source are just the auto generated ones when you add a new file. I have multiple other files in this project that build and run just fine if I don’t add any new Q_OBJECT files but as soon as I add a new Q_OBJECT the MOC starts throwing the error listed below. I am fairly new to CMAKE and QT so I am sure I am doing something dumb but I don’t understand how adding a new file autogenerated file ( That I have used for all the other files in the project and those work fine) can cause all the error below. I suspect something is up with my CMAKE configuration but it works for the other files I have in the project. Any help is appreciated.
07:34:55: Running steps for project NitrOS...
07:34:55: Starting: "/home/ajdecker/Qt/Tools/CMake/bin/cmake" --build /home/ajdecker/Documents/build-NitrOS-Desktop_Qt_6_1_0_GCC_64bit-Debug --target all
[0/2 ?/sec] Re-checking globbed directories...
[1/28 80.5/sec] Building CXX object libs/VehicleCommunication/CMakeFiles/VehicleCommunication.dir/src/protocol/protocols/can.cpp.o
[2/28 102.8/sec] Building CXX object libs/VehicleCommunication/CMakeFiles/VehicleCommunication.dir/VehicleCommunication_autogen/mocs_compilation.cpp.o
[3/28 8.1/sec] Automatic MOC and UIC for target gauge-ui
[4/28 10.7/sec] Automatic RCC for Configuration/configuration.qrc
[5/28 13.3/sec] Automatic RCC for Presentation/qml.qrc
[6/28 15.9/sec] Automatic RCC for Presentation/GaugeStyles/gaugestyles.qrc
[7/28 18.3/sec] Automatic RCC for Resources/resources.qrc
[8/28 3.7/sec] Building CXX object apps/gauge-ui/CMakeFiles/gauge-ui.dir/src/Models/DataProvider.cpp.o
[9/28 2.5/sec] Building CXX object libs/VehicleCommunication/CMakeFiles/VehicleCommunication.dir/src/protocol/protocols/simulator.cpp.o
[10/28 2.6/sec] Building CXX object libs/VehicleCommunication/CMakeFiles/VehicleCommunication.dir/src/protocol/protocols/isotp.cpp.o
/home/ajdecker/Documents/NitrOS/libs/VehicleCommunication/src/protocol/protocols/isotp.cpp: In member function ‘virtual bool NitrOS::Vehicle::Protocol::Protocols::ISOTPProtocol::SendMessage(NitrOS::Vehicle::Protocol::BaseVehicleProtocolMessage&)’:
/home/ajdecker/Documents/NitrOS/libs/VehicleCommunication/src/protocol/protocols/isotp.cpp:77:41: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘std::vector<unsigned char>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
77 | fprintf(stderr, "wrote only %d from %d byte\n", retval, msg.GetMessageData().size());
| ~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| int std::vector<unsigned char>::size_type {aka long unsigned int}
| %ld
[11/28 2.4/sec] Building CXX object apps/gauge-ui/CMakeFiles/gauge-ui.dir/gauge-ui_autogen/mocs_compilation.cpp.o
FAILED: apps/gauge-ui/CMakeFiles/gauge-ui.dir/gauge-ui_autogen/mocs_compilation.cpp.o
/usr/bin/g++ -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_OPENGL_LIB -DQT_QMLMODELS_LIB -DQT_QML_DEBUG -DQT_QML_LIB -DQT_QUICK_LIB -Iapps/gauge-ui -I/home/ajdecker/Documents/NitrOS/apps/gauge-ui -Iapps/gauge-ui/gauge-ui_autogen/include -I/home/ajdecker/Documents/NitrOS/apps/gauge-ui/include -I_deps/json-src/single_include -isystem /home/ajdecker/Qt/6.1.0/gcc_64/include/QtCore -isystem /home/ajdecker/Qt/6.1.0/gcc_64/include -isystem /home/ajdecker/Qt/6.1.0/gcc_64/mkspecs/linux-g++ -isystem /home/ajdecker/Qt/6.1.0/gcc_64/include/QtQuick -isystem /home/ajdecker/Qt/6.1.0/gcc_64/include/QtGui -isystem /home/ajdecker/Qt/6.1.0/gcc_64/include/QtQml -isystem /home/ajdecker/Qt/6.1.0/gcc_64/include/QtNetwork -isystem /home/ajdecker/Qt/6.1.0/gcc_64/include/QtQmlModels -isystem /home/ajdecker/Qt/6.1.0/gcc_64/include/QtOpenGL -g -D DEBUG -fPIC -Wno-error=invalid-offsetof -pthread -std=gnu++17 -MD -MT apps/gauge-ui/CMakeFiles/gauge-ui.dir/gauge-ui_autogen/mocs_compilation.cpp.o -MF apps/gauge-ui/CMakeFiles/gauge-ui.dir/gauge-ui_autogen/mocs_compilation.cpp.o.d -o apps/gauge-ui/CMakeFiles/gauge-ui.dir/gauge-ui_autogen/mocs_compilation.cpp.o -c apps/gauge-ui/gauge-ui_autogen/mocs_compilation.cpp
In file included from apps/gauge-ui/gauge-ui_autogen/mocs_compilation.cpp:6:
apps/gauge-ui/gauge-ui_autogen/RYCJYGFP3B/moc_InstalledDataProvidersModel.cpp:55:6: error: ‘InstalledDataProvidersModel’ has not been declared
55 | void InstalledDataProvidersModel::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
apps/gauge-ui/gauge-ui_autogen/RYCJYGFP3B/moc_InstalledDataProvidersModel.cpp:63:19: error: ‘InstalledDataProvidersModel’ has not been declared
63 | const QMetaObject InstalledDataProvidersModel::staticMetaObject = { {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
apps/gauge-ui/gauge-ui_autogen/RYCJYGFP3B/moc_InstalledDataProvidersModel.cpp:74:20: error: ‘InstalledDataProvidersModel’ has not been declared
74 | const QMetaObject *InstalledDataProvidersModel::metaObject() const
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
apps/gauge-ui/gauge-ui_autogen/RYCJYGFP3B/moc_InstalledDataProvidersModel.cpp:74:62: error: non-member function ‘const QMetaObject* metaObject()’ cannot have cv-qualifier
74 | const QMetaObject *InstalledDataProvidersModel::metaObject() const
| ^~~~~
apps/gauge-ui/gauge-ui_autogen/RYCJYGFP3B/moc_InstalledDataProvidersModel.cpp: In function ‘const QMetaObject* metaObject()’:
apps/gauge-ui/gauge-ui_autogen/RYCJYGFP3B/moc_InstalledDataProvidersModel.cpp:76:21: error: ‘QScopedPointer<QObjectData> QObject::d_ptr’ is protected within this context
76 | return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
| ^~~~~
In file included from /home/ajdecker/Qt/6.1.0/gcc_64/include/QtCore/QObject:1,
from apps/gauge-ui/gauge-ui_autogen/6YEA5652QU/../../../../../NitrOS/apps/gauge-ui/include/DataPresenter.h:4,
from apps/gauge-ui/gauge-ui_autogen/6YEA5652QU/moc_DataPresenter.cpp:10,
from apps/gauge-ui/gauge-ui_autogen/mocs_compilation.cpp:2:
/home/ajdecker/Qt/6.1.0/gcc_64/include/QtCore/qobject.h:413:33: note: declared protected here
413 | QScopedPointer<QObjectData> d_ptr;
| ^~~~~
In file included from apps/gauge-ui/gauge-ui_autogen/mocs_compilation.cpp:6:
apps/gauge-ui/gauge-ui_autogen/RYCJYGFP3B/moc_InstalledDataProvidersModel.cpp:76:21: error: invalid use of non-static data member ‘QObject::d_ptr’
76 | return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
| ^~~~~
In file included from /home/ajdecker/Qt/6.1.0/gcc_64/include/QtCore/QObject:1,
from apps/gauge-ui/gauge-ui_autogen/6YEA5652QU/../../../../../NitrOS/apps/gauge-ui/include/DataPresenter.h:4,
from apps/gauge-ui/gauge-ui_autogen/6YEA5652QU/moc_DataPresenter.cpp:10,
from apps/gauge-ui/gauge-ui_autogen/mocs_compilation.cpp:2:
/home/ajdecker/Qt/6.1.0/gcc_64/include/QtCore/qobject.h:413:33: note: declared here
413 | QScopedPointer<QObjectData> d_ptr;
| ^~~~~
In file included from apps/gauge-ui/gauge-ui_autogen/mocs_compilation.cpp:6:
apps/gauge-ui/gauge-ui_autogen/RYCJYGFP3B/moc_InstalledDataProvidersModel.cpp:76:50: error: ‘QScopedPointer<QObjectData> QObject::d_ptr’ is protected within this context
76 | return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
| ^~~~~
In file included from /home/ajdecker/Qt/6.1.0/gcc_64/include/QtCore/QObject:1,
from apps/gauge-ui/gauge-ui_autogen/6YEA5652QU/../../../../../NitrOS/apps/gauge-ui/include/DataPresenter.h:4,
from apps/gauge-ui/gauge-ui_autogen/6YEA5652QU/moc_DataPresenter.cpp:10,
from apps/gauge-ui/gauge-ui_autogen/mocs_compilation.cpp:2:
/home/ajdecker/Qt/6.1.0/gcc_64/include/QtCore/qobject.h:413:33: note: declared protected here
413 | QScopedPointer<QObjectData> d_ptr;
| ^~~~~
In file included from apps/gauge-ui/gauge-ui_autogen/mocs_compilation.cpp:6:
apps/gauge-ui/gauge-ui_autogen/RYCJYGFP3B/moc_InstalledDataProvidersModel.cpp:76:50: error: invalid use of non-static data member ‘QObject::d_ptr’
76 | return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
| ^~~~~
In file included from /home/ajdecker/Qt/6.1.0/gcc_64/include/QtCore/QObject:1,
from apps/gauge-ui/gauge-ui_autogen/6YEA5652QU/../../../../../NitrOS/apps/gauge-ui/include/DataPresenter.h:4,
from apps/gauge-ui/gauge-ui_autogen/6YEA5652QU/moc_DataPresenter.cpp:10,
from apps/gauge-ui/gauge-ui_autogen/mocs_compilation.cpp:2:
/home/ajdecker/Qt/6.1.0/gcc_64/include/QtCore/qobject.h:413:33: note: declared here
413 | QScopedPointer<QObjectData> d_ptr;
| ^~~~~
In file included from apps/gauge-ui/gauge-ui_autogen/mocs_compilation.cpp:6:
apps/gauge-ui/gauge-ui_autogen/RYCJYGFP3B/moc_InstalledDataProvidersModel.cpp: At global scope:
apps/gauge-ui/gauge-ui_autogen/RYCJYGFP3B/moc_InstalledDataProvidersModel.cpp:79:7: error: ‘InstalledDataProvidersModel’ has not been declared
79 | void *InstalledDataProvidersModel::qt_metacast(const char *_clname)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
apps/gauge-ui/gauge-ui_autogen/RYCJYGFP3B/moc_InstalledDataProvidersModel.cpp: In function ‘void* qt_metacast(const char*)’:
apps/gauge-ui/gauge-ui_autogen/RYCJYGFP3B/moc_InstalledDataProvidersModel.cpp:83:35: error: invalid use of ‘this’ in non-member function
83 | return static_cast<void*>(this);
| ^~~~
apps/gauge-ui/gauge-ui_autogen/RYCJYGFP3B/moc_InstalledDataProvidersModel.cpp:84:51: error: cannot call member function ‘virtual void* QAbstractListModel::qt_metacast(const char*)’ without object
84 | return QAbstractListModel::qt_metacast(_clname);
| ^
apps/gauge-ui/gauge-ui_autogen/RYCJYGFP3B/moc_InstalledDataProvidersModel.cpp: At global scope:
apps/gauge-ui/gauge-ui_autogen/RYCJYGFP3B/moc_InstalledDataProvidersModel.cpp:87:5: error: ‘InstalledDataProvidersModel’ has not been declared
87 | int InstalledDataProvidersModel::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
apps/gauge-ui/gauge-ui_autogen/RYCJYGFP3B/moc_InstalledDataProvidersModel.cpp: In function ‘int qt_metacall(QMetaObject::Call, int, void**)’:
apps/gauge-ui/gauge-ui_autogen/RYCJYGFP3B/moc_InstalledDataProvidersModel.cpp:89:54: error: cannot call member function ‘virtual int QAbstractListModel::qt_metacall(QMetaObject::Call, int, void**)’ without object
89 | _id = QAbstractListModel::qt_metacall(_c, _id, _a);
| ^
[12/28 2.3/sec] Building CXX object apps/gauge-ui/CMakeFiles/gauge-ui.dir/src/DataPresenter.cpp.o
[13/28 2.3/sec] Building CXX object apps/gauge-ui/CMakeFiles/gauge-ui.dir/src/Models/QQmlObjectListModel.cpp.o
[14/28 2.5/sec] Building CXX object apps/gauge-ui/CMakeFiles/gauge-ui.dir/src/Managers/GaugeManager.cpp.o
[15/28 2.4/sec] Building CXX object apps/gauge-ui/CMakeFiles/gauge-ui.dir/src/Models/InstalledDataPresentersModel.cpp.o
/home/ajdecker/Documents/NitrOS/apps/gauge-ui/src/Models/InstalledDataPresentersModel.cpp: In constructor ‘InstalledDataPresentersModel::InstalledDataPresentersModel(QObject*)’:
/home/ajdecker/Documents/NitrOS/apps/gauge-ui/src/Models/InstalledDataPresentersModel.cpp:13:21: warning: ‘std::istream& nlohmann::operator<<(nlohmann::basic_json<>&, std::istream&)’ is deprecated: Since 3.0.0 [-Wdeprecated-declarations]
13 | m_stylesJson << m_stylesFileStream;
| ^~~~~~~~~~~~~~~~~~
In file included from /home/ajdecker/Documents/NitrOS/apps/gauge-ui/include/Models/InstalledDataPresentersModel.h:5,
from /home/ajdecker/Documents/NitrOS/apps/gauge-ui/src/Models/InstalledDataPresentersModel.cpp:1:
_deps/json-src/single_include/nlohmann/json.hpp:20914:26: note: declared here
20914 | friend std::istream& operator<<(basic_json& j, std::istream& i)
| ^~~~~~~~
/home/ajdecker/Documents/NitrOS/apps/gauge-ui/src/Models/InstalledDataPresentersModel.cpp:13:21: warning: ‘std::istream& nlohmann::operator<<(nlohmann::basic_json<>&, std::istream&)’ is deprecated: Since 3.0.0 [-Wdeprecated-declarations]
13 | m_stylesJson << m_stylesFileStream;
| ^~~~~~~~~~~~~~~~~~
In file included from /home/ajdecker/Documents/NitrOS/apps/gauge-ui/include/Models/InstalledDataPresentersModel.h:5,
from /home/ajdecker/Documents/NitrOS/apps/gauge-ui/src/Models/InstalledDataPresentersModel.cpp:1:
_deps/json-src/single_include/nlohmann/json.hpp:20914:26: note: declared here
20914 | friend std::istream& operator<<(basic_json& j, std::istream& i)
| ^~~~~~~~
[16/28 2.3/sec] Building CXX object apps/gauge-ui/CMakeFiles/gauge-ui.dir/src/Models/InstalledDataProvidersModel.cpp.o
[17/28 2.0/sec] Building CXX object apps/gauge-ui/CMakeFiles/gauge-ui.dir/src/main.cpp.o
[18/28 2.1/sec] Building CXX object libs/VehicleCommunication/CMakeFiles/VehicleCommunication.dir/src/obd.cpp.o
ninja: build stopped: subcommand failed.
07:35:04: The process "/home/ajdecker/Qt/Tools/CMake/bin/cmake" exited with code 1.
Error while building/deploying project NitrOS (kit: Desktop Qt 6.1.0 GCC 64bit)
When executing step "Build"
07:35:04: Elapsed time: 00:09
The top level CMAKE file
cmake_minimum_required(VERSION 3.14)
project(NitrOS LANGUAGES CXX)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_compile_options(-D DEBUG)
add_subdirectory(apps)
add_subdirectory(libs)
add_subdirectory(tests)
add_subdirectory(docs)
And the CMAKE file that builds the QT application in question:
include(FetchContent)
file(GLOB GAUGE_UI_PROJECT_SOURCES CONFIGURE_DEPENDS
"${NitrOS_SOURCE_DIR}/apps/gauge-ui/Configuration/*.qrc"
"${NitrOS_SOURCE_DIR}/apps/gauge-ui/Presentation/*.qrc"
"${NitrOS_SOURCE_DIR}/apps/gauge-ui/Presentation/GaugeStyles/*.qrc"
"${NitrOS_SOURCE_DIR}/apps/gauge-ui/Resources/*.qrc"
"${NitrOS_SOURCE_DIR}/apps/gauge-ui/src/*.cpp"
"${NitrOS_SOURCE_DIR}/apps/gauge-ui/src/Models/*.cpp"
"${NitrOS_SOURCE_DIR}/apps/gauge-ui/src/Managers/*.cpp"
)
file(GLOB GAUGE_UI_PROJECT_HEADERS CONFIGURE_DEPENDS
"${NitrOS_SOURCE_DIR}/apps/gauge-ui/include/*.h"
"${NitrOS_SOURCE_DIR}/apps/gauge-ui/include/Models/*.h"
"${NitrOS_SOURCE_DIR}/apps/gauge-ui/include/Managers/*.h"
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(gauge-ui
${GAUGE_UI_PROJECT_SOURCES}
${GAUGE_UI_PROJECT_HEADERS}
)
else()
if(ANDROID)
add_library(gauge-ui SHARED
${GAUGE_UI_PROJECT_SOURCES}
)
else()
add_executable(gauge-ui
${GAUGE_UI_PROJECT_SOURCES}
${GAUGE_UI_PROJECT_HEADERS}
)
endif()
endif()
FetchContent_Declare(json
GIT_REPOSITORY https://github.com/nlohmann/json
GIT_TAG v3.7.3)
FetchContent_GetProperties(json)
if(NOT json_POPULATED)
FetchContent_Populate(json)
add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
set(JSON_BuildTests OFF CACHE INTERNAL "")
target_compile_definitions(gauge-ui
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
target_include_directories(gauge-ui PUBLIC "${NitrOS_SOURCE_DIR}/apps/gauge-ui/include/")
target_link_libraries(gauge-ui
PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Quick PRIVATE nlohmann_json::nlohmann_json)
I've built the cross toolchain for Linux under CYGWIN environment using the article at https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/ as a source.
Compilation and installation finished with success.
Used components are:
binutils-2.35
cloog-0.18.1
gcc-10.2.0
glibc-2.32
gmp-6.1.2
isl-0.20
linux-5.9.3
mpc-1.1.0
mpfr-4.0.2
GCC is configured as:
$ x86_64-unknown-linux-gnu-g++ --verbose
Using built-in specs.
COLLECT_GCC=x86_64-unknown-linux-gnu-g++
COLLECT_LTO_WRAPPER=/opt/cross/x86_64-unknown-linux-gnu/libexec/gcc/x86_64-unknown-linux-
gnu/10.2.0/lto-wrapper.exe
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-10.2.0/configure --prefix=/opt/cross/x86_64-unknown-linux-gnu --
target=x86_64-unknown-linux-gnu --enable-languages=c,c++ --disable-nls --disable-multilib --with-
headers=/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/linux
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (GCC)
But when I'm trying to compile the simple Hello World application that includes I'm getting a lot of different errors:
$ x86_64-unknown-linux-gnu-g++ main.cpp
In file included from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/x86_64-unknown-linux-gnu/bits/gthr-default.h:35,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/x86_64-unknown-linux-gnu/bits/gthr.h:148,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ext/atomicity.h:35,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/bits/ios_base.h:39,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ios:42,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ostream:38,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/iostream:39,
from main.cpp:1:
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/pthread.h:240:34: error: 'clockid_t' has not been declared
240 | clockid_t __clockid,
| ^~~~~~~~~
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/pthread.h:375:12: error: 'cpu_set_t' does not name a type
375 | const cpu_set_t *__cpuset)
| ^~~~~~~~~
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/pthread.h:382:6: error: 'cpu_set_t' has not been declared
382 | cpu_set_t *__cpuset)
| ^~~~~~~~~
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/pthread.h:466:14: error: 'cpu_set_t' does not name a type
466 | const cpu_set_t *__cpuset)
| ^~~~~~~~~
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/pthread.h:471:8: error: 'cpu_set_t' has not been declared
471 | cpu_set_t *__cpuset)
| ^~~~~~~~~
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/pthread.h:765:9: error: 'clockid_t' has not been declared
765 | clockid_t __clockid,
| ^~~~~~~~~
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/pthread.h:911:12: error: 'clockid_t' has not been declared
911 | clockid_t __clockid,
| ^~~~~~~~~
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/pthread.h:933:12: error: 'clockid_t' has not been declared
933 | clockid_t __clockid,
| ^~~~~~~~~
In file included from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/x86_64-unknown-linux-gnu/bits/gthr.h:148,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ext/atomicity.h:35,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/bits/ios_base.h:39,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ios:42,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ostream:38,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/iostream:39,
from main.cpp:1:
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/x86_64-unknown-linux-gnu/bits/gthr-default.h:114:1: error: 'sched_yield' was not declared in this scope; did you mean 'pthread_yield'?
114 | __gthrw(sched_yield)
| ^~~~~~~
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/x86_64-unknown-linux-gnu/bits/gthr-default.h:114:1: error: 'sched_yield' was not declared in this scope; did you mean 'pthread_yield'?
114 | __gthrw(sched_yield)
| ^~~~~~~
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/x86_64-unknown-linux-gnu/bits/gthr-default.h: In function 'int __gthread_yield()':
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/x86_64-unknown-linux-gnu/bits/gthr-default.h:693:33: error: '__gthrw_sched_yield' cannot be used as a function
693 | return __gthrw_(sched_yield) ();
| ^
In file included from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/sys/select.h:37,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/sys/types.h:179,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/stdlib.h:394,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/cstdlib:75,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ext/string_conversions.h:41,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/bits/basic_string.h:6535,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/string:55,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/bits/locale_classes.h:40,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/bits/ios_base.h:41,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ios:42,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ostream:38,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/iostream:39,
from main.cpp:1:
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/bits/types/struct_timeval.h: At global scope:
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/bits/types/struct_timeval.h:8:8: error: redefinition of 'struct timeval'
8 | struct timeval
| ^~~~~~~
In file included from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/pthread.h:23,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/x86_64-unknown-linux-gnu/bits/gthr-default.h:35,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/x86_64-unknown-linux-gnu/bits/gthr.h:148,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ext/atomicity.h:35,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/bits/ios_base.h:39,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ios:42,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ostream:38,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/iostream:39,
from main.cpp:1:
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/sys-include/time.h:16:8: note: previous definition of 'struct timeval'
16 | struct timeval {
| ^~~~~~~
In file included from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ext/string_conversions.h:44,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/bits/basic_string.h:6535,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/string:55,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/bits/locale_classes.h:40,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/bits/ios_base.h:41,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ios:42,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ostream:38,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/iostream:39,
from main.cpp:1:
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ext/string_conversions.h: In constructor '__gnu_cxx::__stoa(_TRet (*)(const _CharT*, _CharT**, _Base ...), const char*, const _CharT*, std::size_t*, _Base ...)::_Save_errno::_Save_errno()':
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ext/string_conversions.h:63:27: error: 'errno' was not declared in this scope
63 | _Save_errno() : _M_errno(errno) { errno = 0; }
| ^~~~~
In file included from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/bits/basic_string.h:6535,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/string:55,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/bits/locale_classes.h:40,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/bits/ios_base.h:41,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ios:42,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ostream:38,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/iostream:39,
from main.cpp:1:
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ext/string_conversions.h:45:1: note: 'errno' is defined in header '<cerrno>'; did you forget to '#include <cerrno>'?
44 | #include <cerrno>
+++ |+#include <cerrno>
45 |
In file included from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ext/string_conversions.h:44,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/bits/basic_string.h:6535,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/string:55,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/bits/locale_classes.h:40,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/bits/ios_base.h:41,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ios:42,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ostream:38,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/iostream:39,
from main.cpp:1:
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ext/string_conversions.h: In destructor '__gnu_cxx::__stoa(_TRet (*)(const _CharT*, _CharT**, _Base ...), const char*, const _CharT*, std::size_t*, _Base ...)::_Save_errno::~_Save_errno()':
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ext/string_conversions.h:64:23: error: 'errno' was not declared in this scope
64 | ~_Save_errno() { if (errno == 0) errno = _M_errno; }
| ^~~~~
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ext/string_conversions.h:64:23: note: 'errno' is defined in header '<cerrno>'; did you forget to '#include <cerrno>'?
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ext/string_conversions.h: In function '_Ret __gnu_cxx::__stoa(_TRet (*)(const _CharT*, _CharT**, _Base ...), const char*, const _CharT*, std::size_t*, _Base ...)':
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ext/string_conversions.h:84:16: error: 'errno' was not declared in this scope
84 | else if (errno == ERANGE
| ^~~~~
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ext/string_conversions.h:84:16: note: 'errno' is defined in header '<cerrno>'; did you forget to '#include <cerrno>'?
In file included from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/system_error:39,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/bits/ios_base.h:46,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ios:42,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/ostream:38,
from /opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/iostream:39,
from main.cpp:1:
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/x86_64-unknown-linux-gnu/bits/error_constants.h: At global scope:
/opt/cross/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/include/c++/10.2.0/x86_64-unknown-linux-gnu/bits/error_constants.h:122:27: error: 'ENOTSUP' was not declared in this scope
122 | not_supported = ENOTSUP,
|
UPD: WSL and virtual machines are not an option in my case
I've managed to solve the issue.
The problem was in the sys-include directory
opt/cross/x86_64-unknown-linux-gnu/sys-include
This directory has include files with the same names as the ones from
opt/cross/x86_64-unknown-linux-gnu/include
but with different content.
The sys-include directory was searched by the compiler before the regular include.
Renaming or removing sys-include solves the issue and code can be compiled.
I don't know the purpose of the sys-include directory, when it was created and why the duplicated files in this directory have another content.
Accepting my own post as answer to indicate that the issue can be solved.
I am on arch and made the mistake of upgrading.
Before I could build bacward-cpp, now I get the following error:
../libraries/backward-cpp/backward.hpp:1357:10: error: ‘bfd_get_section_flags’ was not declared in this scope; did you mean ‘bfd_set_section_flags’?
1357 | if ((bfd_get_section_flags(fobj.handle.get(), section) & SEC_ALLOC) == 0)
| ^~~~~~~~~~~~~~~~~~~~~
| bfd_set_section_flags
../libraries/backward-cpp/backward.hpp:1360:24: error: ‘bfd_get_section_vma’ was not declared in this scope; did you mean ‘bfd_set_section_vma’?
1360 | bfd_vma sec_addr = bfd_get_section_vma(fobj.handle.get(), section);
| ^~~~~~~~~~~~~~~~~~~
| bfd_set_section_vma
../libraries/backward-cpp/backward.hpp:1361:26: error: ‘bfd_get_section_size’ was not declared in this scope; did you mean ‘bfd_set_section_size’?
1361 | bfd_size_type size = bfd_get_section_size(section);
| ^~~~~~~~~~~~~~~~~~~~
| bfd_set_section_size
make[1]: *** [VulkanEngine.make:233: obj/Debug/VulkanDebugging.o] Error 1
make: *** [Makefile:30: VulkanEngine] Error 2
I am linking with both lbdf and ldl, by doing -lbfd -ldl as arguments to g++. I am also doing #define BACKWARD_HAS_BFD 1 before including the header as per the documentation.
I am at a loss.
The corresponding macros of binutils changed slightly.
You have to drop the _get from the section macros and remove the fobj.handle.get() parameter manually: bfd_get_section_flags(fobj.handle.get(), section) to bfd_section_flags(section).