Skip to content

Commit 9f08720

Browse files
committed
Compile cbrain as a shared library
1 parent 7ae73dc commit 9f08720

File tree

11 files changed

+14
-18
lines changed

11 files changed

+14
-18
lines changed

Makefile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
C_SOURCES = $(wildcard src/*.c)
22
HEADERS = $(wildcard src/*.h)
3-
HEADERS += $(wildcard src/models/*.h)
43
OBJ = ${C_SOURCES:.c=.o}
54
CFLAGS = -Wall
65
CC=gcc
76

8-
all: cbrain
7+
all: libcbrain.so
98

109
%.o: %.c
11-
$(CC) -c $< -o $@ $(CFLAGS)
10+
$(CC) -c $< -o $@ $(CFLAGS) -fPIC
1211

13-
cbrain: ${OBJ}
14-
$(CC) $^ -o $@ -lpthread $(CFLAGS)
15-
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 $@
12+
libcbrain.so: ${OBJ}
13+
$(CC) -shared -o $@ -lpthread $(CFLAGS) $^
1614

1715
clean:
18-
rm cbrain
1916
rm src/*.o
17+
rm libcbrain.so
18+

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ Simple implementation of neural structure in c.
55

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

8-
the main() lies in src/cbrain.c
9-
make your changes to main()
10-
118
<code>make</code>
129

13-
<code>./cbrain <number_of_neurons></code>
14-
10+
This will generate shared object **libcbrain.so**
11+
You need to copy **libcbrain.so** and **src/cbrain.h** over to lib and include dirs
1512

1613
All the bugs and PRs are welcome!

src/cbrain.c renamed to examples/cbrain.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "header.h"
1+
#include <cbrain.h>
22

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

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

2121
//struct brain* b = brain_init((uint)neurons_no);
2222
//neuron_link_random(b);
File renamed without changes.
File renamed without changes.

src/brain.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
SOFTWARE.
2121
*/
2222

23-
#include "header.h"
23+
#include "cbrain.h"
2424

2525
/* Initialize new neuron */
2626
struct neuron* neuron_init(uint id)
File renamed without changes.

src/jar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "header.h"
1+
#include "cbrain.h"
22

33
struct jar* jar_init(int b_count)
44
{

src/thread.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
SOFTWARE.
2121
*/
2222

23-
#include "header.h"
23+
#include "cbrain.h"
2424

2525
struct thread_args {
2626
uint s;

0 commit comments

Comments
 (0)