Program Examples:Shared Objects
The following example demonstrates how to compile a shared object in Linux and link it with softMC at run time.
Attached are 3 example files: A C source file, a C header file and a makefile. The source and header files implement a simple program that is given 2 integers as arguments and returns their sum. This program DOESN'T include a main function, therefore the program can be compiled only into a library, and not an executable.
The compiler to be used in order to build the shared object is defined by the CC variable in the makefile. Please notice that it is assigned with a complete path to gcc compiler. This specific gcc is a part of the tool chain we use to build softMC.
When compiling shared objects to be linked with softMC it is advised to use this tool chain. You can download it from: --- LINK ... If you copy the tool chain to your user's directory, /home/my_user, you don't have to change anything in the makefile.
The program opens COM2 and waits for at least 3 bytes to arrive. Then it sends a message "done" and closes connection.
-->
-->?SHARED_OBJECT_SUM(5, 6)
11
-->
The example corresponds to commit SHA-1: ada143a7f402e6bbad24c13c56401a5393ce3d2b in GIT.