[Gambas-user] external functions and structs
T Lee Davidson
t.lee.davidson at gmail.com
Wed Nov 28 17:49:44 CET 2018
When I try to run your code, I get:
Cannot find dynamic library 'libais.so.1.9.so': libais.so.1.9.so: cannot open shared object file: No such file or directory in
Main:61.
In addition to your:
Library "libais.so.1.9"
I tried:
Library "./libais.so.1.9"
Library "../libais.so.1.9"
No love. I don't know why Gambas is changing the name I specified.
___
Lee
On 11/28/18 7:39 AM, gen braga wrote:
> Hi there,
>
> I'm trying to use a method from an external library whose signature is as follow
>
> int __stdcall assemble_vdm( ais_state *state, char *str )
>
> ais_state is:
>
> #define SIXBIT_LEN 255
>
> typedef struct {
> unsigned char msgid; //!< Message ID 0-31
> unsigned int sequence; //!< VDM message sequence number
> unsigned int total; //!< Total # of parts for the message
> unsigned int num; //!< Number of the last part stored
> char channel; //!< AIS Channel character
> sixbit six_state; //!< sixbit parser state
> } ais_state;
>
> six_state is:
>
> typedef struct {
> char bits[SIXBIT_LEN]; //!< raw 6-bit ASCII data string
> char *p; //!< pointer to current character in bits
> unsigned char remainder; //!< Remainder bits
> unsigned char remainder_bits; //!< Number of remainder bits
> } sixbit;
>
> I declared them all as follow:
>
> Public Struct sixbit
> bits[255] As Byte 'raw 6 - bit ASCII data string --> era [SIXBIT_LEN - 1]
> p As String 'pointer To current character In bits
> remainder As Byte 'Remainder bits
> remainder_bits As Byte 'Number Of remainder bits
> End Struct
>
> Public Struct AIS_State
> msgid As Byte 'Message ID 0 - 31
> sequence As Short 'era DWORD; / / ! < VDM message sequence number
> total As Short 'era DWORD; / / ! < Total # Of parts For the message
> num As Short 'era DWORD; / / ! < Number Of the Last part stored
> channel As Byte ': Char; / / ! < AIS Channel character
> six_state As SixBit '; / / ! < sixbit parser state
> End Struct
>
> Private Extern assemble_vdm(state As AIS_State, str1 As String) As Integer
>
> Ok....
> In my Main method I call the assemble_vdm function and the result is as expected, returning an integer between 0 and 5 meaning
> what's going on, I can confirm it by changing the second parameter's contents. But that method, modifies the first parameter
> (state) internally, and I should use it afterwards to decide what do to, reading state.msgid
>
> The fact is, when I read it, its empty and rises segfault.... Does anyone knows how to deal with it?
>
> The library's sources are at https://github.com/bcl/aisparser/tree/master/c
>
> Attached are my sources.
>
> Greetings,
>
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
More information about the User
mailing list