Error while trying to add a shared library to meson build #14403
Replies: 8 comments
-
I think your issue is that you have specified that |
Beta Was this translation helpful? Give feedback.
-
I have already built the static library i just want to include it to meson.build |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
This is not the idiomatic way to find a dependency. There is a libcrypto finder in Meson, you may be able to make this work by simply doing (untested): project('myproject', 'c')
dep_crypto = dependency('libcrypto', static : true) meson setup builddir -Dc_args="-I/path/to/crypto/includes" -Dc_link_args="-L/path/to/crypto/libs" It doesn't look like liboqs provides any discovery methods at all? I don't see a pkg-config or a cmake-config, so that's going to be rather difficult to use from Meson. The way to handle libraries like that if you can't use a pkg-config is something like: cc = meson.get_compiler('c')
root_dir = get_option('openssl-root') # or hardcode it if you don't care if it works on another machine
dep = declare_dependency(
link_with : cc.find_library('crypto', dirs : root_dir, static : true),
compile_args : f'-I@root_dir@/include',
) |
Beta Was this translation helpful? Give feedback.
-
Trying the above methods i encountered few error such as - Library crypto found: YES meson.build:25:0: ERROR: Entries in "link_with" may only be self-built targets, So i changed a little i have poste dit below This is the structure i have saved the libraries In my build file i have added these lines as you suggested cc = meson.get_compiler('c')
openssl_root = get_option('openssl-root') # or hardcode it if you don't care if it works on another machine
liboqs_root = get_option('liboqs-root') # or hardcode it if you don't care if it works on another machine
crypto_dep = dependency('crypto', required : false)
ssl_dep = dependency('ssl', required : false)
oqs_dep = dependency('oqs', required : false)
if not crypto_dep.found()
dep = declare_dependency(
compile_args : ['-I' + join_paths(openssl_root, 'include', 'crypto')],
link_with : crypto_dep,
)
endif
if not ssl_dep.found()
dep = declare_dependency(
compile_args : ['-I' + join_paths(openssl_root, 'include', 'openssl')],
link_with : ssl_dep,
)
endif
if not oqs_dep.found()
dep = declare_dependency(
compile_args : ['-I' + join_paths(liboqs_root, 'include', 'oqs')],
link_with : oqs_dep,
)
endif This is the error im getting when i do meson build : Found pkg-config: /usr/bin/pkg-config (0.29.1)
Found CMake: /usr/bin/cmake (3.16.3)
Run-time dependency crypto found: NO (tried pkgconfig and cmake)
Run-time dependency ssl found: NO (tried pkgconfig and cmake)
Run-time dependency oqs found: NO (tried pkgconfig and cmake)
meson.build:35:4: ERROR: Entries in "link_with" may only be self-built targets,
external dependencies (including libraries) must go to "dependencies". i have static libraries libssl.a, libcrypto.a and liboqs.a i also have the .h files of these libraries i have used the functions of ssl in my code so i want to add these libraries to the build and link |
Beta Was this translation helpful? Give feedback.
-
Oops, yes, that should be I think this is what you want: # [snip]
if not crypto_dep.found()
dep = declare_dependency(
compile_args : ['-I' + join_paths(openssl_root, 'include', 'crypto')],
dependencies : cc.find_library('crypto', dirs : join_paths(openssl_root, 'lib')),
)
endif
if not ssl_dep.found()
dep = declare_dependency(
compile_args : ['-I' + join_paths(openssl_root, 'include', 'openssl')],
dependencies : cc.find_library('ssl', dirs : join_paths(openssl_root, 'lib')),
)
endif
if not oqs_dep.found()
dep = declare_dependency(
compile_args : ['-I' + join_paths(liboqs_root, 'include', 'oqs')],
dependencies : cc.find_library('oqs', dirs : join_paths(liboqs_root, 'lib')),
)
endif |
Beta Was this translation helpful? Give feedback.
-
Hey, Thankyou for your help my meson setup _build is successful, but im still facing issue in ninja build , it says undefined reference to all the openssl functions i have used, i have added the libraries properly but still it says undefined reference and throws an error But this is the error im getting when i do ninja -c build Im trying to add ssl functions to p11-kit, will you be able to help with this please |
Beta Was this translation helpful? Give feedback.
-
What does the |
Beta Was this translation helpful? Give feedback.
-
openssl_dir = '/home/Sivapriya/openssl-3.2.1'
liboqs_dir = '/home/Sivapriya/liboqs/_build'
add_project_arguments(['-D_GNU_SOURCE', '-DP11_KIT_FUTURE_UNSTABLE_API'],
language: 'c')
openssl_lib_dir = join_paths(openssl_dir, 'lib')
liboqs_lib_dir = join_paths(liboqs_dir, 'lib')
libcrypto = static_library('crypto',
files('/home/Sivapriya/openssl-3.2.1/libcrypto.a'),
link_args: '-L/home/Sivapriya/openssl-3.2.1 -lcrypto',
include_directories: '/home/Sivapriya/openssl-3.2.1/include')
libssl = static_library('ssl', files('/home/Sivapriya/openssl-3.2.1/libssl.a'), include_directories: openssl_dir/'include')
liboqs = static_library('liboqs', files('/home/Sivapriya/liboqs/_build/lib/liboqs.so'), include_directories: liboqs_dir/'include')
I have added these lines to my meson.build file of p11-kit while running meson setup _build command im getting this error:
No specified compiler can handle file /home/Sivapriya/openssl-3.2.1/libcrypto.a
Can anyone please give me a solution ASAP!
system parameters
what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.)
Ubuntu 20
what Python version
3.8.10
what meson --version
0.53.2
what ninja --version if it's a Ninja build
1.10.0
Beta Was this translation helpful? Give feedback.
All reactions