Giter Site home page Giter Site logo

Comments (7)

traversaro avatar traversaro commented on June 15, 2024

I think the "recommended way" really depends on which build system you use in your project, and how you handle other 3rd-party dependencies.

If you use CMake, you can install dlfcn-win32 in a specific prefix using CMAKE_INSTALL_PREFIX , and then find it using the instructions documented in https://github.com/dlfcn-win32/dlfcn-win32#using-cmake .
I think it should be possible to also consume it via the FetchContent module, but that is still a work in progress ( https://github.com/dlfcn-win32/dlfcn-win32#using-cmake ).

If instead you typically vendor (i.e. copy in your project) also other dependencies, you can just grab the dlfcn.c and dlfcn.h files and include them in your project. To comply to the LGPL license of the project and avoid the need to license under the LGPL all your project, I suggest to make sure that you compile the dlfcn.c in a standalone shared library.

Yet another alternative is using vcpkg. A port of dlfcn-win32 for vcpkg is available in the main vcpkg repo: https://github.com/Microsoft/vcpkg/tree/master/ports/dlfcn-win32 .

from dlfcn-win32.

cipher1024 avatar cipher1024 commented on June 15, 2024

So far so good. I followed the instruction for cmake and I added a call to vcpkg in my appveyor script. cmake doesn't seem to be finding dlfcn-win32. How do I encode the path to dlfcn-win32 into my cmake file?

from dlfcn-win32.

Lukacms avatar Lukacms commented on June 15, 2024

Hello, did you found any solution ? I'm stuck on the same problem and I don't have Windows on my laptop so I'm testing with Github Actions, which is not ideal. I used FetchContent to install it, but it doesn't find the package, with or without find_package(dlfcn-win32 REQUIRED). Below is my CMake:

project(r-type-utils)

# standard version cpp
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)

# change library prefix to none
set(CMAKE_SHARED_LIBRARY_PREFIX "")
set(CMAKE_STATIC_LIBRARY_PREFIX "")

if (WIN32)
    include(FetchContent)
    FetchContent_Declare(
        dlfcn-win32
        GIT_REPOSITORY "https://github.com/dlfcn-win32/dlfcn-win32.git"
        GIT_TAG "v1.4.1"
        SYSTEM
    )
    FetchContent_MakeAvailable(dlfcn-win32)
endif()

# only add the interface library
add_library(r-type-utils INTERFACE)

# properties
set_property(TARGET r-type-utils PROPERTY CXX_STANDARD 20)
set_property(TARGET r-type-utils PROPERTY CXX_STANDARD_REQUIRED ON)
if (WIN32)
    find_package(dlfcn-win32 REQUIRED)
    target_include_directories(r-type-utils INTERFACE ${CMAKE_BINARY_DIR}/_deps/dlfcn-win32-src/src)
    target_link_libraries(r-type-utils INTERFACE dlfcn-win32::dl)
endif()

from dlfcn-win32.

traversaro avatar traversaro commented on June 15, 2024

If you included the library via FetchContent, the dlfcn-win32::dl target should be available after you call FetchContent_MakeAvailable(dlfcn-win32). If this is not working, there is a bug on dlfcn-win32 side. Furthermore, include directory should be already handled by the target, so you should not need target_include_directories(r-type-utils INTERFACE ${CMAKE_BINARY_DIR}/_deps/dlfcn-win32-src/src). Can you remove find_package and target_include_directories and try again?

from dlfcn-win32.

traversaro avatar traversaro commented on June 15, 2024

So far so good. I followed the instruction for cmake and I added a call to vcpkg in my appveyor script. cmake doesn't seem to be finding dlfcn-win32. How do I encode the path to dlfcn-win32 into my cmake file?

Sorry, this is a really old question, but I missed it. If you installed a library via vcpkg, to find it you need to add find_package(dlfcn-win32) in your CMakeLists.txt, and call your cmake by passing the vcpkg toolchain, see https://learn.microsoft.com/en-us/vcpkg/users/buildsystems/cmake-integration#cmake_toolchain_file for more details.

from dlfcn-win32.

Lukacms avatar Lukacms commented on June 15, 2024

If you included the library via FetchContent, the dlfcn-win32::dl target should be available after you call FetchContent_MakeAvailable(dlfcn-win32). If this is not working, there is a bug on dlfcn-win32 side. Furthermore, include directory should be already handled by the target, so you should not need target_include_directories(r-type-utils INTERFACE ${CMAKE_BINARY_DIR}/_deps/dlfcn-win32-src/src). Can you remove find_package and target_include_directories and try again?

Thank you for your answer ! I did as you said but it did not compile, I put the log below:
image

from dlfcn-win32.

traversaro avatar traversaro commented on June 15, 2024

You are right, there is something missing on our side (that issue is actually tracked in #49). As a temporary workaround, you can just change target_link_libraries(r-type-utils INTERFACE dlfcn-win32::dl) to target_link_libraries(r-type-utils INTERFACE dl) and it should work fine (I guess).

from dlfcn-win32.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.