[Gambas-user] Working with .so library

Admin admin at ...3661...
Thu Jun 1 11:25:07 CEST 2017


31.05.2017 19:50, Benoît Minisini пишет:
> Le 31/05/2017 à 14:36, Admin a écrit :
>> 31.05.2017 18:18, Benoît Minisini пишет:
>>> Le 31/05/2017 à 12:38, Admin a écrit :
>>>> 31.05.2017 16:58, Benoît Minisini пишет:
>>>>> Apparently all that black box is written in C++ with QT, and 
>>>>> without the header of the library interface , I can't tell you if 
>>>>> it is possible to use the library with Gambas, and how.
>>>>>
>>>>> Regards,
>>>>>
>>>> I was lucky enough to find the header file shared by developers and 
>>>> an example program in C++ that utilizes this lib.
>>>>
>>>> Here they are: http://allunix.ru/back/atol-header.tar.gz
>>>>
>>>
>>> Maybe CreateFptrInterface() is a C++ only thing, and that you must 
>>> call another function from the C interface to do something similar. 
>>> But I couldn't find it reading the C header.
>>>
>>> You need the documentation of the C interface, or at least an 
>>> example written in C to know. You usually can't use C++ exported 
>>> functions from Gambas.
>>>
>>> Regards,
>>>
>> Maybe it is. One of the authors of the original .so library stated on 
>> one forum:
>>
>> "You can use purely C interface like this:
>>
>> void *fptr = CreateFptrInterface();
>> put_DeviceSingleSetting(fptr, L"Port", "4");
>> ApplySingleSettings(fptr);
>>
>> "
>>
>> but I can't see the difference.
>>
>>
>> Dmitry.
>>
>
> Then it should work the way you did. But you did not respect the 
> interface of put_DeviceSingleSettingAsInt(). It wants a "wchar_t *", 
> whereas the Gambas strings are encoded in ASCII or UTF-8.
>
> You must first convert the Gambas string to wchar_t by using 
> Conv$(<string>, "UTF-8", "WCHAR_T") or Conv$(<string>, "ASCII", 
> "WCHAR_T").
>
> Regards,
>
Oh. My. God. That's exactly what I needed.

Actually, I saw that the library expetcs a variable in wchar_t format, I 
had no idea what it was, so I googled "gambas wchar_t" and found 
absolutely nothing. Then I wrote my first letter to this maillist.

And now when you gave me this line of the code, the library works 
exactly the way it should, doing everything I'm asking it for.

Huge thank you!

Dmitry/





More information about the User mailing list