4 Replies Latest reply on Nov 3, 2016 4:52 PM by RichardAtwood

    How would i link new '.a' file?


      I have a '.a' file that I want to include in my project, how would i do that?

        • 1. Re: How would i link new '.a' file?

          Hi Mohit_07,


          I have some questions about this:


          • Do you have the header file (.h) and the source code of the library (.c)?
          • Are you using ISSM, right?


          To be honest, I'm not sure if it is possible to link an .a file using ISSM, because ISSM does all the compilation part. Normally when you use a library in your code you have to include the .h file (For example: #include "qm_gpio.h").


          So, I think it will be easier if you have the .c and .h files.


          I will be waiting for your reply.




          • 2. Re: How would i link new '.a' file?

            Hi Leonardo,


            I do have the .h file but no .c file. I also am using ISSM.

            In ISSM, app.mk file has a linker function and I was looking at that to see how it links all of the libqmsi together.

            • 3. Re: How would i link new '.a' file?

              Hi Mohit_07,


              Let me investigate more about it, I will let you know when I have updates.




              • 4. Re: How would i link new '.a' file?

                ISSM does support linking .a files. 


                For example the Accelerometer samples uses IPP which is provided as a “.a” file called: libippsq.a


                Then in that project’s top level Makefile we have these lines:

                CFLAGS += -I$(IPP_LIBRARY_PATH)/include -D__IPP_ENABLED__=1

                LDLIBS += -L$(IPP_LIBRARY_PATH)/lib -lippsq


                We define the IPP_LIBRARY_PATH elsewhere but you would likely want to provide your library path here directly.  The CFLAGs command tells the compiler to include the .h files in that location.  We can ignore the –D, it’s not need for the users question.  The LDLIBS command then links the library, the “.a” file, into the project and it needs 2 things.  “-L<path_to_library>” and “-l<library_name>”.  Another thing note is that it's standard to start your file name with "lib" when using it like this, I don't know if it's required, but it's a good practice to avoid confusion.  


                Thank you,