CMake: DLL's Missing

0

I'm new to CMake and after a week of endless errors I'm at my wit's end.

main.cpp

#include <tox/tox.h>

int main(int argc, char **argv) {
    Tox* tox = tox_new(NULL, NULL);
    return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.18)

Project(toxtest)

add_library(toxcore SHARED IMPORTED)
set_target_properties(toxcore PROPERTIES
    INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/c-toxcore/include"
    IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/c-toxcore/_build/Debug/toxcore.lib"
    IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/c-toxcore/_build/Debug/toxcore.dll"
)

set(BINARY_NAME "toxtest-bin")
add_executable(${BINARY_NAME} main.cpp)
target_link_libraries(${BINARY_NAME} PUBLIC toxcore)

Introduction: My C++ executable depends on a C-library called toxcore, toxcore depends on two other C-libraries called pthread-win32 and libsodium. I have compiled the toxcore library with the following flags, to solve a unresolved external symbol error (Not sure if this is the right way):

cmake .. -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE

I build my executable successfully but now it complains about missing DLL's: toxcore.dll, libsodium.dll, pthreadVC2.dll

With my patience running out: I dumped the DLL's into the directory with the executable, and now I got Application Error:

The application was unable to start correctly (0xc000007b)

How do I this properly? I want to solve the Application Error, and let the executable find the DLL's in their respective directories.

PS: Before anyone marks my question as duplicate. I have looked thru and tried stackoverflow answers which were not sufficient in detail/clarity for a beginner like me. I need someone to give me a more tailored answer and tell me if my steps are in line with the current best practices.

c++
cmake
asked on Stack Overflow Feb 14, 2021 by userX • edited Feb 14, 2021 by userX

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0