Open SivapriyaMR opened 6 months ago
I think your issue is that you have specified that libcrypto.a
is a source file to build your static library crypto
. Is that what you really meant? It seems like it should be libcrypto.c
or some such.
I think your issue is that you have specified that
libcrypto.a
is a source file to build your static librarycrypto
. Is that what you really meant? It seems like it should belibcrypto.c
or some such.
I have already built the static library i just want to include it to meson.build
static_library(...)
is how you build a static library. See https://mesonbuild.com/Reference-manual_functions.html#static_library
You might want to have a look at https://mesonbuild.com/Dependencies.html
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',
)
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', )
Trying the above methods i encountered few error such as - meson.build:27:21: ERROR: Expecting rbracket got string. compile_args : [f'-I{root_dir}/include/crypto'],
Library crypto found: YES
meson.build:25:0: ERROR: Entries in "link_with" may only be self-built targets, external dependencies (including libraries) must go to "dependencies".
So i changed a little i have poste dit below
This is the structure i have saved the libraries usr/local/openssl-root/ ├── include/ │ ├── openssl/ │ │ ├── ssl.h │ │ └── ... └── lib/ ├── libcrypto.a ├── libssl.a └── ...
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
meson.build:25:0: ERROR: Entries in "link_with" may only be self-built targets,
Oops, yes, that should be dependencies
not link_with
. I don't know what I was thinking when I wrote that.
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
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
After doing meson setup _build this is how it build
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)
Library crypto found: YES
Library ssl found: YES
Library oqs found: YES
But this is the error im getting when i do ninja -c build
[203/265] Linking target p11-kit/libp11-kit.so.0.3.1.
FAILED: p11-kit/libp11-kit.so.0.3.1
/usr/bin/ld: p11-kit/077403d@@p11-kit@sha/rpc-server.c.o: in function p11_kit_remote_serve_module': /home/eaas/Sivapriya/p11-kit/_build/../p11-kit/rpc-server.c:2514: undefined reference to
OPENSSL_init_ssl'
/usr/bin/ld: /home/eaas/Sivapriya/p11-kit/_build/../p11-kit/rpc-server.c:2523: undefined reference to SSL_CTX_set_verify' /usr/bin/ld: /home/eaas/Sivapriya/p11-kit/_build/../p11-kit/rpc-server.c:2524: undefined reference to
SSL_CTX_load_verify_locations'
/usr/bin/ld: /home/eaas/Sivapriya/p11-kit/_build/../p11-kit/rpc-server.c:2528: undefined reference to `SSL_new'
Im trying to add ssl functions to p11-kit, will you be able to help with this please
What does the library
or shared_library
call for libp11-kit
look like? I suspect you need to add dep_ssl
to that target's dependency
line
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