DJViking
(Sverre Moe)
March 18, 2022, 8:30am
1
How to link with shared libraries installed on the system?
https://docs.gradle.org/current/userguide/building_cpp_projects.html
I found this documentation a bit lacking. Does not say how to link to external libraries, other than using dependencies from binaries stored in a maven repository.
The libraries I want to use are installed on the system through the Linux package manager.
It is so easy with CMake:
First find the package, then link it.
Here I am linking with Google Protobuf, which requires the package protobuf-devel to be installed through the package manager.
I do not need to know the path of this library on my system, nor the libraries to link it.
find_package(Protobuf REQUIRED)
target_include_directories(application PRIVATE
${Protobuf_INCLUDE_DIRS}
)
target_link_libraries(application PRIVATE
${Protobuf_LIBRARIES}
)
I found some similar questions, but none of these has been answered.
In my build.gradle I have it compiling the source with the correct compiler flags but the build fails because I did not declare how to link in the external C++ static and shared libraries. What is the correct way to declare external static and shared libraries?
I’m using the cpp-application plugin of gradle 7.3 to compile a native executable on Ubuntu Linux.
I was able to get the executable to compile and link. However, when I try to run it, it gives the error:
<executable-path>: error while loading shared libraries: lib<my-library>.so: cannot open shared object file: No such file or directory
Normally, one solution to this problem is to use the LD_LIBRARY_PATH environment variable and set to to include the directory that contains lib<my-library>.…
I’m trying to make a plugin to include the headers and static libraries of the vulkan sdk. The examples in the gradle native samples repository showed me how to add the header files to the build programmatically. Now I’m trying to add a static library to add the vulkan static library to the build, and for the life of me I cannot figure it out.
The sample here shows code specific to groovy that I’m trying to translate to a kotlin plugin to add a library. What I’ve tried is this:
val sdkPath = S…