Skip to content

Commit 4887f05

Browse files
committed
Update README.md
1 parent 8039c59 commit 4887f05

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,43 @@ Building on windows requires [MinGW](http://mingw.org) which provides all the to
1717
#### Building the project
1818
In the project directory, run the following commands: `./autogen.sh` then run `./configure`. If autogen complains that it couldn't find a directory named "m4", run: `mkdir m4` and then `./autogen.sh`.
1919

20+
- note: Running configure with a prefix like: `./configure --prefix=/some/custom/path` will cause `make install` to install the library to that directory instead of the default one.
21+
2022
At this point we should be able to build the project by running:
2123
```
2224
make
2325
```
26+
By default `make` builds a shared library. To build a static library, run make with "static" flag on: `make CFLAGS=-static`.
27+
28+
29+
Installing the library:
30+
```
31+
make install
32+
```
33+
2434
The tests can be run by:
2535
```
2636
make check
2737
```
38+
#### Compiling and linking a simple program
39+
- hello.c
40+
```c
41+
#include <stdio.h>
42+
#include <array.h>
43+
44+
int main(int argc, char **argv) {
45+
Array *ar = array_new();
46+
array_add(ar, "Hello World!\n");
47+
48+
printf("%s", (char*) array_get(ar, 0));
49+
50+
return 0;
51+
}
52+
```
53+
We can now build and staticly link the library to our program:
54+
```
55+
gcc hello.c -I/path/to/library/include/ -static -L/path/to/library/lib/ -lcollectc -o hello
56+
```
2857
2958
#### Examples
3059

0 commit comments

Comments
 (0)