how to include a libray (.a) file into a project on RT1024

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to include a libray (.a) file into a project on RT1024

Jump to solution
3,746 Views
ping1
Contributor V

Hi, All

I am using MCUXpresso IDE, and need to include a precompiled library  file (*.a) into my project, wonder where I should put it and how to link it ? I have header files, but not compiling at the moment.

Regards!

Ping

Labels (1)
0 Kudos
1 Solution
3,612 Views
kerryzhou
NXP TechSupport
NXP TechSupport

From the log, it use the VFP register, seems not used for RT.

 

Best Regards,

Kerry

View solution in original post

0 Kudos
19 Replies
3,630 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @ping1 ,

    So strange, I just open your project, with no modification, build works Ok, totally no error, and map also see your lib.

1.jpg

My SDK is SDK2.10.0, IDE is MCUXpresso IDE v11.3.1 [Build 5262] [2021-04-02].

I think you also can close the IDE, delete all your workspace, then import your project and build again.

 

Best Regards,

Kerry

 

0 Kudos
3,624 Views
ping1
Contributor V

Dear Kerry,

Yes, you are right, it will compile as it is as I want to show you my project compiles without calling library. 

Did you try to modify the zmod.c file at line 110, ret =init_iaq_2nd_gen(&algo_handle); and it still compiles? that is my problem - the function calls the library, it doesn't compile for me.

I just updated my IDE to v11.4.0, and SDK v2.10.0.

Regards!

Ping

0 Kudos
3,619 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @ping1 ,

   Seems your lib have issues, do you generate it with mcuxpresso?

kerryzhou_0-1628756731533.png

Seem your lib code has the mcuxpresso calling issues, do you test your related code without the lib, I mean, add your lib source code to this project, whether it has issues or not?

Best Regards,

Kerry

 

0 Kudos
3,615 Views
ping1
Contributor V

Dear Kerry

That is quick response, thanks!

The library is provided by third party, unfortunately, no source code available.

What does the error message mean? so I can tell the library provider.

Regards!

Ping

 

0 Kudos
3,613 Views
kerryzhou
NXP TechSupport
NXP TechSupport

From the log, it use the VFP register, seems not used for RT.

 

Best Regards,

Kerry

0 Kudos
3,607 Views
ping1
Contributor V

Hi, Kerry

Thanks for your patient support, the RT has hardware float pointer function and had to use another library built for the platform - it compiles now.

Regards!

Ping

 

0 Kudos
3,699 Views
crist_xu
NXP Employee
NXP Employee

hi,

   Please try lib_iaq_2nd_gen in your mcuxpresso link option, instead of lib_iaq_2nd_gen.a

 

Regards,

    Crist

3,622 Views
ping1
Contributor V

Thanks, Crist

I tried and added like _iaq_2nd_gen, the full name of the library is lib_iaq_2nd_gen.a, no luck so far.

Regards!

Ping

0 Kudos
3,714 Views
ping1
Contributor V

Thanks for this, read and tried to put it into Project->Properties->Tool Settings Tab->C++ Linker->Miscellaneous, seems compiled, but when calling the function in it, it says "undefined reference to function ".

Regards!

Ping

0 Kudos
3,704 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @ping1 

Do you add the related header file in your code?

You can refer to my above examples at first, that code add the .a works OK.

 

Best Regards,

Kerry

0 Kudos
3,731 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @ping1 

You can add the .a like this:

kerryzhou_0-1628490036580.png

 

Best Regards,

Kerry

 

0 Kudos
3,722 Views
ping1
Contributor V

Thanks for reply, Kerry

I tried and it doesn't work for me, I created a folder called Lib under same directory as workspace, but it doesn't show on my workspace like yours, because it is just a folder, not a workspace project, the library is a precompiled .a file.

I set it like below, and got an error message when compiling - like  "cannot find -llib_iaq_2nd_gen.a"

ping1_0-1628512376725.png

Can I put it into a fixed location under project folder? do i have to import the file into my workspace?

Regards!

Ping

0 Kudos
3,708 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @ping1 ,

  Give you an example, please open this path:

C:\nxp\MCUXpressoIDE_11.4.0_6157_prc1\ide\Examples\Flashdrivers\NXP\iMXRT

copy the iMXRT1020_QSPI.zip out, then unzip it, then import two project to your mcuxpresso.

You can find two project, one is LPCXFlashDriverlib, another is iMXRT1020_QSPI, LPCXFlashDriverlib will generate the lib .a file, then the iMXRT1020_QSPI will call the lib, you can refer to that project.

 

Best Regards,

Kerry

0 Kudos
3,665 Views
ping1
Contributor V

Dear kerry

Thanks for reply, the example seem working, but my application is different, I have precompiled library file, I created a C/C++ static library project and copy my library file under the lib folder there as you can see.

setting in my application project:

ping1_1-1628609236804.png

 

I tried to compile and here is the error message:

ping1_0-1628609098482.png

Could you let me know the meaning of the message?

Regards!

Ping

 

0 Kudos
3,656 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @ping1 

One important things I don't whether you not it or not:

MCUXpresso IDE requires to have static library name in format "liblibrary_name.a".

kerryzhou_0-1628656207392.png

So, please make sure your generated lib name with : libxxxLib.a, then in the MCUXPresso settings, just xxxLib

Please try it again.

Best Regards,

Kerry

 

 

 

0 Kudos
3,648 Views
ping1
Contributor V

Hi, Kerry

Thanks for your patient.

The 3rd party static library is coming named as lib_iaq_2nd_gen.a. I don't need to compile it although I tried to created a project for it, but then I just copied the folder it under a folder called <Lib> as showing in my screen shot.

In project setting, I put it like below:

ping1_0-1628667606083.png

The error message like below - there are 3 of them:

"error: WellSensor.axf uses VFP register arguments, D:/WORK/Products/POE_WellBeing/Firmware/MIMXRT1024_APP/lib/lib_iaq_2nd_gen.a(iaq_2nd_gen.c.o) does not

failed to merge target specific data of file D:/WORK/Products/POE_WellBeing/Firmware/MIMXRT1024_APP/lib/lib_iaq_2nd_gen.a(iaq_2nd_gen.c.o)"

It seems read the library as lib_iaq_2nd_gen.a correctly and found it, just doesn't compile, does it mean the library is not compatible with the processor?

Regards!

Ping

 

0 Kudos
3,641 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @ping1 ,

   To test the code, please share your issue project, please make sure your project has no build issues before you add the .a, after you attach the project, I will help you to check it.

 

best regards,

KERRY

0 Kudos
3,637 Views
ping1
Contributor V

Dear Kerry

It is attached for check please. It compiles now.

The file calls library is zmod.c, line 110 - init_iaq_2nd_gen(),  if you comment the line in, it won't compile and show error messages. The library is under the <Lib> folder, both header file and .a file.

Regards!

Ping

 

0 Kudos
3,739 Views
bp1979
Senior Contributor I
0 Kudos