!--main.c file
#define EXPORT __attribute__((visibility("default")))
__attribute__((constructor))
static void initializer(void)
{
printf("%s",__FILE__);
}
__attribute__((destructor))
static void finalizer(void)
{
printf("%s",__FILE__);
}
EXPORT
void shownow (void) {
// insert code here...
printf("Hello, World!\n");
}
Use EXPORT before any funtion that you would like to export in dylib file. After you have written the file. You can create a dylib in terminal by typing the command below.
Locate the main.c file and type
gcc -dynamiclib -std=gnu99 "FileName" -current_version 1.0 -compatibility_version 1.0 -fvisibility=hidden -o "LibFileName"
Example:
No comments:
Post a Comment