This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Link static library to Segger IDE

Hello. I compiled with gcc a static library which consists nrf hardware drivers . Now other person from project want to use it in SEGGER IDE as it is now supported by nordic. Should there be any problem with that ? I know segger is using gcc underneath so there souldnt be any problem right ? But for now when linking, segger says he cannot find functions from .a library.

Also I reused linker script from SDK, how the segger user import that linker script into the project?

  • Hi,

    I compiled with gcc a static library which consists nrf hardware drivers . Now other person from project want to use it in SEGGER IDE as it is now supported by nordic. Should there be any problem with that ? I know segger is using gcc underneath so there souldnt be any problem right ?

    How did you add the library?

    You can add it directly to the project, like adding a .c file (this is done in the DFU project for SES in SDK v14.2), or you can do a "normal" gcc approach by adding a -L path to ld, and pass -lmylibrary to ld.

     

    Also I reused linker script from SDK, how the segger user import that linker script into the project?

    Did you reuse a flash_placement.xml file (which is converted to a .ld script under-the-hood) or did you explicitly re-use a .ld script?

    You can choose to either use a .xml parser for linking, or set a .ld script (I haven't tested using a .ld script, so I guess you might run into other issues)

    I'd recommend taking a flash_placement.xml from a similar style project to ensure that you get all user sections correct.

     

    Could you post your build log?

     

    Cheers,

    Håkon

     

  • Thank you.

    For compiling library I used Makefile from sdk. I compiled all files to build sample app, then excluded main.o and build the library from other files. For my example I took a .ld file as is from a sdk examples and then added needed sections. My example is working when I compile with gcc using modified Makefile from SDK. Now I want to use this library in Segger IDE but I know I need to update linker script. Here I understand I need to either modify flash_placement.xml or try manual linker script option. 

    The library file was added like any .c file. Is there anything else needed to get the library to be compiled with all project? I will give you exact logs later but it was complaining about undefined reference to the API functions.

    Can you please confirm that what I did, so compiling a static library under gcc with makefile rules taken from sdk and then using it in segger is fine?

    Regards

  • Hi,

     

    I'd recommend that you use a flash_placement.xml file from a SDK example similar to yours. If you use BLE, use one of the ble_app_* example's flash_placement.xml.

    Is there anything else needed to get the library to be compiled with all project?

    Hard to say without having a build output, but generally; adding the library and the (optional) API includes to it should be fine.


    Can you please confirm that what I did, so compiling a static library under gcc with makefile rules taken from sdk and then using it in segger is fine?

    Yes, you can compile in GCC, and use this library in Segger Embedded Studio.

     

    Best regards,

    Håkon

     

Related