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:
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?
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
I am trying to link glew and glfw on clion with cmake. I did it with visual studio easilly, but I am having problems with clion. This is how I have included my dependencies like glew (.dll shouldnt be there I guess):
And this is my cmake file.
cmake_minimum_required(VERSION 3.6)
project(Course)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
find_package(OpenGL REQUIRED)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLFW/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLFW/libs)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLEW/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLEW/libs)
set(SOURCE_FILES main.cpp Window.cpp Window.h)
add_executable(Course ${SOURCE_FILES})
target_link_libraries(Course ${OPENGL_LIBRARY} libglew32.a libglfw3.a )
Error:
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x42c): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x448): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x464): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x478): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x48c): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x4a0): more undefined references to `wglGetProcAddress#4' follow
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1de1f): undefined reference to `wglGetCurrentDC#0'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1de8f): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1dea3): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1debe): undefined reference to `wglGetCurrentDC#0'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1df3a): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1e0c0): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1e0dc): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1e0fa): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1e4dc): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1e4f8): more undefined references to `wglGetProcAddress#4' follow
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x20352): undefined reference to `glGetString#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x204d4): undefined reference to `glGetIntegerv#8'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x204e3): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x2055e): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x2057a): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x20596): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x205ac): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x20665): more undefined references to `wglGetProcAddress#4' follow
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26e21): undefined reference to `glGetString#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26f31): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26f47): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26f60): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26f7b): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26f8f): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26fa3): more undefined references to `wglGetProcAddress#4' follow
Seems like cmake can't find glew (but I told it where glew is?):
Edit:
Adding ${OPENGL_LIBRARIES} at the end of target_link_libraries worked
cmake_minimum_required(VERSION 3.6)
project(Course)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
find_package(OpenGL REQUIRED)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLFW/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLFW/libs)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLEW/include/GL)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLEW/libs)
set(SOURCE_FILES main.cpp Window.cpp Window.h)
add_executable(Course ${SOURCE_FILES})
target_link_libraries(Course glfw3.a libglew32.a ${OPENGL_LIBRARIES})
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.