3 Replies Latest reply on Apr 14, 2020 5:07 AM by LePo_1062026

    How to make a static library file怎样生成静态库文件

    user_264721

      Hi CY Friend,

       

      自己工程里的算法不想给源码,怎样将.c .h生成一个静态库文件,请问CY 有文档吗?

       

      谢谢

      sophie

        • 2. Re: How to make a static library file怎样生成静态库文件
          user_264721

          Hi Len,

           

          If I need to use generated source code, what should I do ?

           

          Thanks

          sophie

          • 3. Re: How to make a static library file怎样生成静态库文件
            LePo_1062026

            sophie,

             

            The KBA listed earlier, has you place the library code in a Library project (.cylib).  Once you are happy with the code (it performs to your expectations) you compile the code under all the CPUs you wish to use the code.  For example the CortexM4, CortexM0+, etc.

            To do so, select the library project and then the Build Settings...

            Select the Processors:  then "Apply".  Remember, different PSoC might be using different CPUs.

             

            If you have any special Build options that need to be used, set them for each Processor and Build configuration (Debug or Release).

            Then "Apply" when you are all finished.

             

            You can now generate your library code for all Processors you selected.

            Change the Build configuration from "Debug" to "Release" (or visa versa) and rebuild.

             

            If no errors occur during the build, you will have directories with your object code (.o) files for each Processor selected:

                   

            and each Build configuration selected

                              

            Here is the output for each Processor/Build configuration.  The files with the .o are the ones desired for the library to be shared.

                                         

            Next you can create an archive of the Library to share with others.

            Select "Complete" before selecting "Archive".   Minimal will not include the directories where the .o files are compiled.

            It will create the library archive.  Note:  This archive will include the source code (.c) files.

             

            Lastly you want to remove the source code files from the archive.  To do so, go into the archive and delete all the files with .c extension.

            NOTE:  You must leave the .h files.   These files are needed by the user of the library to access the library functions, global variables and any #defines needed.

             

            I hope this helps.

             

            Len