Comments (7)
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.
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.
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.
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.
So far so good. I followed the instruction for
cmake
and I added a call tovcpkg
in my appveyor script.cmake
doesn't seem to be findingdlfcn-win32
. How do I encode the path todlfcn-win32
into mycmake
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.
If you included the library via
FetchContent
, thedlfcn-win32::dl
target should be available after you callFetchContent_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 needtarget_include_directories(r-type-utils INTERFACE ${CMAKE_BINARY_DIR}/_deps/dlfcn-win32-src/src)
. Can you removefind_package
andtarget_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:
from dlfcn-win32.
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)
- Understand why settting cmake_minimum_required to 3.20 make test fail HOT 1
- Use of LoadLibraryExA with LOAD_WITH_ALTERED_SEARCH_PATH flag HOT 9
- config.mak: No such file or directory HOT 5
- can I dlsym malloc function? HOT 5
- Add support and docs for using dlfcn-win32 using CMake's FetchContent module HOT 1
- MAX_PATH restriction feasible after Windows dropped it for Win10? HOT 3
- ERROR Non-library file %TEMP%\temp.dll was processed via WINAPI: 18 From line 138 HOT 3
- Should common subset of ZDICT_cover_params_t and ZDICT_fastCover_params_t be moved into a separate struct and put it into the front of the struct, implementing inheritance this way? HOT 1
- UTF-8 path failes to dlopen HOT 11
- Add automatic tests with Dr. Memory
- dlsym multiple defintion HOT 2
- undefined reference to `GetModuleHandleExA' HOT 6
- AppVeyor test problems HOT 4
- Using dlfcn-win32 as a subproject of libbacktrace, gollvm HOT 3
- Write docs on how to use the dlfcn-win32 in a buildsystem agnostic way
- no RTLD_NOLOAD HOT 6
- Add support to dladdr() to inspect export table for additional symbols
- Release 1.3.0 HOT 7
- Testing i586-mingw32msvc-gcc builds via cmake HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dlfcn-win32.