Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CFFI mailing list

61 views
Skip to first unread message

Marco Antoniotti

unread,
Jun 13, 2016, 1:03:33 PM6/13/16
to
Hi

I am trying to get to the CFFI mailing list (devel), but, somehow, the gmane NNTP server seems uncooperative. Any ideas?

In any case, I have the following problem.

This is in my "test" file:


(cffi:define-foreign-library cl-autowrap-tests-lib
(t "cl-autowrap-test.a"))


This is what I get on LWM.

CL-USER 15 > (cffi:load-foreign-library 'cl-autowrap-tests::cl-autowrap-tests-lib)

Error: Unable to load foreign library (CL-AUTOWRAP-TESTS-LIB).
Could not register handle for external module CL-AUTOWRAP-TESTS::CL-AUTOWRAP-TESTS-LIB:
no suitable image found. Did find:
/Users/marcoxa/Projects/Lang/CL/tests/cl-autowrap/cl-autowrap-test.a: file too short.
1 (continue) Try loading the foreign library again.
2 Use another library instead.
3 (abort) Return to level 0.
4 Return to top loop level 0.

Type :b for backtrace or :c <option number> to proceed.
Type :bug-form "<subject>" for a bug report template or :? for other options.


It obviously appears that something may be amiss with the .a (static) generation. My C/C++ fu us very rusty.

Any ideas?

Cheers
--
MA

Frank DG1SBG

unread,
Jun 29, 2016, 8:16:53 AM6/29/16
to
Marco Antoniotti <mar...@gmail.com> writes:

> Hi
>
[snip]
>
> (cffi:define-foreign-library cl-autowrap-tests-lib
> (t "cl-autowrap-test.a"))
>
>
> This is what I get on LWM.
>
> CL-USER 15 > (cffi:load-foreign-library 'cl-autowrap-tests::cl-autowrap-tests-lib)
>
> Error: Unable to load foreign library (CL-AUTOWRAP-TESTS-LIB).
> Could not register handle for external module CL-AUTOWRAP-TESTS::CL-AUTOWRAP-TESTS-LIB:
> no suitable image found. Did find:
> /Users/marcoxa/Projects/Lang/CL/tests/cl-autowrap/cl-autowrap-test.a: file too short.

[snip]

> Any ideas?

Yes. You cannot load a .a (static) library with CFFI. CFFI goes through
the _dynamic_ loader (dlopen() syscall on linux and macOS). You need to
bring in the .a lib at link time to a C++ exe. Or, in other words, if
you are in Lisp only, the you can't load the .a lib.

Not what you wanted to hear/read, I can imagine, but ... If you really,
really need to have the static lib you might want to load Lisp as a
dynamic lib into a manually set-up C/C++ exe - you then can link the
static lib to the exe and use CFFI to define the foreign function
calls.... Yes, clumsy.

Frank

Marco Antoniotti

unread,
Jul 1, 2016, 8:18:59 AM7/1/16
to
Thanks. I did solve my problems meanwhile. The static vs dynamic issue was just a minor glitch. The real issues I had were with the cl-autowrap set up.

Cheers
--
MA
0 new messages