Working on exercise 3-5 but I'm creating some libraries
This commit is contained in:
Executable
+16
@@ -0,0 +1,16 @@
|
||||
if [ ! -d "bin" ]; then
|
||||
mkdir bin
|
||||
echo "created bin directory"
|
||||
fi
|
||||
|
||||
if [ ! -d "bin/static" ]; then
|
||||
mkdir bin/static
|
||||
echo "created bin/static directory"
|
||||
fi
|
||||
|
||||
gcc -c src/test.c -Iinclude -o bin/static/test.o
|
||||
|
||||
# gcc -fPIC src/test.c -Iinclude -o bin/shared/test.o
|
||||
|
||||
ar rcs bin/static/libtestlibrary.a bin/static/test.o
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#include <stdio.h>
|
||||
|
||||
// Returns a test value
|
||||
int TestLibrary_test_value();
|
||||
|
||||
// Multiplies the value by 1.5
|
||||
double TestLibrary_multiply_by_one_point_five(const double value);
|
||||
|
||||
|
||||
void __attribute__((constructor)) initLibrary(void);
|
||||
|
||||
void __attribute__((destructor)) cleanUpLibrary(void);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
|
||||
// #include "../include/test.h"
|
||||
#include "test.h"
|
||||
|
||||
int TestLibrary_test_value()
|
||||
{
|
||||
return 48;
|
||||
}
|
||||
|
||||
|
||||
double TestLibrary_multiply_by_one_point_five(const double value)
|
||||
{
|
||||
return value * 1.5;
|
||||
}
|
||||
|
||||
|
||||
void __attribute__((constructor)) initLibrary(void)
|
||||
{
|
||||
printf("TestLibrary Initialized\n");
|
||||
}
|
||||
|
||||
void __attribute__((destructor)) cleanUpLibrary(void)
|
||||
{
|
||||
printf("TestLibrary is exiting\n");
|
||||
}
|
||||
Reference in New Issue
Block a user