How to link shared library *dll with CMake in Windows

JohnyBe

I have 2 files: library.dll and library.h with some code that I need in my own project. I'm working on Windows with Clion where I should config this with CMake.

I tried this way:

cmake_minimum_required(VERSION 3.6)
project(test2)

set(CMAKE_CXX_STANDARD 11)
link_directories(C:\\Users\\Johny\\CLionProjects\\test2)

set(SOURCE_FILES main.cpp)
add_executable(test2 ${SOURCE_FILES})

target_link_libraries(test2 library.dll)

It compiled but didnt work. Returns code -1073741515

How can I handle with it?

AKJ

Although this question is old. You are targeting the link library wrongly. target_link_libraries(test2 library.dll) is wrong. This is an example linking SDL2. In the main CMakeList.txt

cmake_minimum_required(VERSION 3.12)
project(GraphicTest)

set(CMAKE_CXX_STANDARD 11)

include_directories("${PROJECT_SOURCE_DIR}/SDL")
add_subdirectory(SDL)

add_executable(GraphicTest main.cpp)
target_link_libraries(GraphicTest SDL2)

and in the library folder. Here SDL, add a CMakeLists.txt

message("-- Linking SDL")
add_library(SDL2 SDL2.dll)
set_target_properties(SDL2 PROPERTIES LINKER_LANGUAGE C)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

CMake link shared library on Windows

From Dev

Cmake: How to statically link packages to shared library?

From Dev

How to link a shared library with CMake with relative path

From Dev

Linking shared dll library cmake clion project

From Dev

Build gtest as shared library (dll) in CMake

From Dev

CMAKE link shared library that has version information

From Dev

Cmake: link openscenegraph to my shared library

From Dev

How to link shared library to another shared library

From

How to create a shared library with cmake?

From Dev

cmake: how to set rpath in a shared library with only target_link_directories (without target_link_libraries)?

From Dev

cmake: how to link a library which has a lib prefix on windows

From Dev

CMake shared library from object library & DLL exports

From Dev

How to link library using cmake

From Dev

Link error with SFML library in CMake project on Windows

From Dev

How are windows DLL actually shared?

From Java

Could not link static c library with shared lib in android using Cmake

From Dev

cmake: cannot find the shared library when coming to link stage

From Dev

cmake - Is it possible to link executable to shared library with relative path at runtime?

From Java

cmake: target_link_libraries use static library not shared

From Dev

CMake link directory passing when compiling shared library

From Dev

cmake link error on linking shared library hierarchy to executable

From Dev

How to link a library generated by cmake on other directory?

From Dev

How do I link a library using CMake?

From Dev

How to link to the C math library with CMake?

From Dev

How to use dynamic link library with CMake?

From Dev

how do i link wininet library with cmake

From Dev

CMake how to link subproject with external library

From Dev

How to link Android NDK shared library?

From Dev

How to link libnode.a to a shared library in linux

Related Related

  1. 1

    CMake link shared library on Windows

  2. 2

    Cmake: How to statically link packages to shared library?

  3. 3

    How to link a shared library with CMake with relative path

  4. 4

    Linking shared dll library cmake clion project

  5. 5

    Build gtest as shared library (dll) in CMake

  6. 6

    CMAKE link shared library that has version information

  7. 7

    Cmake: link openscenegraph to my shared library

  8. 8

    How to link shared library to another shared library

  9. 9

    How to create a shared library with cmake?

  10. 10

    cmake: how to set rpath in a shared library with only target_link_directories (without target_link_libraries)?

  11. 11

    cmake: how to link a library which has a lib prefix on windows

  12. 12

    CMake shared library from object library & DLL exports

  13. 13

    How to link library using cmake

  14. 14

    Link error with SFML library in CMake project on Windows

  15. 15

    How are windows DLL actually shared?

  16. 16

    Could not link static c library with shared lib in android using Cmake

  17. 17

    cmake: cannot find the shared library when coming to link stage

  18. 18

    cmake - Is it possible to link executable to shared library with relative path at runtime?

  19. 19

    cmake: target_link_libraries use static library not shared

  20. 20

    CMake link directory passing when compiling shared library

  21. 21

    cmake link error on linking shared library hierarchy to executable

  22. 22

    How to link a library generated by cmake on other directory?

  23. 23

    How do I link a library using CMake?

  24. 24

    How to link to the C math library with CMake?

  25. 25

    How to use dynamic link library with CMake?

  26. 26

    how do i link wininet library with cmake

  27. 27

    CMake how to link subproject with external library

  28. 28

    How to link Android NDK shared library?

  29. 29

    How to link libnode.a to a shared library in linux

HotTag

Archive