When I am linking to an external library, I get a lot of "undefined reference", despite those functions are in the external library.
$ g++.exe -std=c++11 -g2 -O0 -Wall -Wextra -pedantic -g -Wl,--whole-archive E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a -Wl,--no-whole-archive -o buergerkarte.exe -Wl,--major-image-version,0,--minor-image-version,0 E:/msys64/mingw64/lib/libQt5Widgetsd.dll.a E:/msys64/usr/src/OpenSC-GUI/lib/opensc/lib/windows/libopensc.a -lz -lssl -lcrypto -llzma -Wl,-subsystem,windows E:/msys64/mingw64/lib/libQt5Guid.dll.a E:/msys64/mingw64/lib/libQt5Cored.dll.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(mainwidget.cpp.obj): In function `MainWidget::pksc15PinChangeDone(Error)':
E:/msys64/usr/src/OpenSC-GUI/src/mainwidget.cpp:392: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(mainwidget.cpp.obj): In function `MainWidget::pksc15PinUnblockDone(Error)':
E:/msys64/usr/src/OpenSC-GUI/src/mainwidget.cpp:410: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::cancel()':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:30: undefined reference to `sc_cancel'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::initScContext()':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:73: undefined reference to `sc_context_create'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:75: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::connectCard(bool)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:92: undefined reference to `sc_detect_card_presence'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:96: undefined reference to `sc_wait_for_event'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:98: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:106: undefined reference to `sc_connect_card'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:109: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:114: undefined reference to `sc_lock'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:116: undefined reference to `sc_disconnect_card'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:118: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::connectReader(bool)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:131: undefined reference to `sc_ctx_get_reader_count'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:138: undefined reference to `sc_wait_for_event'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:140: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:143: undefined reference to `sc_ctx_detect_readers'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:145: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:150: undefined reference to `sc_ctx_get_reader_count'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:151: undefined reference to `sc_ctx_get_reader'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:152: undefined reference to `sc_detect_card_presence'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:162: undefined reference to `sc_ctx_get_reader'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:167: undefined reference to `sc_ctx_get_reader_count'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::verifyCurrentSmartCard()':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:184: undefined reference to `sc_detect_card_presence'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:195: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::verifyCurrentCardReader()':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:207: undefined reference to `sc_ctx_detect_readers'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:207: undefined reference to `sc_ctx_get_reader_count'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:207: undefined reference to `sc_ctx_get_reader_by_name'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::cleanupScContext()':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:224: undefined reference to `sc_release_context'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::cleanupSmartCard()':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:233: undefined reference to `sc_unlock'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:234: undefined reference to `sc_disconnect_card'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::gatherPkcs15PinInfo()':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:246: undefined reference to `sc_pkcs15_bind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:248: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:257: undefined reference to `sc_pkcs15_get_objects'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:259: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:260: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:262: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:275: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:280: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::changePinPkcs15(unsigned char const*, unsigned char const*)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:290: undefined reference to `sc_pkcs15_bind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:292: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:297: undefined reference to `sc_pkcs15_get_objects'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:299: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:301: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:308: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:315: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:325: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:329: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj):E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:335: more undefined references to `sc_pkcs15_unbind' follow
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::changePinPkcs15(unsigned char const*, unsigned char const*)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:344: undefined reference to `sc_pkcs15_change_pin'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:348: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:353: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::unblockPinPkcs15(unsigned char const*, unsigned char const*)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:363: undefined reference to `sc_pkcs15_bind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:365: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:370: undefined reference to `sc_pkcs15_get_objects'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:372: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:374: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:381: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:387: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:391: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:397: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj):E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:401: more undefined references to `sc_pkcs15_unbind' follow
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::unblockPinPkcs15(unsigned char const*, unsigned char const*)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:406: undefined reference to `sc_pkcs15_unblock_pin'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:410: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:415: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::getPersonalDatafromCard(sc_pkcs15_card*)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:428: undefined reference to `sc_pkcs15_get_objects'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:430: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:438: undefined reference to `sc_format_oid'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:439: undefined reference to `sc_compare_oid'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:454: undefined reference to `sc_pkcs15_read_data_object'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:456: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:471: undefined reference to `sc_pkcs15_free_data_object'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:487: undefined reference to `sc_pkcs15_free_data_object'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:493: undefined reference to `sc_pkcs15_free_data_object'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:500: undefined reference to `sc_pkcs15_free_data_object'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:511: undefined reference to `sc_pkcs15_free_data_object'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::getSerialDatafromCard(sc_pkcs15_card*)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:530: undefined reference to `sc_format_path'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::getX509CertificateDatafromCard(sc_pkcs15_card*)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:562: undefined reference to `sc_format_path'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:566: undefined reference to `sc_select_file'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:568: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:576: undefined reference to `sc_pkcs15_read_certificate'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:578: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:582: undefined reference to `sc_pkcs15_free_certificate'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::readDataFromFile(sc_pkcs15_card const*, sc_path const*, unsigned char*, unsigned long long)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:592: undefined reference to `sc_select_file'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:596: undefined reference to `sc_read_binary'
collect2.exe: error: ld returned 1 exit status
Here is my CMakeLists.txt, which generates the command above:
# Bring header files into scope
set( LIB_DIR ${PROJECT_SOURCE_DIR}/lib )
include_directories(${LIB_DIR}/opensc/include)
include_directories (${LIB_DIR}/opensc/include/common)
include_directories(${LIB_DIR}/opensc/include/libopensc)
include_directories(${LIB_DIR}/opensc/include/scconf)
find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
SET(QT_USE_QTSVG TRUE)
find_package( ZLIB REQUIRED )
include_directories( ${ZLIB_INCLUDE_DIRS} )
find_package(OpenSSL REQUIRED)
include_directories( ${OPENSSL_INCLUDE_DIRS} )
#Adding forms
set( FORMS forms/mainwidget.ui forms/pukdialog.ui forms/aboutdialog.ui)
#Adding source files
set(SRCS main.cpp)
set(SRCS ${SRCS} mainwidget.cpp cardcontrolhandler.cpp error.cpp logger.cpp statusbar.cpp pukdialog.cpp aboutdialog.cpp x509certificatehandler.cpp )
#Adding headers
set(HEADERS mainwidget.h cardcontrolhandler.h statusbar.h logger.h pukdialog.h aboutdialog.h )
#Adding Resources
set(RESOURCES ../buergerkarte.qrc)
#Generation of Qt Stuff (moc files, ui headers and resource files)
QT5_WRAP_CPP( HEADERS_MOC ${HEADERS})
QT5_WRAP_UI( FORMS_HEADERS ${FORMS})
QT5_ADD_RESOURCES( RESOURCES_RCC ${RESOURCES})
#We have to include the binary directory because the qt stuff like ui headers will be generated there
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
#Creates executable from sources, moc headers (Qt), forms headers (Qt) and resources (Qt)
add_executable (${PROJECT_NAME} ${SRCS} ${HEADERS_MOC} ${FORMS_HEADERS} ${RESOURCES_RCC} ../buergerkarte.rc )
#Linking with special arguments for windows or linux platform
if( WIN32 )
set(LIBOPENSC ${LIB_DIR}/opensc/lib/windows/libopensc.a)
# target_link_libraries(${PROJECT_NAME} ${QT_QTMAIN_LIBRARY} ${QT_LIBRARIES} ${LIBOPENSC} ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS} -llcms -llzma -Wl,-subsystem,windows )
target_link_libraries(${PROJECT_NAME} ${QT_QTMAIN_LIBRARY} Qt5::Widgets ${LIBOPENSC} ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS} -llzma -Wl,-subsystem,windows )
elseif( APPLE )
set(LIBOPENSC ${LIB_DIR}/opensc/lib/mac_osx/libopensc.3.dylib)
#set(LIBOPENSC ./libopensc.3.dylib)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets ${LIBOPENSC} ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS} )
else()
set(LIBOPENSC ${LIB_DIR}/opensc/lib/linux/libopensc.a)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets ${LIBOPENSC} ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS} )
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
ADD_CUSTOM_COMMAND (
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND lupdate -silent -I ../src ../src -ts ../translations/${PROJECT_NAME}_de.ts ../translations/${PROJECT_NAME}_it.ts
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()
All the undefined references are contained inside the ${LIB_DIR}/opensc/lib/windows/libopensc.a file. The main program adds the header files from opensc. Why does the linker not see the functions inside the external library, despite it is added to the command?
g++.exe -std=c++11 -g2 -O0 -Wall -Wextra -pedantic -g -Wl,--whole-archive E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a -Wl,--no-whole-archive -o buergerkarte.exe -Wl,--major-image-version,0,--minor-image-version,0 E:/msys64/mingw64/lib/libQt5Widgetsd.dll.a E:/msys64/usr/src/OpenSC-GUI/lib/opensc/lib/windows/libopensc.a -lz -lssl -lcrypto -llzma -Wl,-subsystem,windows E:/msys64/mingw64/lib/libQt5Guid.dll.a E:/msys64/mingw64/lib/libQt5Cored.dll.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
I am using mingw-w64. Thanks!
Related
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 have a library called liborwell.a compiled with cmake that is linked into my little project with a makefile.
Here's how I'm linking the liborwell.a:
target_link_libraries(orwell PRIVATE
${ZLIB_LIBRARY} ${X11_LIBRARY} ${LIB_VDPAU} ${LIB_VA} ${LIB_VA_DRM} ${LIB_VA_X11}
myRtspClient-static ${GTKMM_LIBRARIES} ${GLEW_LIBRARY} ${GLU_LIBRARY} ${GL_LIBRARY} epoxy
PUBLIC pthread -lstdc++fs AVCODEC_LIB AVUTIL_LIB SWS_SCALE_LIB SWRESAMPLE_LIB ${LIBDL_LIBRARY} zlmediakit zltoolkit )
and here's how I'm linking in the makefile:
EXTRA_LDFLAGS=-L ../../gtk/build/desktoplinux -L ../../deps/ffmpeg/build/desktop/x86_64/lib -L ../../ -lGL -lorwell
The cmake library gets compiled successfully,but in the project that uses this library, the linker complains that ffmpeg functions (av_codec_open2 for example) are missing:
FfmpegHardwareDecoder.cpp:(.text+0x5bb): undefined reference to `av_hwdevice_iterate_types'
FfmpegHardwareDecoder.cpp:(.text+0x5e3): undefined reference to `av_hwdevice_get_type_name'
../../gtk/build/desktoplinux/liborwell.a(FfmpegHardwareDecoder.cpp.o): In function `FfmpegHardwareDecoder::FfmpegHardwareDecoder(Decoder::Codec, FfmpegHardwareDecoder::Device, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
FfmpegHardwareDecoder.cpp:(.text+0x7b9): undefined reference to `av_hwdevice_find_type_by_name'
FfmpegHardwareDecoder.cpp:(.text+0x94a): undefined reference to `avcodec_find_decoder'
FfmpegHardwareDecoder.cpp:(.text+0x98d): undefined reference to `avcodec_find_decoder'
FfmpegHardwareDecoder.cpp:(.text+0x9b9): undefined reference to `avcodec_alloc_context3'
FfmpegHardwareDecoder.cpp:(.text+0xa3b): undefined reference to `avcodec_get_hw_config'
FfmpegHardwareDecoder.cpp:(.text+0xa53): undefined reference to `av_hwdevice_get_type_name'
FfmpegHardwareDecoder.cpp:(.text+0xb4f): undefined reference to `av_hwdevice_ctx_create'
FfmpegHardwareDecoder.cpp:(.text+0xbd4): undefined reference to `av_buffer_ref'
FfmpegHardwareDecoder.cpp:(.text+0xc13): undefined reference to `avcodec_open2'
../../gtk/build/desktoplinux/liborwell.a(FfmpegHardwareDecoder.cpp.o): In function `FfmpegHardwareDecoder::hardwareDecode(std::shared_ptr<EncodedPacket>)':
FfmpegHardwareDecoder.cpp:(.text+0xdd4): undefined reference to `avcodec_send_packet'
FfmpegHardwareDecoder.cpp:(.text+0xe2f): undefined reference to `av_frame_alloc'
FfmpegHardwareDecoder.cpp:(.text+0xe4a): undefined reference to `av_frame_alloc'
FfmpegHardwareDecoder.cpp:(.text+0xef7): undefined reference to `avcodec_receive_frame'
../../gtk/build/desktoplinux/liborwell.a(FfmpegHardwareDecoder.cpp.o): In function `FfmpegHardwareDecoder::sendPacket(std::shared_ptr<EncodedPacket>, std::shared_ptr<DecodedFrame>)':
FfmpegHardwareDecoder.cpp:(.text+0x1134): undefined reference to `av_frame_alloc'
FfmpegHardwareDecoder.cpp:(.text+0x11a6): undefined reference to `av_hwframe_transfer_data'
../../gtk/build/desktoplinux/liborwell.a(FfmpegHardwareDecoder.cpp.o): In function `AVPacketDeleter::operator()(AVPacket*)':
FfmpegHardwareDecoder.cpp:(.text._ZN15AVPacketDeleterclEP8AVPacket[_ZN15AVPacketDeleterclEP8AVPacket]+0x18): undefined reference to `av_packet_unref'
../../gtk/build/desktoplinux/liborwell.a(FfmpegHardwareDecoder.cpp.o): In function `AVFrameDeleter::operator()(AVFrame*)':
FfmpegHardwareDecoder.cpp:(.text._ZN14AVFrameDeleterclEP7AVFrame[_ZN14AVFrameDeleterclEP7AVFrame]+0x18): undefined reference to `av_frame_unref'
../../gtk/build/desktoplinux/liborwell.a(FfmpegHardwareDecoder.cpp.o): In function `AVBufferRefDeleter::operator()(AVBufferRef*)':
FfmpegHardwareDecoder.cpp:(.text._ZN18AVBufferRefDeleterclEP11AVBufferRef[_ZN18AVBufferRefDeleterclEP11AVBufferRef]+0x18): undefined reference to `av_buffer_unref'
../../gtk/build/desktoplinux/liborwell.a(FfmpegHardwareDecoder.cpp.o): In function `AVCodecContextDeleter::operator()(AVCodecContext*)':
FfmpegHardwareDecoder.cpp:(.text._ZN21AVCodecContextDeleterclEP14AVCodecContext[_ZN21AVCodecContextDeleterclEP14AVCodecContext]+0x18): undefined reference to `avcodec_free_context'
../../gtk/build/desktoplinux/liborwell.a(FfmpegSoftwareDecoder.cpp.o): In function `FfmpegSoftwareDecoder::FfmpegSoftwareDecoder(Decoder::Codec)':
FfmpegSoftwareDecoder.cpp:(.text+0x5db): undefined reference to `avcodec_find_decoder'
FfmpegSoftwareDecoder.cpp:(.text+0x67a): undefined reference to `avcodec_alloc_context3'
FfmpegSoftwareDecoder.cpp:(.text+0x6b3): undefined reference to `avcodec_open2'
../../gtk/build/desktoplinux/liborwell.a(FfmpegSoftwareDecoder.cpp.o): In function `FfmpegSoftwareDecoder::sendPacket(std::shared_ptr<EncodedPacket>, std::shared_ptr<DecodedFrame>)':
FfmpegSoftwareDecoder.cpp:(.text+0x903): undefined reference to `av_log_set_level'
FfmpegSoftwareDecoder.cpp:(.text+0x94a): undefined reference to `av_packet_alloc'
FfmpegSoftwareDecoder.cpp:(.text+0xa3f): undefined reference to `avcodec_send_packet'
FfmpegSoftwareDecoder.cpp:(.text+0xa4a): undefined reference to `av_frame_alloc'
FfmpegSoftwareDecoder.cpp:(.text+0xa9c): undefined reference to `avcodec_receive_frame'
../../gtk/build/desktoplinux/liborwell.a(FileWriter.cpp.o): In function `FileWriter::setPath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
FileWriter.cpp:(.text+0xc25): undefined reference to `std::experimental::filesystem::v1::create_directories(std::experimental::filesystem::v1::__cxx11::path const&)'
../../gtk/build/desktoplinux/liborwell.a(FileWriter.cpp.o): In function `std::experimental::filesystem::v1::__cxx11::path::path(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&)':
FileWriter.cpp:(.text._ZNSt12experimental10filesystem2v17__cxx114pathC2EONSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZNSt12experimental10filesystem2v17__cxx114pathC5EONSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x4c): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
../../gtk/build/desktoplinux/liborwell.a(ZLRTSPClient.cpp.o): In function `ZLRTSPClient::startThreadMode()':
ZLRTSPClient.cpp:(.text._ZN12ZLRTSPClient15startThreadModeEv[_ZN12ZLRTSPClient15startThreadModeEv]+0x76): undefined reference to `mediakit::Client::kRtpType[abi:cxx11]'
I inspected liborwell.a:
nm liborwell.a | grep avcodec_open
U avcodec_open2
U avcodec_open2
nm liborwell.a | grep av_frame_alloc
U av_frame_alloc
U av_frame_alloc
as you can see, the symbols are there.
What am I doing wrong?
Here's the full linking command if anyone is intersted:
"/usr/bin/ld" -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o /home/dev/orwell/orwell_flutter/linux/../build/linux/debug/flutter_desktop_example /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu/crt1.o /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu/crti.o /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/crtbegin.o -L/home/dev/orwell/orwell_flutter/linux/../build/linux/debug/lib -L../../gtk/build/desktoplinux -L../../deps/ffmpeg/build/desktop/x86_64/lib -L../../ -L/usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../.. -L/usr/lib/llvm-6.0/bin/../lib -L/lib -L/usr/lib /home/dev/orwell/orwell_flutter/linux/../build/linux/obj/main.o /home/dev/orwell/orwell_flutter/linux/../build/linux/obj/flutter/generated_plugin_registrant.o /home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/linux/flutter/ephemeral/cpp_client_wrapper_glfw/flutter_window_controller.o /home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/linux/flutter/ephemeral/cpp_client_wrapper_glfw/plugin_registrar.o /home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/linux/flutter/ephemeral/cpp_client_wrapper_glfw/engine_method_result.o /home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/linux/flutter/ephemeral/cpp_client_wrapper_glfw/standard_codec.o /home/dev/orwell/orwell_flutter/linux/../build/linux/obj/../common/src/flutter_video_renderer.o /home/dev/orwell/orwell_flutter/linux/../build/linux/obj/../common/src/flutter_texture_video_renderer.o /home/dev/orwell/orwell_flutter/linux/../build/linux/obj/../common/src/flutter_orwell_plugin.o /home/dev/orwell/orwell_flutter/linux/../build/linux/obj/../../engine/src/flutter/third_party/glad/src/gl.o -lflutter_linux_glfw -lGL -lpthread -lorwell "-rpath=\$ORIGIN/lib" -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/crtend.o /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu/crtn.o
UPDATE:
I just found that U in nm means undefined, but I compiled an executable just to test and it didn't complain about the lib being undefined, why the library can't find the symbols?
I wrote simple apps with Openssl in C and C++. I compile them like this:
gcc openssltest.c -o openssltest -lcrypto
g++ openssltest.cpp -o openssltest -lcrypto
And its all ok but only, when you have Openssl installed.
I would like to compile it that I can run them on OS where theres no Openssl installend (linux-like OS). I tried this:
gcc -c openssltest.c -lcrypto -static
gcc openssltest.o -o openssltest -lcrypto -static
and same for C++:
g++ -c openssltest.cpp -lcrypto -static
g++ openssltest.o -o openssltest -lcrypto -static
But have those errors:
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x19): undefined reference to `dlopen'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x2c): undefined reference to `dlsym'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x37): undefined reference to `dlclose'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
(.text+0x354): undefined reference to `dlsym'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
(.text+0x3fb): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
(.text+0x474): undefined reference to `dlsym'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
(.text+0x52e): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
(.text+0x5a2): undefined reference to `dlopen'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
(.text+0x60b): undefined reference to `dlclose'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
(.text+0x638): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
(.text+0x6cd): undefined reference to `dladdr'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
(.text+0x731): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
(.text+0x78a): undefined reference to `dlclose'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_free':
(.text+0x4d): undefined reference to `inflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_free':
(.text+0x6b): undefined reference to `deflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_ctrl':
(.text+0x284): undefined reference to `deflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_ctrl':
(.text+0x342): undefined reference to `zError'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_expand_block':
(.text+0x411): undefined reference to `inflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_compress_block':
(.text+0x4ca): undefined reference to `deflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_finish':
(.text+0x51f): undefined reference to `inflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_finish':
(.text+0x528): undefined reference to `deflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_init':
(.text+0x5d7): undefined reference to `inflateInit_'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_init':
(.text+0x659): undefined reference to `deflateInit_'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
(.text+0x893): undefined reference to `inflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
(.text+0x90d): undefined reference to `zError'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
(.text+0x97c): undefined reference to `inflateInit_'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
(.text+0xa6f): undefined reference to `deflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
(.text+0xaec): undefined reference to `zError'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
(.text+0xb7e): undefined reference to `deflateInit_'
collect2: error: ld returned 1 exit status
How can I make this? I remember that a while ago I did this but now, erm, forgot how to do it. Im on Ubuntu 13.04 x64 - can it be an issue?
I had a similar issue trying to statically compile a simple DES program using the openssl lib. I used -lcrypto -lz -ldl -static-libgcc and it worked for me. No warnings or errors.
You need to be aware that libraries need to availiable as statically linked *.a files. If they are not, then compilation will either fail or you end up with a dynamically linked executable.
If this gets too much PITA (all the libraries dependencies need to be statically compiled to, and their deps too and so on) use something like buildroot
A hotfix: try to link in libdl statically, too.
If this not works, IMHO your libcrypto.a is bad compiled.
I had the same problem as you. Here's the command that solved it for me:
gcc yourfile.c -o yourfile -static -lcrypto -lz -ldl
It generates this warning:
/usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup': (.text+0x1b): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
but the executable still works.
After trying this for all of today with no result, and searching through LOTS of threads on here and on forums, I'm hoping someone here will be able to find a solution.
I'm trying to get this simple example using cURL to work on Windows using MinGW.
When I try to compile it with g++
g++ -o Test.exe Test.cpp -DCURL_STATICLIB -I curl\include -L curl\lib -lcurl
it always gives me the same errors:
C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0x87): undefined reference to `_curl_easy_init'
C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0xb6): undefined reference to `_curl_easy_setopt'
C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0xc2): undefined reference to `_curl_easy_perform'
C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0xd9): undefined reference to `_curl_easy_strerror'
C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0x101): undefined reference to `_curl_easy_cleanup'
collect2.exe: error: ld returned 1 exit status
To be honest, I'm all out of ideas what could be causing this. Any help would be greatly appreciated. Thanks in advance!
Edit:
When adding the parameter -v, I'm getting the following output:
g++ -v -o Test.exe Test.cpp -DCURL_STATICLIB -I curl\include -L curl\lib -lcurl
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.7.0/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --disable-build-poststage1-with-cxx --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.7.0 (GCC)
COLLECT_GCC_OPTIONS='-v' '-o' 'Test.exe' '-D' 'CURL_STATICLIB' '-I' 'curl\include' '-Lcurl\lib' '-shared-libgcc' '-mtune=i386' '-march=i386'
c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/cc1plus.exe -quiet -v -I curl\include
-iprefix c:\mingw\bin\../lib/gcc/mingw32/4.7.0/ -D CURL_STATICLIB Test.cpp -quiet -dumpbase Test.cpp -mtune=i386 -march=i386 -auxbase Test -version -o C:\Users\Xenon\AppData\Local\Temp\ccsSlqnP.s
GNU C++ (GCC) version 4.7.0 (mingw32)
compiled by GNU C version 4.7.0, GMP version 5.0.1, MPFR version 2.4.1,
MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "c:\mingw\bin\../lib/gcc/mingw32/4.7.0/../../../../mingw32/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include/c++"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include/c++/mingw32"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include/c++/backward"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include"
ignoring nonexistent directory "/mingw/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include-fixed"
ignoring nonexistent directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/../../../../mingw32/include"
ignoring nonexistent directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
curl\include
c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include/c++
c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include/c++/mingw32
c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include/c++/backward
c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include
c:\mingw\bin\../lib/gcc/mingw32/4.7.0/../../../../include
c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include-fixed
End of search list.
GNU C++ (GCC) version 4.7.0 (mingw32)
compiled by GNU C version 4.7.0, GMP version 5.0.1, MPFR version 2.4.1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 9fc40f37d31a03e5502141ce58bdf4c7
COLLECT_GCC_OPTIONS='-v' '-o' 'Test.exe' '-D' 'CURL_STATICLIB' '-I' 'curl\include' '-Lcurl\lib' '-shared-libgcc' '-mtune=i386' '-march=i386'
c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/as.exe -o C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o C:\Users\Xenon\AppData\Local\Temp\ccsSlqnP.s
COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/
LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/4.7.0/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../
COLLECT_GCC_OPTIONS='-v' '-o' 'Test.exe' '-D' 'CURL_STATICLIB' '-I' 'curl\include' '-Lcurl\lib' '-shared-libgcc' '-mtune=i386' '-march=i386'
c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/collect2.exe -Bdynamic -u ___register_frame_info -u ___deregister_frame_info -o Test.exe c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../crt2.o c:/mingw/bin/../lib/gcc/mingw32/4.7.0/crtbegin.o -Lcurl\lib -Lc:/mingw/bin/../lib/gcc/mingw32/4.7.0 -Lc:/mingw/bin/../lib/gcc -Lc:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/lib -Lc:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../.. C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o -lcurl -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32
-luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt c:/mingw/bin/../lib/gcc/mingw32/4.7.0/crtend.o
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0xf): undefined reference to `_curl_easy_init'
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0x36): undefined reference to `_curl_easy_setopt'
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0x42): undefined reference to `_curl_easy_perform'
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0x59): undefined reference to `_curl_easy_strerror'
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0x81): undefined reference to `_curl_easy_cleanup'
collect2.exe: error: ld returned 1 exit status
I still don't know what could be causing my problem though...are all those "ignored" directories normal?
Edit: After now using a 32-bit cURL library, the compiler is literally spamming error messages. I don't know if it means it's working or even more broken now... Had to remove a few messages, as they were 506 lines...
>g++ -o Test.exe Test.cpp -DCURL_STATICLIB -I curl\include -L curl\lib -lcurl
curl\lib/libcurl.a(easy.o):(.text+0x16): undefined reference to `_WSAStartup#8'
curl\lib/libcurl.a(easy.o):(.text+0x39): undefined reference to `_WSACleanup#0'
[...]
curl\lib/libcurl.a(ssluse.o):(.text+0x1662): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x1688): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x16cb): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x16f7): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x1723): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x174f): more undefined references to `_BN_num_bits' follow
curl\lib/libcurl.a(ssluse.o):(.text+0x1833): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1876): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x18a2): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x18ce): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x18fa): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x192a): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x195a): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x199a): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x19c6): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x19f2): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x1a22): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x1a52): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1ade): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1b22): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1b66): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1baa): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1bee): more undefined references to `_BN_bn2bin' follow
curl\lib/libcurl.a(ssluse.o):(.text+0x1e8c): undefined reference to `_GENERAL_NAMES_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x1ea0): undefined reference to `_X509_get_subject_name'
curl\lib/libcurl.a(ssluse.o):(.text+0x1eca): undefined reference to `_X509_NAME_get_index_by_NID'
curl\lib/libcurl.a(ssluse.o):(.text+0x1ee2): undefined reference to `_X509_NAME_get_entry'
curl\lib/libcurl.a(ssluse.o):(.text+0x1eea): undefined reference to `_X509_NAME_ENTRY_get_data'
curl\lib/libcurl.a(ssluse.o):(.text+0x1efc): undefined reference to `_ASN1_STRING_type'
curl\lib/libcurl.a(ssluse.o):(.text+0x1f15): undefined reference to `_ASN1_STRING_to_UTF8'
curl\lib/libcurl.a(ssluse.o):(.text+0x1f7f): undefined reference to `_CRYPTO_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x1f96): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x203f): undefined reference to `_ASN1_STRING_data'
curl\lib/libcurl.a(ssluse.o):(.text+0x2052): undefined reference to `_ASN1_STRING_length'
curl\lib/libcurl.a(ssluse.o):(.text+0x20e0): undefined reference to `_PEM_read_X509'
curl\lib/libcurl.a(ssluse.o):(.text+0x2105): undefined reference to `_X509_check_issued'
curl\lib/libcurl.a(ssluse.o):(.text+0x213e): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x2146): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x21c6): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x2274): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x2280): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x22b4): more undefined references to `_X509_free' follow
curl\lib/libcurl.a(ssluse.o):(.text+0x22c3): undefined reference to `_SSL_get_verify_result'
curl\lib/libcurl.a(ssluse.o):(.text+0x233e): undefined reference to `_GENERAL_NAMES_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x23b7): undefined reference to `_ASN1_STRING_length'
curl\lib/libcurl.a(ssluse.o):(.text+0x23dc): undefined reference to `_CRYPTO_malloc'
curl\lib/libcurl.a(ssluse.o):(.text+0x23ec): undefined reference to `_ASN1_STRING_data'
curl\lib/libcurl.a(ssluse.o):(.text+0x2467): undefined reference to `_X509_verify_cert_error_string'
curl\lib/libcurl.a(ssluse.o):(.text+0x248e): undefined reference to `_X509_verify_cert_error_string'
curl\lib/libcurl.a(ssluse.o):(.text+0x24c9): undefined reference to `_GENERAL_NAMES_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x251a): undefined reference to `_RAND_load_file'
curl\lib/libcurl.a(ssluse.o):(.text+0x251f): undefined reference to `_RAND_status'
curl\lib/libcurl.a(ssluse.o):(.text+0x256a): undefined reference to `_RAND_add'
curl\lib/libcurl.a(ssluse.o):(.text+0x2578): undefined reference to `_RAND_status'
curl\lib/libcurl.a(ssluse.o):(.text+0x2599): undefined reference to `_RAND_file_name'
curl\lib/libcurl.a(ssluse.o):(.text+0x25b2): undefined reference to `_RAND_load_file'
curl\lib/libcurl.a(ssluse.o):(.text+0x25b7): undefined reference to `_RAND_status'
curl\lib/libcurl.a(ssluse.o):(.text+0x267f): undefined reference to `_ERR_clear_error'
curl\lib/libcurl.a(ssluse.o):(.text+0x268a): undefined reference to `_SSL_connect'
[...]
curl\lib/libcurl.a(ssluse.o):(.text+0x3ecb): undefined reference to `_RAND_bytes'
curl\lib/libcurl.a(ftp.o):(.text+0xdac): undefined reference to `_bind#12'
curl\lib/libcurl.a(ftp.o):(.text+0xdbc): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(ftp.o):(.text+0xdfc): undefined reference to `_htons#4'
curl\lib/libcurl.a(ftp.o):(.text+0xe4f): undefined reference to `_getsockname#12'
curl\lib/libcurl.a(ftp.o):(.text+0xe5f): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(ftp.o):(.text+0xf2d): undefined reference to `_getsockname#12'
curl\lib/libcurl.a(ftp.o):(.text+0xf51): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(ftp.o):(.text+0xfb4): undefined reference to `_getsockname#12'
curl\lib/libcurl.a(ftp.o):(.text+0xfc4): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(ftp.o):(.text+0x10d1): undefined reference to `_listen#8'
curl\lib/libcurl.a(ftp.o):(.text+0x10dd): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(ftp.o):(.text+0x11e9): undefined reference to `_ntohs#4'
curl\lib/libcurl.a(ftp.o):(.text+0x1249): undefined reference to `_ntohs#4'
curl\lib/libcurl.a(ftp.o):(.text+0x1429): undefined reference to `_getsockname#12'
curl\lib/libcurl.a(ftp.o):(.text+0x1478): undefined reference to `_accept#12'
curl\lib/libcurl.a(ftp.o):(.text+0x2bb9): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text+0x3fc): undefined reference to `_WSAStartup#8'
curl\lib/libcurl.a(telnet.o):(.text+0x432): undefined reference to `_WSACleanup#0'
curl\lib/libcurl.a(telnet.o):(.text+0xe1b): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text+0xe41): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text+0xf11): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x17b): undefined reference to `_send#16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x18b): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x3bb): undefined reference to `_ntohs#4'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x3cb): undefined reference to `_ntohs#4'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x5bd): undefined reference to `_htons#4'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x5d2): undefined reference to `_htons#4'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x6ae): undefined reference to `_send#16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x6ba): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x708): undefined reference to `_send#16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x714): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x853): undefined reference to `_send#16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x85f): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x9ad): undefined reference to `_send#16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x9b9): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(ldap.o):(.text+0x221): undefined reference to `__imp__ldap_err2stringA'
curl\lib/libcurl.a(ldap.o):(.text+0x267): undefined reference to `__imp__ldap_msgfree'
curl\lib/libcurl.a(ldap.o):(.text+0x298): undefined reference to `__imp__ldap_unbind_s'
curl\lib/libcurl.a(ldap.o):(.text+0x6cb): undefined reference to `__imp__ldap_set_optionA'
curl\lib/libcurl.a(ldap.o):(.text+0x721): undefined reference to `__imp__ldap_simple_bind_sA'
curl\lib/libcurl.a(ldap.o):(.text+0x778): undefined reference to `__imp__ldap_search_sA'
curl\lib/libcurl.a(ldap.o):(.text+0x796): undefined reference to `__imp__ldap_err2stringA'
curl\lib/libcurl.a(ldap.o):(.text+0x825): undefined reference to `__imp__ldap_err2stringA'
curl\lib/libcurl.a(ldap.o):(.text+0x888): undefined reference to `__imp__ldap_set_optionA'
curl\lib/libcurl.a(ldap.o):(.text+0x8a3): undefined reference to `__imp__ldap_initA'
curl\lib/libcurl.a(ldap.o):(.text+0x8dd): undefined reference to `__imp__ldap_first_entry'
curl\lib/libcurl.a(ldap.o):(.text+0x91e): undefined reference to `__imp__ldap_get_dnA'
curl\lib/libcurl.a(ldap.o):(.text+0x9bd): undefined reference to `__imp__ldap_first_attributeA'
curl\lib/libcurl.a(ldap.o):(.text+0x9e9): undefined reference to `__imp__ldap_get_values_lenA'
curl\lib/libcurl.a(ldap.o):(.text+0xbc9): undefined reference to `__imp__ldap_value_free_len'
curl\lib/libcurl.a(ldap.o):(.text+0xc1e): undefined reference to `__imp__ldap_memfreeA'
curl\lib/libcurl.a(ldap.o):(.text+0xc3d): undefined reference to `__imp__ldap_next_attributeA'
curl\lib/libcurl.a(ldap.o):(.text+0xc56): undefined reference to `__imp__ldap_memfreeA'
curl\lib/libcurl.a(ldap.o):(.text+0xc71): undefined reference to `__imp__ber_free'
curl\lib/libcurl.a(ldap.o):(.text+0xc86): undefined reference to `__imp__ldap_next_entry'
curl\lib/libcurl.a(ldap.o):(.text+0xcaf): undefined reference to `__imp__ldap_value_free_len'
curl\lib/libcurl.a(ldap.o):(.text+0xcbc): undefined reference to `__imp__ldap_memfreeA'
curl\lib/libcurl.a(ldap.o):(.text+0xccb): undefined reference to `__imp__ldap_memfreeA'
curl\lib/libcurl.a(ldap.o):(.text+0xcea): undefined reference to `__imp__ber_free'
curl\lib/libcurl.a(tftp.o):(.text+0x210): undefined reference to `_sendto#24'
curl\lib/libcurl.a(tftp.o):(.text+0x29b): undefined reference to `_sendto#24'
[...]
curl\lib/libcurl.a(ssh.o):(.text+0x46a9): undefined reference to `_libssh2_knownhost_init'
curl\lib/libcurl.a(ssh.o):(.text+0x46cd): undefined reference to `_libssh2_knownhost_readfile'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x24): undefined reference to `_RTMP_Close'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x2c): undefined reference to `_RTMP_Free'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0xbc): undefined reference to `_setsockopt#20'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0xcf): undefined reference to `_RTMP_Connect1'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x13d): undefined reference to `_RTMP_Write'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x15e): undefined reference to `_RTMP_Alloc'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x16c): undefined reference to `_RTMP_Init'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x17c): undefined reference to `_RTMP_SetBufferMS'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x190): undefined reference to `_RTMP_SetupURL'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x1ac): undefined reference to `_RTMP_Free'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x1eb): undefined reference to `_RTMP_Read'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x24e): undefined reference to `_RTMP_ConnectStream'
curl\lib/libcurl.a(select.o):(.text+0x2e): undefined reference to `_WSASetLastError#4'
curl\lib/libcurl.a(select.o):(.text+0x2ae): undefined reference to `_select#20'
curl\lib/libcurl.a(select.o):(.text+0x2bd): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(select.o):(.text+0x354): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x374): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x3b4): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x3d1): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x42f): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x445): more undefined references to `___WSAFDIsSet#8' follow
curl\lib/libcurl.a(select.o):(.text+0x77d): undefined reference to `_select#20'
curl\lib/libcurl.a(select.o):(.text+0x78c): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(select.o):(.text+0x849): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x863): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x884): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(content_encoding.o):(.text+0x170): undefined reference to `_inflate'
curl\lib/libcurl.a(content_encoding.o):(.text+0x18c): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x1ac): undefined reference to `_inflateInit2_'
curl\lib/libcurl.a(content_encoding.o):(.text+0x224): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x27e): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x294): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x2be): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x2ce): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x33e): undefined reference to `_inflateInit_'
curl\lib/libcurl.a(content_encoding.o):(.text+0x472): undefined reference to `_zlibVersion'
curl\lib/libcurl.a(content_encoding.o):(.text+0x4b0): undefined reference to `_inflateInit2_'
curl\lib/libcurl.a(content_encoding.o):(.text+0x4f8): undefined reference to `_inflateInit2_'
curl\lib/libcurl.a(content_encoding.o):(.text+0x58c): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x5c9): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x6ca): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(nonblock.o):(.text+0x2a): undefined reference to `_ioctlsocket#12'
curl\lib/libcurl.a(md5.o):(.text+0x15): undefined reference to `_MD5_Init'
curl\lib/libcurl.a(md5.o):(.text+0x3b): undefined reference to `_MD5_Update'
curl\lib/libcurl.a(md5.o):(.text+0x4e): undefined reference to `_MD5_Final'
curl\lib/libcurl.a(md5.o):(.rdata+0x0): undefined reference to `_MD5_Init'
curl\lib/libcurl.a(md5.o):(.rdata+0x4): undefined reference to `_MD5_Update'
curl\lib/libcurl.a(md5.o):(.rdata+0x8): undefined reference to `_MD5_Final'
curl\lib/libcurl.a(md5.o):(.rdata+0x14): undefined reference to `_MD5_Init'
curl\lib/libcurl.a(md5.o):(.rdata+0x18): undefined reference to `_MD5_Update'
curl\lib/libcurl.a(md5.o):(.rdata+0x1c): undefined reference to `_MD5_Final'
curl\lib/libcurl.a(curl_gethostname.o):(.text+0x19): undefined reference to `_gethostname#8'
curl\lib/libcurl.a(socks_sspi.o):(.text+0x2e4): undefined reference to `_htons#4'
curl\lib/libcurl.a(socks_sspi.o):(.text+0x427): undefined reference to `_ntohs#4'
curl\lib/libcurl.a(socks_sspi.o):(.text+0x811): undefined reference to `_htons#4'
curl\lib/libcurl.a(socks_sspi.o):(.text+0xc5c): undefined reference to `_htons#4'
curl\lib/libcurl.a(socks_sspi.o):(.text+0xd7e): undefined reference to `_ntohs#4'
collect2.exe: error: ld returned 1 exit status
Edit: I also tried downloading the Windows OpenSSL package offered on their website and including it - no change.
Edit: It's finally working! The solution was to use the 32-bit cURL package and to pass these parameters to the compiler:
g++ -o Test.exe Test.cpp -DCURL_STATICLIB -I curl\include -L curl\lib -lcurldll -lssh2 -lidn -lrtmp -lssl -lcrypto -lz -lws2_32 -lwldap32
Since everything is setup correctly, I see two solutions:
either remove -DCURL_STATICLIB or add -static to your command line.
Edit:
It took some time, but it looks like you have a 32 bit Mingw and a 64 bit libcurl. Download the 32 bit libcurl and try again.
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