8 Replies Latest reply on Oct 17, 2020 10:36 AM by ArLe_3696811

    cannot attached a only Code library to a project

    ArLe_3696811

      Hi

       

      I am using creator version 3.3 and pSoC 5

      In my project I have a folder with two files C and H and they have some functionality we need for many project.

      So far we were coping those file to each project separately. (the files are compile OK in the project)

       

      We decided to create a code library that can be linked and share among the project

      I have created a Code library project with this two files and gave it a name.

      Let say that the library name creates is "MyLib.a" and the H file is "MyFile.h" and also I Have "MyFile.c".

       

      The library project compile OK and created the Library "MyLib.a" .

       

      Now I went to any project I have that uses those files embeded in my code and removed the code from it. Assuming now i can add the library and the include the h file and all will be fine.

      First I added the Library in the linked in the library path and library name using the browse option we have in the IDE

      The H file have been assign in the project include folder and added to the project

      When I complied it the it complain that he cannot fie the file "MyLib.a" where for sure it exist and i have set the right path for it

      I also try to add it as dependencies and any information I found in.

      I am familiar with adding library in different type of high language and here I failed.

      I tried to search the forum before putting my case here and didn't find any found some and followed them instruction but one works.

      I tried also to copy this library file "MyLib.a" to my project folder but it didn't worked.

       

      Please help is required on that issue and i am sure that someone came across it and have a solution

       

      Regards and Thx

      Arie

        • 1. Re: cannot attached a only Code library to a project
          BoTa_264741

          ArLe,

          One way to do this is to create a custom component, and add it to the dependencies list. Then all you need is to add it to the dependencies (Project-> Dependencies -> Add..) and drop component to the schematic. You can find an examples of such "pure API" components here:

          SerialPlot: interface to real-time data charts

          MedianFilter: sliding window median filter component

          Fast Thermistor Calculator

           

          This is probably not what you mentioned above, but I find it convenient.

          /odissey1

          • 2. Re: cannot attached a only Code library to a project
            LePo_1062026

            ArLe,

             

            /odissey1 is correct.

             

            Maybe the attached document may help.

             

            Len

            1 of 1 people found this helpful
            • 3. Re: cannot attached a only Code library to a project
              ArLe_3696811

              Hi

               

              Thanks for your help but i am using PSoC Creator version 3.3 and cannot load the project its probably build with later version

              What i Need is a very simple :

              I have written some function to access a Nextion HMI Screen (its a touch screen that has an API - simple one). it is not so important

              I will show you one functoion in my C file and a declaration in my H file and if you can point me how to do it as in your sample seriallib

               

              I will list only one function to ease the explanation and if help will be given on only this function will be more then fine.

               

               

              .c file name "HMIControls.c"

              and one of the functoin is :

              void HMI_SetIntegerControlValue(char* pageName, char* objectName, int value, char* pcBuf)

              {

                  char carValue[20];

                 

                  itoa(value, carValue, 10);

                     

                  if (pageName != NULL)

                  {

                      sprintf(pcBuf, "%s.%s.val=%s%c%c%c", pageName, objectName, carValue, HMI_END_COMMAND, HMI_END_COMMAND, HMI_END_COMMAND) ;

                  }

                  else

                  {

                      sprintf(pcBuf, "%s.val=%s%c%c%c", objectName, carValue, HMI_END_COMMAND, HMI_END_COMMAND, HMI_END_COMMAND) ;

                  }

                  HMI_SendData(pcBuf) ;

              }

               

              and in the .h file name "HMIControls.h" i have the prototype declaration of that function

               

              void HMI_SetIntegerControlValue(char* pageName, char* objectName, int value, char* pcBuf);

               

              Now what i need is how to create an empty custom component code only that i can create a library on the above function and then linked it to any project using Nextion screen that required those functionalities.

               

              Thanks in advance

              Arie

              • 4. Re: cannot attached a only Code library to a project
                LePo_1062026

                Arie,

                 

                I guess I'm having difficulty understanding what you are trying to do.  So I have some questions:

                 

                We decided to create a code library that can be linked and share among the project

                I have created a Code library project with this two files and gave it a name.

                Let say that the library name creates is "MyLib.a" and the H file is "MyFile.h" and also I Have "MyFile.c".

                 

                The library project compile OK and created the Library "MyLib.a" .

                The library called "MyLib.a" as actually called "MyLib.a.cylib"?

                 

                Now I went to any project I have that uses those files embeded in my code and removed the code from it. Assuming now i can add the library and the include the h file and all will be fine.

                Yes.  Once you compile the code, you can remove the .c file.   However you need to compile the code for the CPU types you plan to support.

                Try this link:  Creating a Library Project as an Object Code – KBA90606

                 

                Is there a reason you are using Creator 3.3?   Creator is currently at 4.3.

                 

                Len

                • 5. Re: cannot attached a only Code library to a project
                  BoTa_264741

                  ArLe,,

                  When adding your custom library to the project did you follow the steps described in this KBA?

                  Adding .a Library File to PSoC Creator Project Using GCC Toolchain – KBA227572

                  /odissey1

                  2 of 2 people found this helpful
                  • 6. Re: cannot attached a only Code library to a project
                    ArLe_3696811

                    Hi BoTa_264741

                     

                    Your link does the job

                    To be honest i saw it and followed the instruction and i missed the CPU type. After following carefully on what said in the link it all works OK

                     

                    One small issue i figure in another library i have created.

                    One of my function required the use of pow function so, I have used #inclue <math.h> file and compile the lib OK.

                    Note : If i removed the #include <math.h> it didn't compile. so the #include <math.h> is a must for that library to compile.

                     

                    So after creating the new lib.

                    I opened my project that required this new library functionality and made a dependency on the new lib and compile the project. the compiler complains that there is no reference to "pow" function, do you any any clue why it complains on it?

                    I get around this error compilation by replacing the value that pow calculates with a fixed known number and the project compile and run prefect.

                     

                    Thanks again

                    Arie

                    • 7. Re: cannot attached a only Code library to a project
                      BoTa_264741

                      ArLe,

                      I believe that the compiler also needs to be notified about using the math library. Somewhere in the Project-> Build settings -> Compiler -> Additional libraries add "m" (math library).

                      /odissey1

                      1 of 1 people found this helpful
                      • 8. Re: cannot attached a only Code library to a project
                        ArLe_3696811

                        Many Thanks It works OK