Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BSEC Shared Library for Linux x64

    BSEC Shared Library for Linux x64

    olsen
    Member

    We are developing an application that is responsible for collecting data from thousands of different remote sensors, including BME680 and BME688, using a .Net C# application running on Ubuntu 22.04 on Intel x64 hardware.

    We have created managed to create a prototype under Windows 10, where we managed to connect to multiple BME680 sensors and integrated BSEC 2.4.0.0 multi-instance version using P/Invoke.

    The integration code looks like this:

    private const string BsecLibraryName = "BSECLibrary64.dll";
    
    [DllImport(BsecLibraryName, EntryPoint = "bsec_init_m", CallingConvention = CallingConvention.Cdecl)]    
    private static extern int bsec_init_m(IntPtr bsec_instance);
    
    [DllImport(BsecLibraryName, EntryPoint = "bsec_do_steps_m", CallingConvention = CallingConvention.Cdecl)]
    private static extern int bsec_do_steps_m(IntPtr bsec_instance,
                                            [In] BSEC_input_struct[] inputs,
                                            byte number_inputs,
                                            [Out] BSEC_output_struct[] outputs,
                                            [In, Out] ref byte number_outputs);
    // and so on ...


    However, we are facing an issue when porting the code from windows to linux. The problem is that for windows there is a dynamic library (.dll), while there is no shared library (.so) available for linux. All we can find for linux is BSEC2.4.0.0_Generic_Release_23012023/algo/normal_version/bin/gcc/Linux/m64/libalgobsec.a, which is a static library and for .Net P/Invoke to work it reqires the DllImport to point to a dynamic library (a.k.a .so in linux).

    We have tried to create an .so in multiple ways so far, but we are always facing different issues. For example:

    $ gcc -shared -o BSECLibrary64.so test.c bin/gcc/Linux/m64/libalgobsec.a
    /usr/bin/ld: bin/gcc/Linux/m64/libalgobsec.a(ChannelHub.o): warning: relocation against `uv' in read-only section `.text'
    /usr/bin/ld: bin/gcc/Linux/m64/libalgobsec.a(bsec_codegen_do_steps.o): relocation R_X86_64_PC32 against symbol `uv2' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: final link failed: bad value
    collect2: error: ld returned 1 exit status

    We are uncertain if getting a libalgobsec.a compiled with -fPIC would be enough to create a shared object. 

    Can anyone help us obtain a working shared library of BSEC for linux ?

     

    P.S. the content of the test.c is not relevant at the moment and was just used to force the libalgobsec.a to be included in the shared library:

    #include "inc/bsec_interface.h"
    #include "inc/bsec_interface_multi.h"
    
    void test()
    {
        bsec_init();
        bsec_init_m(NULL);
    }

     

    8 REPLIES 8

    Hello @BSTRobin ,

    Is there any progress? Will you be able to build libalgobsec.a with -fPIC?

     

    BSTRobin
    Community Moderator
    Community Moderator

    Hi olsen,

    Sorry for the delay reply.

    After our internal discussion, current BSEC release package didn't contain the libalgobsec.a with -fPIC under ubuntu system you requested.
    If you design a project with BME68x and request the library, could you provide your email address? Then we will contact with you.

    Hi BSTRobin,

    I do have the same problem too. I was trying to compile the libalgobsec.a into my library as shared library but failed. I had privately message you. Looking forward for your fast response. Thanks.

    I would also like package with compiled with -fPIC. would that be possible? we would like to update to the latest version.

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist