Skip to content

Commit

Permalink
Compile cbrain as a shared library
Browse files Browse the repository at this point in the history
  • Loading branch information
Auxilus committed Jul 17, 2019
1 parent 7ae73dc commit 9f08720
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 18 deletions.
13 changes: 6 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
C_SOURCES = $(wildcard src/*.c)
HEADERS = $(wildcard src/*.h)
HEADERS += $(wildcard src/models/*.h)
OBJ = ${C_SOURCES:.c=.o}
CFLAGS = -Wall
CC=gcc

all: cbrain
all: libcbrain.so

%.o: %.c
$(CC) -c $< -o $@ $(CFLAGS)
$(CC) -c $< -o $@ $(CFLAGS) -fPIC

cbrain: ${OBJ}
$(CC) $^ -o $@ -lpthread $(CFLAGS)
strip -S --strip-unneeded --remove-section=.note.gnu.gold-version --remove-section=.comment --remove-section=.note --remove-section=.note.gnu.build-id --remove-section=.note.ABI-tag $@
libcbrain.so: ${OBJ}
$(CC) -shared -o $@ -lpthread $(CFLAGS) $^

clean:
rm cbrain
rm src/*.o
rm libcbrain.so

7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ Simple implementation of neural structure in c.

<code>git clone https://github.com/Auxilus/cbrain</code>

the main() lies in src/cbrain.c
make your changes to main()

<code>make</code>

<code>./cbrain <number_of_neurons></code>

This will generate shared object **libcbrain.so**
You need to copy **libcbrain.so** and **src/cbrain.h** over to lib and include dirs

All the bugs and PRs are welcome!
4 changes: 2 additions & 2 deletions src/cbrain.c → examples/cbrain.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "header.h"
#include <cbrain.h>

int main(int argc, char* argv[])
{
Expand All @@ -16,7 +16,7 @@ int main(int argc, char* argv[])
uint sleep_t;
sleep_t = (argc < 3) ? SLEEP_T : strtof(argv[2], NULL);

struct brain* b = parse_model_csv("src/models/conn.txt");
struct brain* b = parse_model_csv("models/conn.txt");

//struct brain* b = brain_init((uint)neurons_no);
//neuron_link_random(b);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/brain.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#include "header.h"
#include "cbrain.h"

/* Initialize new neuron */
struct neuron* neuron_init(uint id)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/jar.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "header.h"
#include "cbrain.h"

struct jar* jar_init(int b_count)
{
Expand Down
2 changes: 1 addition & 1 deletion src/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#include "header.h"
#include "cbrain.h"

struct thread_args {
uint s;
Expand Down
2 changes: 1 addition & 1 deletion src/util.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "header.h"
#include "cbrain.h"
#include <stdarg.h>

int rand_int(int x, int y)
Expand Down

0 comments on commit 9f08720

Please sign in to comment.