Linking Error cmake - Using CodeSynthesis XSD in cmake - c++

I have been trying to include Synthesis XSD into my project, but unfortunately, I have been dealing with a linking problem after I have generated my XML files into cxx files.
These are the lines in my CMakelist.txt files that should include and link the library into my executable.
NOTES:
For simplicity, I have added a hardcoded path to the installation directory of Synthesis XSD 4.0
I have Box2D and SDL included into my project and they always have worked before. You can ignore them in this code
cmake_minimum_required(VERSION 3.17)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CURRENT_BINARY_DIR ./build)
set(CMAKE_CURRENT_SOURCE_DIR .)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
add_executable(NightByte ./Main.cpp
# Game
./Game/Game.cpp
./Game/Components/Component.hpp
./Game/Components/RenderComponent.cpp
./Game/Components/RenderComponent.hpp
./Game/Components/WorldPositionComponent.cpp
./Game/Components/WorldPositionComponent.hpp
./Game/Scenes/Menu/MainMenu.hpp
# Engine
./Engine/Engine.cpp
./Engine/Audio/AudioFile.cpp
./Engine/Audio/AudioFile.h
./Engine/Input/Adapter/SDLInputEngineAdapter.cpp
./Engine/Audio/Adapter/SDLAudioEngineAdapter.cpp
./Engine/Audio/Adapter/SDLAudioEngineAdapter.hpp
./Engine/Rendering/Spritesheet.cpp
./Engine/Rendering/TextureManager.cpp
./Engine/Rendering/Adapter/SDLRenderingAdaper.cpp
# API
./API/Input/EngineInputAPI.cpp
./API/Audio/AudioAPI.cpp
./API/Rendering/EngineRenderingAPI.hpp
./API/Rendering/EngineRenderingAPI.cpp
./API/Engine/EngineWindowAPI.cpp
./API/Engine/WindowAPI.hpp
# XML
./Engine/Resources/XML/Generated/wall.hxx
./Engine/Resources/XML/Generated/wall.cxx
./Engine/Resources/XML/Generated/common.hxx
./Engine/Resources/XML/Generated/common.cxx
)
find_package(box2d REQUIRED)
target_include_directories(NightByte PUBLIC
${SDL2_SOURCE_DIR}/include
${BOX2D_SOURCE_DIR}/include/box2d
${SDL2IMAGE_SOURCE_DIR}
"C:/Program Files (x86)/CodeSynthesis XSD 4.0/include/")
add_library(xerces "C:/Program Files (x86)/CodeSynthesis XSD 4.0/bin64/xerces-c_3_1D_vc120.dll"
"C:/Program Files (x86)/CodeSynthesis XSD 4.0/bin64/xerces-c_3_1_vc120.dll"
"C:/Program Files (x86)/CodeSynthesis XSD 4.0/lib64/vc-12.0/xerces-c_3.lib")
set_target_properties(xerces PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(NightByte SDL2 box2d SDL2::image xerces)
This is the error I get when compiling the generated XML files:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj): in function `xsd::cxx::xml::initialize()':
C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/elements.hxx:84: undefined reference to `__imp__ZN11xercesc_3_16XMLUni22fgXercescDefaultLocaleE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/elements.hxx:84: undefined reference to `__imp__ZN11xercesc_3_116XMLPlatformUtils10InitializeEPKcS2_PNS_12PanicHandlerEPNS_13MemoryManagerE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj): in function `xsd::cxx::xml::terminate()':
C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/elements.hxx:90: undefined reference to `__imp__ZN11xercesc_3_116XMLPlatformUtils9TerminateEv'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj): in function `xercesc_3_1::DOMErrorHandler::DOMErrorHandler()':
C:/PROGRA~2/CODESY~1.0/include/xercesc/dom/DOMErrorHandler.hpp:54: undefined reference to `__imp__ZTVN11xercesc_3_115DOMErrorHandlerE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj): in function `xercesc_3_1::DOMErrorHandler::~DOMErrorHandler()':
C:/PROGRA~2/CODESY~1.0/include/xercesc/dom/DOMErrorHandler.hpp:77: undefined reference to `__imp__ZTVN11xercesc_3_115DOMErrorHandlerE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj): in function `xsd::cxx::xml::sax::std_input_stream::std_input_stream(std::istream&)':
C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/sax/std-input-source.hxx:27: undefined reference to `__imp__ZN11xercesc_3_114BinInputStreamC2Ev'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj): in function `xsd::cxx::xml::sax::std_input_source::std_input_source(std::istream&)':
C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/sax/std-input-source.hxx:87: undefined reference to `__imp__ZN11xercesc_3_116XMLPlatformUtils15fgMemoryManagerE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/sax/std-input-source.hxx:87: undefined reference to `__imp__ZN11xercesc_3_111InputSourceC2EPNS_13MemoryManagerE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj): in function `xsd::cxx::xml::sax::std_input_source::makeStream() const':
C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/sax/std-input-source.hxx:141: undefined reference to `__imp__ZN11xercesc_3_17XMemorynwEy'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/sax/std-input-source.hxx:141: undefined reference to `__imp__ZN11xercesc_3_17XMemorydlEPv'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj): in function `std::unique_ptr<xercesc_3_1::DOMDocument, xsd::cxx::xml::dom::deleter<xercesc_3_1::DOMDocument> > xsd::cxx::xml::dom::create_document<char>()':
C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/wildcard-source.txx:29: undefined reference to `__imp__ZN11xercesc_3_125DOMImplementationRegistry20getDOMImplementationEPKt'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/wildcard-source.txx:32: undefined reference to `__imp__ZN11xercesc_3_116XMLPlatformUtils15fgMemoryManagerE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj): in function `std::unique_ptr<xercesc_3_1::DOMDocument, xsd::cxx::xml::dom::deleter<xercesc_3_1::DOMDocument> > xsd::cxx::xml::dom::parse<char>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, xercesc_3_1::DOMErrorHandler&, xsd::cxx::xml::properties<char> const&, unsigned long)':
C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:264: undefined reference to `__imp__ZN11xercesc_3_125DOMImplementationRegistry20getDOMImplementationEPKt'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:266: undefined reference to `__imp__ZN11xercesc_3_116XMLPlatformUtils15fgMemoryManagerE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:273: undefined reference to `__imp__ZN11xercesc_3_16XMLUni13fgDOMCommentsE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:277: undefined reference to `__imp__ZN11xercesc_3_16XMLUni26fgDOMDatatypeNormalizationE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:284: undefined reference to `__imp__ZN11xercesc_3_16XMLUni13fgDOMEntitiesE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:288: undefined reference to `__imp__ZN11xercesc_3_16XMLUni15fgDOMNamespacesE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:292: undefined reference to `__imp__ZN11xercesc_3_16XMLUni29fgDOMElementContentWhitespaceE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:296: undefined reference to `__imp__ZN11xercesc_3_16XMLUni13fgDOMValidateE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:297: undefined reference to `__imp__ZN11xercesc_3_16XMLUni14fgXercesSchemaE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:298: undefined reference to `__imp__ZN11xercesc_3_16XMLUni26fgXercesSchemaFullCheckingE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:302: undefined reference to `__imp__ZN11xercesc_3_16XMLUni13fgDOMValidateE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:303: undefined reference to `__imp__ZN11xercesc_3_16XMLUni14fgXercesSchemaE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:310: undefined reference to `__imp__ZN11xercesc_3_16XMLUni29fgXercesHandleMultipleImportsE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:317: undefined reference to `__imp__ZN11xercesc_3_16XMLUni26fgXercesSchemaFullCheckingE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:322: undefined reference to `__imp__ZN11xercesc_3_16XMLUni29fgXercesUserAdoptsDOMDocumentE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:333: undefined reference to `__imp__ZN11xercesc_3_16XMLUni36fgXercesSchemaExternalSchemaLocationE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:343: undefined reference to `__imp__ZN11xercesc_3_16XMLUni47fgXercesSchemaExternalNoNameSpaceSchemaLocationE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:355: undefined reference to `__imp__ZN11xercesc_3_16XMLUni18fgXercesLoadSchemaE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:361: undefined reference to `__imp__ZN11xercesc_3_16XMLUni17fgDOMErrorHandlerE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj): in function `xsd::cxx::xml::sax::std_input_source::std_input_source<char>(std::istream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/sax/std-input-source.hxx:102: undefined reference to `__imp__ZN11xercesc_3_116XMLPlatformUtils15fgMemoryManagerE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/sax/std-input-source.hxx:102: undefined reference to `__imp__ZN11xercesc_3_111InputSourceC2EPKtPNS_13MemoryManagerE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj): in function `std::unique_ptr<xercesc_3_1::DOMDocument, xsd::cxx::xml::dom::deleter<xercesc_3_1::DOMDocument> > xsd::cxx::xml::dom::parse<char>(xercesc_3_1::InputSource&, xercesc_3_1::DOMErrorHandler&, xsd::cxx::xml::properties<char> const&, unsigned long)':
C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:120: undefined reference to `__imp__ZN11xercesc_3_125DOMImplementationRegistry20getDOMImplementationEPKt'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:122: undefined reference to `__imp__ZN11xercesc_3_116XMLPlatformUtils15fgMemoryManagerE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:129: undefined reference to `__imp__ZN11xercesc_3_16XMLUni13fgDOMCommentsE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:133: undefined reference to `__imp__ZN11xercesc_3_16XMLUni26fgDOMDatatypeNormalizationE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:140: undefined reference to `__imp__ZN11xercesc_3_16XMLUni13fgDOMEntitiesE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:144: undefined reference to `__imp__ZN11xercesc_3_16XMLUni15fgDOMNamespacesE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:148: undefined reference to `__imp__ZN11xercesc_3_16XMLUni29fgDOMElementContentWhitespaceE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:152: undefined reference to `__imp__ZN11xercesc_3_16XMLUni13fgDOMValidateE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:153: undefined reference to `__imp__ZN11xercesc_3_16XMLUni14fgXercesSchemaE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:154: undefined reference to `__imp__ZN11xercesc_3_16XMLUni26fgXercesSchemaFullCheckingE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:158: undefined reference to `__imp__ZN11xercesc_3_16XMLUni13fgDOMValidateE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:159: undefined reference to `__imp__ZN11xercesc_3_16XMLUni14fgXercesSchemaE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:166: undefined reference to `__imp__ZN11xercesc_3_16XMLUni29fgXercesHandleMultipleImportsE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:172: undefined reference to `__imp__ZN11xercesc_3_16XMLUni26fgXercesSchemaFullCheckingE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:177: undefined reference to `__imp__ZN11xercesc_3_16XMLUni29fgXercesUserAdoptsDOMDocumentE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:188: undefined reference to `__imp__ZN11xercesc_3_16XMLUni36fgXercesSchemaExternalSchemaLocationE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:198: undefined reference to `__imp__ZN11xercesc_3_16XMLUni47fgXercesSchemaExternalNoNameSpaceSchemaLocationE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:210: undefined reference to `__imp__ZN11xercesc_3_16XMLUni18fgXercesLoadSchemaE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:216: undefined reference to `__imp__ZN11xercesc_3_16XMLUni17fgDOMErrorHandlerE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:218: undefined reference to `__imp__ZN11xercesc_3_116XMLPlatformUtils15fgMemoryManagerE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:218: undefined reference to `__imp__ZN11xercesc_3_119Wrapper4InputSourceC1EPNS_11InputSourceEbPNS_13MemoryManagerE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:218: undefined reference to `__imp__ZN11xercesc_3_119Wrapper4InputSourceD1Ev'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/dom/parsing-source.txx:218: undefined reference to `__imp__ZN11xercesc_3_119Wrapper4InputSourceD1Ev'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj):wall.cxx:(.rdata$_ZTVN3xsd3cxx3xml3sax16std_input_sourceE[_ZTVN3xsd3cxx3xml3sax16std_input_sourceE]+0x48): undefined reference to `xercesc_3_1::InputSource::setEncoding(unsigned short const*)'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj):wall.cxx:(.rdata$_ZTVN3xsd3cxx3xml3sax16std_input_sourceE[_ZTVN3xsd3cxx3xml3sax16std_input_sourceE]+0x50): undefined reference to `xercesc_3_1::InputSource::setPublicId(unsigned short const*)'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj):wall.cxx:(.rdata$_ZTVN3xsd3cxx3xml3sax16std_input_sourceE[_ZTVN3xsd3cxx3xml3sax16std_input_sourceE]+0x58): undefined reference to `xercesc_3_1::InputSource::setSystemId(unsigned short const*)'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj): in function `xsd::cxx::xml::sax::std_input_source::~std_input_source()':
C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/sax/std-input-source.hxx:83: undefined reference to `__imp__ZN11xercesc_3_111InputSourceD2Ev'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj): in function `xsd::cxx::xml::sax::std_input_source::~std_input_source()':
C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/sax/std-input-source.hxx:83: undefined reference to `__imp__ZN11xercesc_3_17XMemorydlEPv'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj): in function `xsd::cxx::xml::sax::std_input_stream::~std_input_stream()':
C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/sax/std-input-source.hxx:23: undefined reference to `__imp__ZN11xercesc_3_114BinInputStreamD2Ev'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj): in function `xsd::cxx::xml::sax::std_input_stream::~std_input_stream()':
C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/sax/std-input-source.hxx:23: undefined reference to `__imp__ZN11xercesc_3_17XMemorydlEPv'
collect2.exe: error: ld returned 1 exit status
Update 1:
To make the case easier to understand, I have added the .lib file for this library next to the DLL's
Update 2:
I have changed the add_library to:
add_library(xerces SHARED IMPORTED GLOBAL)
set_target_properties(xerces PROPERTIES IMPORTED_IMPLIB "C:/Program Files (x86)/CodeSynthesis XSD 4.0/lib64/vc-12.0/xerces-c_3.lib")
set_target_properties(xerces PROPERTIES IMPORTED_LOCATION "C:/Program Files (x86)/CodeSynthesis XSD 4.0/bin64/xerces-c_3_1_vc120.dll")
target_link_libraries(NightByte SDL2 box2d SDL2::image xerces)
But I still get the same linking CXX executable error:
[100%] Linking CXX executable bin\NightByte.exe
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj): in function `xsd::cxx::xml::initialize()':
C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/elements.hxx:84: undefined reference to `__imp__ZN11xercesc_3_16XMLUni22fgXercescDefaultLocaleE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/elements.hxx:84: undefined reference to `__imp__ZN11xercesc_3_116XMLPlatformUtils10InitializeEPKcS2_PNS_12PanicHandlerEPNS_13MemoryManagerE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj): in function `xsd::cxx::xml::terminate()':
C:/PROGRA~2/CODESY~1.0/include/xsd/cxx/xml/elements.hxx:90: undefined reference to `__imp__ZN11xercesc_3_116XMLPlatformUtils9TerminateEv'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj): in function `xercesc_3_1::DOMErrorHandler::DOMErrorHandler()':
C:/PROGRA~2/CODESY~1.0/include/xercesc/dom/DOMErrorHandler.hpp:54: undefined reference to `__imp__ZTVN11xercesc_3_115DOMErrorHandlerE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\NightByte.dir/objects.a(wall.cxx.obj): in function `xercesc_3_1::DOMErrorHandler::~DOMErrorHandler()':
C:/PROGRA~2/CODESY~1.0/include/xercesc/dom/DOMErrorHandler.hpp:77: undefined reference to `__imp__ZTVN11xercesc_3_115DOMErrorHandlerE'
[AND MORE]
Update 3
I have used find_package before and I am trying it now as well(As well the other method).
But in this scenario, I receive the following error when linking in make:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find C:/Program Files (x86)/CodeSynthesis XSD 4.0: Permission denied
With Verbose=1 in Make
[other executions by make]
[ 44%] Built target box2d
C:/Users/husey/scoop/apps/make/current/bin/make.exe -f CMakeFiles\NightByte.dir\build.make CMakeFiles/NightByte.dir/depend
make[2]: Entering directory 'C:/Users/husey/Desktop/engine/build'
D:\JetBrains\Toolbox\apps\CLion\ch-0\202.7660.37\bin\cmake\win\bin\cmake.exe -E cmake_depends "MinGW Makefiles" C:\Users\husey\Desktop\engine C:\Users\husey\Desktop\engine C:\Users\husey\Desktop\engine\build C:\Users\husey\Desktop\engine\build C:\Users\husey\Desktop\engine\build\CMakeFiles\NightByte.dir\DependInfo.cmake --color=
make[2]: Leaving directory 'C:/Users/husey/Desktop/engine/build'
C:/Users/husey/scoop/apps/make/current/bin/make.exe -f CMakeFiles\NightByte.dir\build.make CMakeFiles/NightByte.dir/build
make[2]: Entering directory 'C:/Users/husey/Desktop/engine/build'
[ 44%] Linking CXX executable bin\NightByte.exe
D:\JetBrains\Toolbox\apps\CLion\ch-0\202.7660.37\bin\cmake\win\bin\cmake.exe -E cmake_link_script CMakeFiles\NightByte.dir\link.txt --verbose=1
D:\JetBrains\Toolbox\apps\CLion\ch-0\202.7660.37\bin\cmake\win\bin\cmake.exe -E rm -f CMakeFiles\NightByte.dir/objects.a
C:\msys64\mingw64\bin\ar.exe cr CMakeFiles\NightByte.dir/objects.a #CMakeFiles\NightByte.dir\objects1.rsp
C:\msys64\mingw64\bin\g++.exe -g -Wl,--whole-archive CMakeFiles\NightByte.dir/objects.a -Wl,--no-whole-archive -o bin\NightByte.exe -Wl,--out-implib,libNightByte.dll.a -Wl,--major-image-version,0,--minor-image-version,0 #CMakeFiles\NightByte.dir\linklibs.rsp
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find C:/Program Files (x86)/CodeSynthesis XSD 4.0: Permission denied
collect2.exe: error: ld returned 1 exit status
make[2]: *** [CMakeFiles\NightByte.dir\build.make:366: bin/NightByte.exe] Error 1
make[2]: Leaving directory 'C:/Users/husey/Desktop/engine/build'
make[1]: *** [CMakeFiles\Makefile2:345: CMakeFiles/NightByte.dir/all] Error 2
make[1]: Leaving directory 'C:/Users/husey/Desktop/engine/build'
make: *** [Makefile:149: all] Error 2

For standard libraries like XercesC, CMake provides a standard way of "including" them into your project, i.e. find_package.
In your case, instead of manually adding_library, you should write something like this:
# omitted the first part of CMakeLists ....
find_package(box2d REQUIRED)
find_package(XercesC REQUIRED)
target_include_directories(NightByte PUBLIC
${SDL2_SOURCE_DIR}/include
${BOX2D_SOURCE_DIR}/include/box2d
${SDL2IMAGE_SOURCE_DIR}
)
target_link_libraries(NightByte SDL2 box2d SDL2::image XercesC::XercesC)
Note the following:
XercesC is searched for the same way as box2d
NightByte target is linked against the XercesC::XercesC. This is imported library, that is created by FindXercesC.cmake in case xercesc is found.
explicitly adding XercexC include directories is not necessary, since all compiling attributes are inherited from XercesC::XercesC when you link against it.
BTW, there are a couple of other issues with your CMakeLists.txt. on lines 3 and 4 you explicitly set CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR. In brief, don't do it, CMake automatically takes care of the values of those variables.
In the end, here is the documentation about find_package, XercesC module, and a list of readily available parkages in CMake (scroll down to "Find Modules" for a list).

Thank you guys for helping me out, without you I probably wouldn't have gotten further.
My problem was that I have been using the MinGW compiler but the CodeSynthesis libraries I got are built with Visual Studio's compiler.
I haven't been able to compile yet with MinGW but this problem is solved by using the Visual Studio Compiler.
For those who use the MinGW compiler, download the following:

Related

CMake C++ Project librealsense: undefined reference to OpenGL with CLion

I am trying to integrate librealsense C++ CLion Project on Ubuntu 20.04.
Compiling the Librealsense separately in the terminal works just as expected.
the Project looks like this:
RS_Pipeline
.
├── build
├── main.cpp
├── CMakeLists.txt
└── librealsense // the integrated lib
├── CMakeLists.txt
├── third-party // libs like GLFW and GLAD which are use in the examples
├── examples //
| ├── example.hpp // with class to generate OpenGL Window
└── ...
The CMakeLists.txt in the base Folder looks rather simple:
cmake_minimum_required(VERSION 3.2)
project(RS_Pipeline LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 11)
set(OpenGL_GL_PREFERENCE LEGACY)
add_executable(RS_Pipeline main.cpp librealsense/examples/example.hpp)
add_subdirectory(librealsense)
target_link_libraries(${PROJECT_NAME} realsense2)
As soon as i try to include the submodul into my CLion Project i get a ton of: main.cpp:(.text+0x23c): undefined reference to glViewport error messages and building my main.cpp in the base dir fails.
somehow the #include <librealsense2/rs.hpp> #include "librealsense/examples/example.hpp"
works fine and even the intellisense finds all the functions.
PLUS: the included examples within the librealsense Library also compile without any problem. (They use exactly the same #include "librealsense/examples/example.hpp".
It looks like, that CLion just dose not link find the right openGL in my own main.cpp resp. if i include it from example.hpp.
====================[ Build | RS_Pipeline | Release ]===========================
/snap/clion/175/bin/cmake/linux/bin/cmake --build /home/lukas/Development/Cpp/RS_Pipeline/cmake-build-release --target RS_Pipeline
[0/1] Re-running CMake...
-- Checking internet connection...
-- Internet connection identified
-- Info: REALSENSE_VERSION_STRING=2.50.0
-- Setting Unix configurations
-- Building libcurl enabled
-- using RS2_USE_V4L2_BACKEND
-- Could NOT find apriltag (missing: APRILTAG_INC APRILTAG_LIB)
-- Unable to find apriltag library, skipping pose-apriltag example
-- Check for updates capability added to realsense-viewer
-- Check for updates capability added to realsense-depth-quality
-- Building with TM2
-- Fetching recommended firmwares:
-- D4XX_FW_VERSION: 5.13.0.50
-- SR3XX_FW_VERSION: 3.26.1.0
-- T26X_FW_VERSION: 0.2.0.951
-- L51X_FW_VERSION: 1.5.8.1
-- L53X_FW_VERSION: 3.5.5.1
-- https://librealsense.intel.com/Releases/RS4xx/FW/D4XX_FW_Image-5.13.0.50.bin
-- Download firmware 0;"returning early; file already exists with expected SHA1 hash" for D4XX_FW_Image-5.13.0.50.bin
-- https://librealsense.intel.com/Releases/SR300/FW/SR3XX_FW_Image-3.26.1.0.bin
-- Download firmware 0;"returning early; file already exists with expected SHA1 hash" for SR3XX_FW_Image-3.26.1.0.bin
-- https://librealsense.intel.com/Releases/TM2/FW/target/0.2.0.951/target-0.2.0.951.mvcmd
-- Download firmware 0;"returning early; file already exists with expected SHA1 hash" for target-0.2.0.951.mvcmd
-- https://librealsense.intel.com/Releases/L5xx/FW/L51X_FW_Image-1.5.8.1.bin
-- Download firmware 0;"returning early; file already exists with expected SHA1 hash" for L51X_FW_Image-1.5.8.1.bin
-- https://librealsense.intel.com/Releases/L5xx/FW/L53X_FW_Image-3.5.5.1.bin
-- Download firmware 0;"returning early; file already exists with expected SHA1 hash" for L53X_FW_Image-3.5.5.1.bin
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lukas/Development/Cpp/RS_Pipeline/cmake-build-release
[1/1] Linking CXX executable RS_Pipeline
FAILED: RS_Pipeline
: && /usr/bin/c++ -O3 -DNDEBUG -rdynamic CMakeFiles/RS_Pipeline.dir/main.cpp.o -o RS_Pipeline -Wl,-rpath,/home/lukas/Development/Cpp/RS_Pipeline/cmake-build-release/librealsense librealsense/librealsense2.so.2.50.0 -lglfw && :
/usr/bin/ld: CMakeFiles/RS_Pipeline.dir/main.cpp.o: in function `set_viewport(rect const&)':
main.cpp:(.text+0x23c): undefined reference to `glViewport'
/usr/bin/ld: main.cpp:(.text+0x241): undefined reference to `glLoadIdentity'
/usr/bin/ld: main.cpp:(.text+0x24b): undefined reference to `glMatrixMode'
/usr/bin/ld: CMakeFiles/RS_Pipeline.dir/main.cpp.o: in function `draw_pointcloud(float, float, glfw_state&, rs2::points&)':
main.cpp:(.text+0x2bb): undefined reference to `glLoadIdentity'
/usr/bin/ld: main.cpp:(.text+0x2c5): undefined reference to `glPushAttrib'
/usr/bin/ld: main.cpp:(.text+0x2e0): undefined reference to `glClearColor'
/usr/bin/ld: main.cpp:(.text+0x2ea): undefined reference to `glClear'
/usr/bin/ld: main.cpp:(.text+0x2f4): undefined reference to `glMatrixMode'
/usr/bin/ld: main.cpp:(.text+0x2f9): undefined reference to `glPushMatrix'
/usr/bin/ld: main.cpp:(.text+0x32a): undefined reference to `gluPerspective'
/usr/bin/ld: main.cpp:(.text+0x334): undefined reference to `glMatrixMode'
/usr/bin/ld: main.cpp:(.text+0x339): undefined reference to `glPushMatrix'
/usr/bin/ld: main.cpp:(.text+0x36c): undefined reference to `gluLookAt'
/usr/bin/ld: main.cpp:(.text+0x394): undefined reference to `glTranslatef'
/usr/bin/ld: main.cpp:(.text+0x3b2): undefined reference to `glRotated'
/usr/bin/ld: main.cpp:(.text+0x3cf): undefined reference to `glRotated'
/usr/bin/ld: main.cpp:(.text+0x3e3): undefined reference to `glTranslatef'
/usr/bin/ld: main.cpp:(.text+0x3f6): undefined reference to `glPointSize'
/usr/bin/ld: main.cpp:(.text+0x400): undefined reference to `glEnable'
/usr/bin/ld: main.cpp:(.text+0x40a): undefined reference to `glEnable'
/usr/bin/ld: main.cpp:(.text+0x417): undefined reference to `glBindTexture'
/usr/bin/ld: main.cpp:(.text+0x437): undefined reference to `glTexParameterfv'
/usr/bin/ld: main.cpp:(.text+0x44b): undefined reference to `glTexParameteri'
/usr/bin/ld: main.cpp:(.text+0x45f): undefined reference to `glTexParameteri'
/usr/bin/ld: main.cpp:(.text+0x466): undefined reference to `glBegin'
/usr/bin/ld: main.cpp:(.text+0x516): undefined reference to `glEnd'
/usr/bin/ld: main.cpp:(.text+0x51b): undefined reference to `glPopMatrix'
/usr/bin/ld: main.cpp:(.text+0x525): undefined reference to `glMatrixMode'
/usr/bin/ld: main.cpp:(.text+0x52a): undefined reference to `glPopMatrix'
/usr/bin/ld: main.cpp:(.text+0x52f): undefined reference to `glPopAttrib'
/usr/bin/ld: main.cpp:(.text+0x558): undefined reference to `glVertex3fv'
/usr/bin/ld: main.cpp:(.text+0x566): undefined reference to `glTexCoord2fv'
/usr/bin/ld: CMakeFiles/RS_Pipeline.dir/main.cpp.o: in function `draw_pointcloud_wrt_world(float, float, glfw_state&, rs2::points&, rs2_pose&, float*, std::vector >&)':
main.cpp:(.text+0x98b): undefined reference to `glLoadIdentity'
/usr/bin/ld: main.cpp:(.text+0x995): undefined reference to `glPushAttrib'
/usr/bin/ld: main.cpp:(.text+0x9b0): undefined reference to `glClearColor'
/usr/bin/ld: main.cpp:(.text+0x9ba): undefined reference to `glClear'
/usr/bin/ld: main.cpp:(.text+0x9c4): undefined reference to `glMatrixMode'
/usr/bin/ld: main.cpp:(.text+0x9c9): undefined reference to `glPushMatrix'
/usr/bin/ld: main.cpp:(.text+0x9fa): undefined reference to `gluPerspective'
/usr/bin/ld: main.cpp:(.text+0xa04): undefined reference to `glMatrixMode'
/usr/bin/ld: main.cpp:(.text+0xa09): undefined reference to `glPushMatrix'
/usr/bin/ld: main.cpp:(.text+0xa2f): undefined reference to `glTranslatef'
/usr/bin/ld: main.cpp:(.text+0xa4a): undefined reference to `glRotated'
/usr/bin/ld: main.cpp:(.text+0xa65): undefined reference to `glRotated'
/usr/bin/ld: main.cpp:(.text+0xa79): undefined reference to `glTranslatef'
/usr/bin/ld: main.cpp:(.text+0xa83): undefined reference to `glEnable'
/usr/bin/ld: main.cpp:(.text+0xa90): undefined reference to `glLineWidth'
/usr/bin/ld: main.cpp:(.text+0xa9a): undefined reference to `glBegin'
/usr/bin/ld: main.cpp:(.text+0xac4): undefined reference to `glColor3f'
/usr/bin/ld: main.cpp:(.text+0xad8): undefined reference to `glVertex3f'
/usr/bin/ld: main.cpp:(.text+0xae2): undefined reference to `glEnd'
/usr/bin/ld: main.cpp:(.text+0xaef): undefined reference to `glLineWidth'
/usr/bin/ld: main.cpp:(.text+0xb02): undefined reference to `glColor3f'
/usr/bin/ld: main.cpp:(.text+0xb2f): undefined reference to `glMultMatrixf'
/usr/bin/ld: main.cpp:(.text+0xb37): undefined reference to `glMultMatrixf'
/usr/bin/ld: main.cpp:(.text+0xb4a): undefined reference to `glPointSize'
/usr/bin/ld: main.cpp:(.text+0xb54): undefined reference to `glEnable'
/usr/bin/ld: main.cpp:(.text+0xb5e): undefined reference to `glEnable'
/usr/bin/ld: main.cpp:(.text+0xb71): undefined reference to `glBindTexture'
/usr/bin/ld: main.cpp:(.text+0xb91): undefined reference to `glTexParameterfv'
/usr/bin/ld: main.cpp:(.text+0xba5): undefined reference to `glTexParameteri'
/usr/bin/ld: main.cpp:(.text+0xbb9): undefined reference to `glTexParameteri'
/usr/bin/ld: main.cpp:(.text+0xbc0): undefined reference to `glBegin'
/usr/bin/ld: main.cpp:(.text+0xc76): undefined reference to `glEnd'
/usr/bin/ld: main.cpp:(.text+0xc7b): undefined reference to `glPopMatrix'
/usr/bin/ld: main.cpp:(.text+0xc85): undefined reference to `glMatrixMode'
/usr/bin/ld: main.cpp:(.text+0xc8a): undefined reference to `glPopMatrix'
/usr/bin/ld: main.cpp:(.text+0xc8f): undefined reference to `glPopAttrib'
/usr/bin/ld: main.cpp:(.text+0xcc0): undefined reference to `glVertex3fv'
/usr/bin/ld: main.cpp:(.text+0xcce): undefined reference to `glTexCoord2fv'
/usr/bin/ld: CMakeFiles/RS_Pipeline.dir/main.cpp.o: in function `set_viewport(rect const&)':
main.cpp:(.text+0x27b): undefined reference to `glOrtho'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
The examples all include this file, while you don't:
find_package(OpenGL REQUIRED)
set(DEPENDENCIES realsense2 glfw ${OPENGL_LIBRARIES})
which makes the realsense2 library depend on GLFW and your OpenGL stack.
Add the following to your CMakeLists.txt:
find_package(OpenGL REQUIRED)
target_link_libraries(${PROJECT_NAME} glfw OpenGL::GL )
#Botje Thanks a lot, that was fast! now it is working with the following CMakeLists:
cmake_minimum_required(VERSION 3.2)
project(RS_Pipeline LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 11)
set(OpenGL_GL_PREFERENCE LEGACY)
find_package(OpenGL REQUIRED)
add_executable(RS_Pipeline main.cpp librealsense/examples/example.hpp)
add_subdirectory(librealsense)
target_link_libraries(${PROJECT_NAME}
realsense2
glfw OpenGL::GL
glfw OpenGL::GLU
)
looks like this topic can be closed already.

Can't compile qt project with static lib curl

I am trying to compile a qt project with qtcurl using a statically built curl.
I am using the following to build a minimalist curl static library:
./configure --disable-shared --enable-static --prefix=/tmp/curl --disable-ldap --disable-sspi --without-librtmp --disable-ftp --disable-file --disable-dict --disable-telnet --disable-tftp --disable-rtsp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-smb --without-libidn --enable-ares
I am including
-L/tmp/curl/lib/libcurl.a
in the LIBS of the project, and
/tmp/curl/include
in the INCLUDEPATH
This is the output that I am getting:
QtCUrl.o: In function `QtCUrl::QtCUrl()':
QtCUrl.cpp:(.text+0x10d): undefined reference to `curl_easy_init'
QtCUrl.o: In function `QtCUrl::~QtCUrl()':
QtCUrl.cpp:(.text+0x32e): undefined reference to `curl_slist_free_all'
QtCUrl.cpp:(.text+0x355): undefined reference to `curl_easy_cleanup'
QtCUrl.o: In function `QtCUrl::setOptions(QHash<CURLoption, QVariant>&)':
QtCUrl.cpp:(.text+0xcee): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0xdac): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0xee9): undefined reference to `curl_slist_append'
QtCUrl.cpp:(.text+0xfe5): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0x1078): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0x109f): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0x1155): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0x1290): undefined reference to `curl_easy_setopt'
QtCUrl.o: In function `QtCUrl::exec(QHash<CURLoption, QVariant>&)':
QtCUrl.cpp:(.text+0x1f27): undefined reference to `curl_easy_perform'
QtCUrl.o: In function `curlGlobalInit()':
QtCUrl.cpp:(.text+0xa6): undefined reference to `curl_global_init'
collect2: error: ld returned 1 exit status
What am I missing here?

Travis-ci - undefined references c++

My Travis-ci build keeps failing with undefined reference, Heres is the build log
build
Cmake file
Travis file
How would I go about solving this 'undefined reference' from ncurses?
I have built ncurses from source as well as have the 'CMAKE_CXX_FLAGS' set to "-lncurses", but it doesn't seem to execute the 'CMAKE_CXX_FLAGS', I think.
for non links
cmake -
cmake_minimum_required(VERSION 3.9)
project(hoshiMenu)
include(FindPkgConfig)
pkg_check_modules(CURLPP REQUIRED curlpp)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS "-lncurses")
add_executable(hoshiMenu main.cpp)
target_link_libraries(hoshiMenu ${CURLPP_LDFLAGS})
travis build error part -
$ make
Scanning dependencies of target hoshiMenu
[ 50%] Building CXX object CMakeFiles/hoshiMenu.dir/main.cpp.o
[100%] Linking CXX executable hoshiMenu
CMakeFiles/hoshiMenu.dir/main.cpp.o: In function `main':
main.cpp:(.text+0x2d): undefined reference to `initscr'
main.cpp:(.text+0x32): undefined reference to `cbreak'
main.cpp:(.text+0x4d): undefined reference to `stdscr'
main.cpp:(.text+0x59): undefined reference to `stdscr'
main.cpp:(.text+0x75): undefined reference to `stdscr'
main.cpp:(.text+0x81): undefined reference to `stdscr'
main.cpp:(.text+0xb9): undefined reference to `newwin'
main.cpp:(.text+0xd9): undefined reference to `box'
main.cpp:(.text+0xf2): undefined reference to `newwin'
main.cpp:(.text+0x112): undefined reference to `box'
main.cpp:(.text+0x12b): undefined reference to `newwin'
main.cpp:(.text+0x14b): undefined reference to `box'
main.cpp:(.text+0x150): undefined reference to `refresh'
main.cpp:(.text+0x15f): undefined reference to `wrefresh'
main.cpp:(.text+0x16e): undefined reference to `wrefresh'
main.cpp:(.text+0x17d): undefined reference to `wrefresh'
main.cpp:(.text+0x191): undefined reference to `keypad'
main.cpp:(.text+0x2ca): undefined reference to `wattr_on'
main.cpp:(.text+0x311): undefined reference to `mvwprintw'
main.cpp:(.text+0x32a): undefined reference to `wattr_off'
main.cpp:(.text+0x34d): undefined reference to `wgetch'
main.cpp:(.text+0x3af): undefined reference to `refresh'
main.cpp:(.text+0x3bb): undefined reference to `refresh'
main.cpp:(.text+0x3cf): undefined reference to `keypad'
main.cpp:(.text+0x62c): undefined reference to `wattr_on'
main.cpp:(.text+0x673): undefined reference to `mvwprintw'
main.cpp:(.text+0x68c): undefined reference to `wattr_off'
main.cpp:(.text+0x6af): undefined reference to `wgetch'
main.cpp:(.text+0x752): undefined reference to `wattr_on'
main.cpp:(.text+0x799): undefined reference to `mvwprintw'
main.cpp:(.text+0x7b2): undefined reference to `wattr_off'
main.cpp:(.text+0x7d5): undefined reference to `wgetch'
main.cpp:(.text+0x891): undefined reference to `refresh'
main.cpp:(.text+0x898): undefined reference to `stdscr'
main.cpp:(.text+0x8a4): undefined reference to `stdscr'
main.cpp:(.text+0x8c0): undefined reference to `stdscr'
main.cpp:(.text+0x8cc): undefined reference to `stdscr'
main.cpp:(.text+0x8f0): undefined reference to `wrefresh'
main.cpp:(.text+0x91a): undefined reference to `mvwprintw'
main.cpp:(.text+0x929): undefined reference to `wrefresh'
main.cpp:(.text+0x93f): undefined reference to `stdscr'
main.cpp:(.text+0x947): undefined reference to `wgetch'
main.cpp:(.text+0x94c): undefined reference to `endwin'
collect2: error: ld returned 1 exit status
make[2]: *** [hoshiMenu] Error 1
make[1]: *** [CMakeFiles/hoshiMenu.dir/all] Error 2
make: *** [all] Error 2
The command "make" exited with 2.
Done. Your build exited with 1.
Travis yaml -
language: cpp
sudo: required
dist: trusty
os: linux
compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++', 'gcc', 'cmake', 'make']
env:
- CXX_COMPILER=g++
- C_COMPILER=gcc
before_install:
- pushd ~
- wget -O curlpp-0.8.1.tar.gz https://github.com/jpbarrette/curlpp/archive/v0.8.1.tar.gz
- tar -xf curlpp-0.8.1.tar.gz
- cd curlpp-0.8.1
- mkdir cmake_build
- cd cmake_build
- cmake -D CMAKE_CXX_COMPILER=`which ${CXX_COMPILER}` -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" -DCMAKE_EXE_LINKER_FLAGS="$CMAKE_EXE_LINKER_FLAGS" ..
- sudo make install
- wget -O ncurses-6.1.tar.gz https://invisible-mirror.net/archives/ncurses/ncurses-6.1.tar.gz
- tar -xf ncurses-6.1.tar.gz
- cd ncurses-6.1
- ./configure
- make
- sudo make install
- popd
script:
- mkdir build
- cd build
- cmake ..
- make
Thank you for your help <3

CMake linker not working correctly

I am trying to build my project using CMake but I am having error linking required libraries. I have this CMakeLists.txt in the root folder of my project:
cmake_minimum_required(VERSION 2.6)
project(test)
add_subdirectory(src)
And in my src folder, alongside my source files I have this CMakeLists.txt:
set (CMAKE_CXX_FLAGS "Wall -std=c++11" )
set (CMAKE_EXE_LINKER_FLAGS "-lSDL2 -lGL" )
file (GLOB SRCS *.cpp *.h )
add_executable(engine ${SRCS} )
I then go into the build folder and do cmake .. and it runs without any errors. When I do make, the compilation runs without any errors as well, but when it gets to the linking part, I get these errors:
CMakeFiles/test.dir/Application.cpp.o: In function `Application::onExecute()':
Application.cpp:(.text+0x41): undefined reference to `SDL_GetTicks'
Application.cpp:(.text+0x4e): undefined reference to `SDL_GetTicks'
Application.cpp:(.text+0xd7): undefined reference to `SDL_PollEvent'
CMakeFiles/test.dir/Application.cpp.o: In function `Application::render()':
Application.cpp:(.text+0x17b): undefined reference to `glClearColor'
Application.cpp:(.text+0x185): undefined reference to `glClear'
Application.cpp:(.text+0x194): undefined reference to `SDL_GL_SwapWindow'
CMakeFiles/test.dir/Application.cpp.o: In function `Application::cleanUp()':
Application.cpp:(.text+0x1b2): undefined reference to `SDL_GL_DeleteContext'
Application.cpp:(.text+0x1c1): undefined reference to `SDL_DestroyWindow'
Application.cpp:(.text+0x1c6): undefined reference to `SDL_Quit'
CMakeFiles/test.dir/Application.cpp.o: In function `Application::initialize()':
Application.cpp:(.text+0x1de): undefined reference to `SDL_Init'
Application.cpp:(.text+0x1ea): undefined reference to `SDL_GetError'
Application.cpp:(.text+0x22b): undefined reference to `SDL_CreateWindow'
Application.cpp:(.text+0x243): undefined reference to `SDL_GetError'
Application.cpp:(.text+0x25a): undefined reference to `SDL_Quit'
Application.cpp:(.text+0x270): undefined reference to `SDL_GL_SetAttribute'
Application.cpp:(.text+0x27f): undefined reference to `SDL_GL_SetAttribute'
Application.cpp:(.text+0x28e): undefined reference to `SDL_GL_SetAttribute'
Application.cpp:(.text+0x29d): undefined reference to `SDL_GL_CreateContext'
Application.cpp:(.text+0x2af): undefined reference to `glGetString'
collect2: error: ld returned 1 exit status
make[2]: *** [src/test] Error 1
make[1]: *** [src/CMakeFiles/test.dir/all] Error 2
make: *** [all] Error 2
I have the correct includes in my header files and I was able to compile and run using only make so I think the linker flags I tell CMake aren't being passed to the compiler. How can I fix this?
You have to use the cmake command target_link_libraries to reference SDL libs.

OpenGL/glut/stdc++ build errors

I'm using Ubuntu and tried using synaptic to install everything that had the word "GLUT" in it and also SDL and opengl . But still a simple program fails to compile . It shows this :
opengl1.cpp:(.text+0xe): undefined reference to `glClear'
opengl1.cpp:(.text+0x1a): undefined reference to `glBegin'
opengl1.cpp:(.text+0x2e): undefined reference to `glVertex2i'
opengl1.cpp:(.text+0x33): undefined reference to `glEnd'
opengl1.cpp:(.text+0x38): undefined reference to `glFlush'
/tmp/ccnwQeLu.o: In function `MyInit()':
opengl1.cpp:(.text+0x4c): undefined reference to `glGetString'
opengl1.cpp:(.text+0x57): undefined reference to `std::cout'
opengl1.cpp:(.text+0x5c): undefined reference to `std::basic_ostream >& std::operator >(std::basic_ostream >&, unsigned char const*)'
opengl1.cpp:(.text+0x6c): undefined reference to `std::basic_ostream >& std::operator >(std::basic_ostream >&, char const*)'
opengl1.cpp:(.text+0x78): undefined reference to `glGetString'
opengl1.cpp:(.text+0x83): undefined reference to `std::cout'
opengl1.cpp:(.text+0x88): undefined reference to `std::basic_ostream >& std::operator >(std::basic_ostream >&, unsigned char const*)'
opengl1.cpp:(.text+0x98): undefined reference to `std::basic_ostream >& std::operator >(std::basic_ostream >&, char const*)'
opengl1.cpp:(.text+0xc0): undefined reference to `glClearColor'
opengl1.cpp:(.text+0xdf): undefined reference to `glColor3f'
opengl1.cpp:(.text+0xec): undefined reference to `glPointSize'
opengl1.cpp:(.text+0xf8): undefined reference to `glMatrixMode'
opengl1.cpp:(.text+0xfd): undefined reference to `glLoadIdentity'
opengl1.cpp:(.text+0x12d): undefined reference to `gluOrtho2D'
/tmp/ccnwQeLu.o: In function `main':
opengl1.cpp:(.text+0x14a): undefined reference to `glutInit'
opengl1.cpp:(.text+0x156): undefined reference to `glutInitDisplayMode'
opengl1.cpp:(.text+0x16d): undefined reference to `glutInitWindowSize'
opengl1.cpp:(.text+0x181): undefined reference to `glutInitWindowPosition'
opengl1.cpp:(.text+0x18d): undefined reference to `glutCreateWindow'
opengl1.cpp:(.text+0x19e): undefined reference to `glutDisplayFunc'
opengl1.cpp:(.text+0x1a3): undefined reference to `glutMainLoop'
/tmp/ccnwQeLu.o: In function `__static_initialization_and_destruction_0(int, int)':
opengl1.cpp:(.text+0x1cb): undefined reference to `std::ios_base::Init::Init()'
opengl1.cpp:(.text+0x1d0): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccnwQeLu.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
If I use g++ instead of gcc I get this:
vim opebgl1.cpp
g++ opengl1.cpp -o opengl1 -lGL -lstdc++ -lc -lm
and then get this :
/tmp/ccCJBuIl.o: In function `MyInit()':
opengl1.cpp:(.text+0x12d): undefined reference to `gluOrtho2D'
/tmp/ccCJBuIl.o: In function `main':
opengl1.cpp:(.text+0x14a): undefined reference to `glutInit'
opengl1.cpp:(.text+0x156): undefined reference to `glutInitDisplayMode'
opengl1.cpp:(.text+0x16d): undefined reference to `glutInitWindowSize'
opengl1.cpp:(.text+0x181): undefined reference to `glutInitWindowPosition'
opengl1.cpp:(.text+0x18d): undefined reference to `glutCreateWindow'
opengl1.cpp:(.text+0x19e): undefined reference to `glutDisplayFunc'
opengl1.cpp:(.text+0x1a3): undefined reference to `glutMainLoop'
collect2: ld returned 1 exit status
So what do I really need to start working with opengl in Ubuntu?
Add "-lstdc++ -lGL" to your linker flags.
Or try to compile it like this:
g++ opengl1.cpp -o opengl1 -lGL -lGLU -lc -lm
(edit: added -lGLU, removed -lstdc++)
You should link it with glut and GLU as well:
g++ opengl1.cpp -o opengl1 -lGL -lstdc++ -lc -lm -lglut -lGLU
Files ended with .cpp must be compiled with g++. The rest of the errors are related to the linking process, and they should not happen if you build your application with the command I suggested above. If they do, make sure you have installed libglut and libglu.
Make sure you are using g++ to build your C++ files to avoid the linker errors pertaining to the C++ standard library.
To resolve the GLUT symbols you probably just need to add -lglut to your final build command.
While compiling the code you must mention some parameters according to your includes.
You already used -lGL, -lm etc.
To use gluOrtho2D the parameter to be used is -lGLU
and for other functions that begin with glut use -lglut