mirror of https://github.com/OISF/suricata
examples: program linking against library
Provide an example of an extremely simple application that links against Suricata. This provides a Makefile integrated with the Suricata build system for in-tree building, as well as an example Makefile for building out of tree. Currently this application just wraps SuricataMain and does nothing else.pull/10469/head
parent
6d792f017b
commit
2421b024f2
@ -0,0 +1,2 @@
|
|||||||
|
!/Makefile.example.in
|
||||||
|
Makefile.example
|
@ -0,0 +1,9 @@
|
|||||||
|
bin_PROGRAMS = simple
|
||||||
|
|
||||||
|
simple_SOURCES = main.c
|
||||||
|
|
||||||
|
AM_CPPFLAGS = -I$(top_srcdir)/src
|
||||||
|
|
||||||
|
simple_LDFLAGS = $(all_libraries) $(SECLDFLAGS)
|
||||||
|
simple_LDADD = $(top_builddir)/src/libsuricata_c.a ../../$(RUST_SURICATA_LIB) ../../$(HTP_LDADD) $(RUST_LDADD)
|
||||||
|
simple_DEPENDENCIES = $(top_builddir)/src/libsuricata_c.a ../../$(RUST_SURICATA_LIB)
|
@ -0,0 +1,12 @@
|
|||||||
|
LIBSURICATA_CONFIG ?= @CONFIGURE_PREFIX@/bin/libsuricata-config
|
||||||
|
|
||||||
|
SURICATA_LIBS = `$(LIBSURICATA_CONFIG) --libs`
|
||||||
|
SURICATA_CFLAGS := `$(LIBSURICATA_CONFIG) --cflags`
|
||||||
|
|
||||||
|
all: simple
|
||||||
|
|
||||||
|
simple: main.c
|
||||||
|
$(CC) -o $@ $^ $(CFLAGS) $(SURICATA_CFLAGS) $(SURICATA_LIBS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f simple
|
@ -0,0 +1,36 @@
|
|||||||
|
# Simple Library Example
|
||||||
|
|
||||||
|
## Building In Tree
|
||||||
|
|
||||||
|
The Suricata build system has created a Makefile that should allow you
|
||||||
|
to build this application in-tree on most supported platforms. To
|
||||||
|
build simply run:
|
||||||
|
|
||||||
|
```
|
||||||
|
make
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building Out of Tree
|
||||||
|
|
||||||
|
A Makefile.example has also been generated to use as an example on how
|
||||||
|
to build against the library in a standalone application.
|
||||||
|
|
||||||
|
First build and install the Suricata library including:
|
||||||
|
|
||||||
|
```
|
||||||
|
make install-library
|
||||||
|
make install-headers
|
||||||
|
```
|
||||||
|
|
||||||
|
Then run:
|
||||||
|
|
||||||
|
```
|
||||||
|
make -f Makefile.example
|
||||||
|
```
|
||||||
|
|
||||||
|
If you installed to a non-standard location, you need to ensure that
|
||||||
|
`libsuricata-config` is in your path, for example:
|
||||||
|
|
||||||
|
```
|
||||||
|
PATH=/opt/suricata/bin:$PATH make -f Makefile.example
|
||||||
|
```
|
@ -0,0 +1,7 @@
|
|||||||
|
#include "suricata.h"
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
SuricataMain(argc, argv);
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue