Jump to content
OMRON Forums

Creating a User C Library

Omron Forums Support

Recommended Posts

This is a post on how to create a C Library common to all background programs (i.e. a library whose functions all background C programs can use) in case some of you do not yet know how to do that. Note that for the time being, the library can not be used by CPLCs, only background programs. In the future (in the December release of the IDE, hopefully) CPLCs will be able to link to the libraries.


First, in the Solution Explorer of your project in the IDE, right click "Libraries", then "Add a new C Library Project". Name your project whatever you want, e.g., MyLibrary:




This will automatically create a source file in that folder of the same name but all lower-case, e.g., mylibrary.c. Now right click on the folder (e.g. MyLibrary) and click "Add New Item":




Click "Background C Header" and name it the same thing as your source file, but with a ".h" extension instead of ".c":




Put all the functions you want to be in your library into the ".c" source code file, and then make sure you copy prototypes of those functions into the ".h" header file.


Now in your Background C Program, you can just add this line to include your header file (using the MyLibrary example):


#include "../../Libraries/MyLibrary/mylibrary.h"


Attached is an example project that has one function (a simple function that just increments a variable whose address is passed to it) in the mylibrary.c source code, the prototype of that function in the mylibrary.h header file, and a Background C Program (capp1.c) that includes the mylibrary.h header file and uses the function.


If you have any questions about this, please feel free to post them.


Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

This topic is now closed to further replies.

  • Create New...