C++ running file with included library failes without compiling error (CMake / CLion)

后端 未结 1 663
孤城傲影
孤城傲影 2021-01-24 17:32

I got the following problem; I have my super library called mylib: it looks like this:

My project folder is called library...


mylib.hpp

n         


        
相关标签:
1条回答
  • 2021-01-24 18:09

    Exit code -1073741515 (0xC0000135) is STATUS_DLL_NOT_FOUND. This would indicate that the dll isn't available to the program at runtime. In windows, the search path for a dll is as follows:

    1. The directory where the executable for the current process is located.
    2. The current directory.
    3. The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.
    4. The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.
    5. The directories listed in the PATH environment variable.

    Verify that liblibrary.dll is located in a place it can be found by the executable.

    Once you have done that, you may want to add a macro to help you copy the dll to the executable directory as part of your build. This can be done in cmake like so:

    add_custom_command(TARGET uselib POST_BUILD        # Adds a post-build event to uselib
    COMMAND ${CMAKE_COMMAND} -E copy_if_different  # which executes "cmake - E copy_if_different..."
        "${PROJECT_SOURCE_DIR}/libs/liblibrary.dll"      # this is in-file
        $<TARGET_FILE_DIR:uselib>)                 # this is out-file path
    
    0 讨论(0)
提交回复
热议问题