Git Product home page Git Product logo

nativelibs's Introduction

NativeLibs

The simple use in your module is:

use NativeLibs; # This also re-exports NativeCall :DEFAULTS for convenience
my $Lib; # To keep the reference

sub some_native_func() is native { * } # Note no library needed
… The rest of your module

INIT {
    # Load the needed library
    without $Lib = NativeLibs::Loader.load('libsomelib.so.4') {
        .fail;
    }
}
…

If in your native library binding you need to support a range of versions:

use NativeLibs;

constant LIB = NativeLibs::Searcher.at-runtime(
    'mysqlclient', # The library short name
    'mysql_init',  # A 'well known symbol'
    16..20	   # A List of supported versions, a range in this example
);

sub mysql_get_client_info(--> Str)       is export is native(LIB) { * }

...

This is a grow-up version of the original NativeLibs (v0.0.3) included in DBIish now released to allow the interested people the testing and discussion of the module.

So, if you use this in your own module, please use with a version, for example:

use NativeLibs:ver<0.0.5>;

and include "NativeLibs:ver<0.0.5+>" in your META6's depends

Other examples in the drivers of https://github.com/perl6/DBIish

nativelibs's People

Contributors

curttilmes avatar hankache avatar jj avatar ohmycloud avatar salortiz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nativelibs's Issues

How can I specify 'no version'?

I want to find either "libfoo.so.1", "libfoo.so.1.3" or "libfoo.so.1.3.0" or "libfoo.so" without a version.

It isn't just a 'range of versions' -- I want either version 1, or 1.3 or 1.3.0 or no version at all.

Fails to Install on FreeBSD 12-STABLE

% zef install -v .
===> Testing: NativeLibs:ver<0.0.7>:authgithub:salortiz
[NativeLibs] t/01-basic.t ........ ok
[NativeLibs] t/02-cannon-name.t ..
[NativeLibs] Dubious, test returned 255 (wstat 65280, 0xff00)
[NativeLibs] Failed 10/10 subtests
[NativeLibs] t/10-search.t ....... ok
[NativeLibs] t/20-compile.t ...... ok
[NativeLibs] Test Summary Report
[NativeLibs] -------------------
[NativeLibs] t/02-cannon-name.t (Wstat: 65280 Tests: 0 Failed: 0)
[NativeLibs] Non-zero exit status: 255
[NativeLibs] Parse errors: Bad plan. You planned 10 tests but ran 0.
[NativeLibs] t/10-search.t (Wstat: 0 Tests: 3 Failed: 0)
[NativeLibs] TODO passed: 3
[NativeLibs] Files=4, Tests=27, 3 wallclock secs ( 0.05 usr 0.02 sys + 5.52 cusr 0.47 csys = 6.06 CPU)
[NativeLibs] Result: FAIL
===> Testing [FAIL]: NativeLibs:ver<0.0.7>:authgithub:salortiz
Aborting due to test failure: NativeLibs:ver<0.0.7>:authgithub:salortiz (use --force-test to override)

Problem installing NativeLibs in Alpine

[NativeLibs] # Failed test 'No version found'
[NativeLibs] # at t/10-search.t line 22
[NativeLibs] # Failed test 'Can't be loaded'
[NativeLibs] # at t/10-search.t line 24

This is an (indirect) dependence of DBIish (through UUID), since it's not listed differently.

Tests fail on Windows 10

Welcome to Rakudo(tm) v2020.12-31-gf89863249.
Implementing the Raku(tm) programming language v6.d.
Built on MoarVM version 2020.12-16-g34f9d8c7a.
❯ zef install NativeLibs
===> Searching for: NativeLibs
===> Testing: NativeLibs:ver<0.0.8>:auth<github:salortiz>
[NativeLibs] No such method 'CALL-ME' for invocant of type
[NativeLibs] 'NativeCall::Types::Pointer'
[NativeLibs]   in block  at t/10-search.t line 37
[NativeLibs]   in block <unit> at t/10-search.t line 10
[NativeLibs] foo.c: In function 'main':
[NativeLibs] foo.c:4:21: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'long long unsigned int' [-Wformat=]
[NativeLibs]      printf("size: %lu", sizeof(int));
[NativeLibs]                    ~~^   ~~~~~~~~~~~
[NativeLibs]                    %I64u
[NativeLibs] foo.c:4:21: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'long long unsigned int' [-Wformat=]
[NativeLibs]      printf("size: %lu", sizeof(int));
[NativeLibs]                    ~~^   ~~~~~~~~~~~
[NativeLibs]                    %I64u
[NativeLibs] gcc: error: $@).a: No such file or directory
[NativeLibs] The spawned command 'gcc -shared -Wl,--out-implib,lib$(notdir $@).a  -O3 -DNDEBUG   -lshell32 -lws2_32 -lmswsock -lrpcrt4 -ladvapi32 -lpsapi -liphlpapi -luserenv -luser32 -o foo.dll foo.o' exited unsuccessfully (exit code: 1, signal: 0)
[NativeLibs]   in block <unit> at t/20-compile.t line 12
===> Testing [FAIL]: NativeLibs:ver<0.0.8>:auth<github:salortiz>
Aborting due to test failure: NativeLibs:ver<0.0.8>:auth<github:salortiz> (use --force-test to override)

Installation problem on Windows 10

Hello,
I encountered the followin problem:

C:\Users\bc>zef --debug install  "NativeLibs:ver<0.0.9>"
===> Searching for: NativeLibs:ver<0.0.9>
===> Found: NativeLibs:ver<0.0.9>:auth<github:salortiz> [via Zef::Repository::Ecosystems<rea>]
===> Fetching: NativeLibs:ver<0.0.9>
[NativeLibs] Fetching https://raw.githubusercontent.com/raku/REA/main/archive/N/NativeLibs/NativeLibs%3Aver%3C0.0.9%3E%3Aauth%3Cgithub%3Asalortiz%3E.tar.gz with plugin: Zef::Service::Shell::curl+{<anon|1>}
===> Fetching [OK]: NativeLibs:ver<0.0.9>:auth<github:salortiz> to C:\Users\bc\AppData\Local\Temp/.zef\1674398838.7840.2380.3565237259304\NativeLibs%3Aver%3C0.0.9%3E%3Aauth%3Cgithub%3Asalortiz%3E.tar.gz
===> Extracting: NativeLibs:ver<0.0.9>
[NativeLibs] Extracting with plugin: Zef::Service::Shell::tar+{<anon|1>}
===> Extraction [OK]: NativeLibs:ver<0.0.9> to C:\Users\bc\AppData\Local\Temp/.zef\NativeLibs%3Aver%3C0.0.9%3E%3Aauth%3Cgithub%3Asalortiz%3E.tar.gz
===> Filtering: NativeLibs:ver<0.0.9>:auth<github:salortiz>
===> Filtering [OK] for NativeLibs:ver<0.0.9>:auth<github:salortiz>
===> # SKIP: No need to build NativeLibs:ver<0.0.9>:auth<github:salortiz>
===> Testing: NativeLibs:ver<0.0.9>:auth<github:salortiz>
[NativeLibs] Testing with plugin: Zef::Service::TAP+{<anon|1>}
[NativeLibs] 1..23
[NativeLibs] ok 1 - NativeLibs:v<0.0.9> module can be use-d ok
[NativeLibs] ok 2 - Class Loader exists
[NativeLibs] ok 3 - Class Searcher exists
[NativeLibs] ok 4 - sub cannon-name exists
[NativeLibs] ok 5 - constant is-win exists
[NativeLibs] ok 6 - NativeCall loaded too
[NativeLibs] ok 7 - '&trait_mod:<is>' loaded too
[NativeLibs] ok 8 - 'ulonglong' loaded too
[NativeLibs] ok 9 - 'Pointer' loaded too
[NativeLibs] ok 10 - '&explicitly-manage' loaded too
[NativeLibs] ok 11 - '&cglobal' loaded too
[NativeLibs] ok 12 - 'bool' loaded too
[NativeLibs] ok 13 - 'CArray' loaded too
[NativeLibs] ok 14 - 'ulong' loaded too
[NativeLibs] ok 15 - 'void' loaded too
[NativeLibs] ok 16 - '&nativesizeof' loaded too
[NativeLibs] ok 17 - 'long' loaded too
[NativeLibs] ok 18 - 'size_t' loaded too
[NativeLibs] ok 19 - 'OpaquePointer' loaded too
[NativeLibs] ok 20 - '&refresh' loaded too
[NativeLibs] ok 21 - 'longlong' loaded too
[NativeLibs] ok 22 - '&guess_library_name' loaded too
[NativeLibs] ok 23 - '&nativecast' loaded too
[NativeLibs] t\01-basic.t ........ ok
[NativeLibs] 1..10
[NativeLibs] ok 1 - foo.dll
[NativeLibs] ok 2 - foo.dll
[NativeLibs] ok 3 - # SKIP <unknown>
[NativeLibs] ok 4 - # SKIP <unknown>
[NativeLibs] ok 5 - # SKIP <unknown>
[NativeLibs] ok 6 - # SKIP <unknown>
[NativeLibs] ok 7 - # SKIP <unknown>
[NativeLibs] ok 8 - # SKIP <unknown>
[NativeLibs] ok 9 - # SKIP <unknown>
[NativeLibs] ok 10 - # SKIP <unknown>
[NativeLibs] t\02-cannon-name.t .. ok
[NativeLibs] ok 1 - found kernel32.dll
[NativeLibs] ok 2 - Unversionized
[NativeLibs] ok 3 - Can be loaded
[NativeLibs] ok 4 - used
[NativeLibs] ok 5 - and disposed
[NativeLibs] ok 6 - The object does role 'Callable'
[NativeLibs] ok 7 - Closure can be called
[NativeLibs] ok 8 - Indeed mysql # TODO Can fail if the mysqlclient library isn't installed
[NativeLibs] 1..8
[NativeLibs] t\10-search.t ....... ok
[NativeLibs] 1..2
[NativeLibs] ok 1 - Can create compiler
[NativeLibs] t\20-compile.t ...... Dubious, test returned 255
[NativeLibs] All 2 subtests passed
[NativeLibs] All tests successful.
[NativeLibs]
[NativeLibs] Test Summary Report
[NativeLibs] -------------------
[NativeLibs] t\20-compile.t  (Wstat: 65280 Tests: 1 Failed: 0)
[NativeLibs] Non-zero exit status: 255
[NativeLibs]   Parse errors: Bad plan.  You planned 2 tests but ran 1.
[NativeLibs] Files=4, Tests=42,  3 wallclock secs
[NativeLibs] Result: FAILED
===> Testing [FAIL]: NativeLibs:ver<0.0.9>:auth<github:salortiz>
Aborting due to test failure: NativeLibs:ver<0.0.9>:auth<github:salortiz> (use --force-test to override)

Please "git tag" your RAKU modules with it's versions

Can you please "GIT TAG" your RAKU modules with it's version, similar and at the same time you maintain it's "version": "x.y.z" in your META6.json file?
I was told, this will happen "for free" going forward with mi6 anyhow, but for now it would be great if you spend those 2 seconds already now :)

"Tagging" is generally highly appreciated in regards to "reproducible builds" and here especially for the "Rakudo Star" modules

THANK YOU!

Impovement for Windows: Check that "cl.exe" exists

As a beginer,

  • I nnstall rakudostar
  • I try to upgrade the installation with zef
    -> I did have the issue ( #17 )

The error message was not clear to me! I suggest that you could improve it by

  • Checking that the "cl.exe" exist and if not explain what to do

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.