Git Product home page Git Product logo

Comments (8)

gregsskyles avatar gregsskyles commented on June 16, 2024

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.

from meson.

SivapriyaMR avatar SivapriyaMR commented on June 16, 2024

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 have already built the static library i just want to include it to meson.build

from meson.

gregsskyles avatar gregsskyles commented on June 16, 2024

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

from meson.

dcbaker avatar dcbaker commented on June 16, 2024

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',
)

from meson.

SivapriyaMR avatar SivapriyaMR commented on June 16, 2024
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

from meson.

dcbaker avatar dcbaker commented on June 16, 2024

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

from meson.

SivapriyaMR avatar SivapriyaMR commented on June 16, 2024

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

from meson.

dcbaker avatar dcbaker commented on June 16, 2024

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

from meson.

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.