[syslog-ng] Not able to link syslog-ng libraries through gcc

Nitish Saboo nitish.saboo55 at gmail.com
Thu Mar 5 11:42:49 UTC 2020


Hi,

I compiled syslog-ng-3.25.1 using the following code:

tar -xvzf syslog-ng_3.25.1.tar.gz

mkdir -p syslog-ng_3.25.1/build

cd syslog-ng_3.25.1/build

../configure
--prefix=/home/nsaboo/Desktop/Cproject/syslog/syslog-ng_3.25.1/install

make

make install

Post installation,the folder structure looks like this:

nsaboo at ubuntu:~/Desktop/Cproject/syslog/syslog-ng-3.25.1/install$ ls -lrt
total 28
drwxrwxr-x 2 nsaboo nsaboo 4096 Feb 11 04:08 sbin
drwxrwxr-x 2 nsaboo nsaboo 4096 Feb 11 04:08 bin
drwxr-xr-x 2 nsaboo nsaboo 4096 Feb 11 04:08 var
drwxr-xr-x 3 nsaboo nsaboo 4096 Feb 11 04:08 share
drwxrwxr-x 4 nsaboo nsaboo 4096 Feb 11 04:08 include
drwxr-xr-x 3 nsaboo nsaboo 4096 Feb 11 04:08 etc
drwxrwxr-x 4 nsaboo nsaboo 4096 Feb 18 00:35 lib
nsaboo at ubuntu:~/Desktop/Cproject/syslog/syslog-ng-3.25.1/install$

I have a C code base (syslog-node.c) and header file (node.h) that is
internally calling syslog-ng patterndb apis':
I have a main.c file that calls methods in 'syslog-node.c'.

My header file has following methods:

typedef void (*key_value_cb)(const char* key, const char* value, size_t
value_len, int data);
int initialize_engine(const char* filename, const char* module_path,
key_value_cb cb);
int reload_pattern_db(const char* filename, key_value_cb cb);
int load_pattern_db(const char* filename, key_value_cb cb);
void match(const char* pattern, size_t pattern_len, const char* program,
size_t program_len);
int shutdown();


I am calling following gcc command to create a binary but it is erroring
out:

 gcc -L/home/nsaboo/Desktop/Cproject/syslog/syslog-ng-3.25.1/install/lib
lsyslog-ng
-L/home/nsaboo/Desktop/Cproject/syslog/syslog-ng-3.25.1/install/lib/syslog-ng
ldbparser -I/usr/include/glib-2.0
-I/usr/lib/x86_64-linux-gnu/glib-2.0/include
-I/home/nsaboo/Desktop/Cproject/syslog/syslog-ng-3.25.1/install/include/syslog-ng
-I/home/nsaboo/Desktop/Cproject/syslog/syslog-ng-3.25.1/install/include
-I/home/nsaboo/Desktop/Cproject/syslog/syslog-ng-3.25.1/
-I/home/nsaboo/Desktop/Cproject/syslog/syslog-ng-3.25.1/build/
-I/usr/local/include/eventlog/ syslog-node.c main.c -o main

 Error
 =====

nsaboo at ubuntu:~/Desktop/Cproject$  gcc
-L/home/nsaboo/Desktop/Cproject/syslog/syslog-ng-3.25.1/install/lib
-lsyslog-ng
-L/home/nsaboo/Desktop/Cproject/syslog/syslog-ng-3.25.1/install/lib/syslog-ng
-ldbparser -I/usr/include/glib-2.0
-I/usr/lib/x86_64-linux-gnu/glib-2.0/include
-I/home/nsaboo/Desktop/Cproject/syslog/syslog-ng-3.25.1/install/include/syslog-ng
-I/home/nsaboo/Desktop/Cproject/syslog/syslog-ng-3.25.1/install/include
-I/home/nsaboo/Desktop/Cproject/syslog/syslog-ng-3.25.1/
-I/home/nsaboo/Desktop/Cproject/syslog/syslog-ng-3.25.1/build/
-I/usr/local/include/eventlog/ syslog-node.c main.c -o main
/tmp/ccam1ao5.o: In function `pdbtool_pdb_emit_accumulate':
syslog-node.c:(.text+0x55): undefined reference to `logmsg_registry'
syslog-node.c:(.text+0x73): undefined reference to `nv_table_foreach'
/tmp/ccam1ao5.o: In function `match':
syslog-node.c:(.text+0x93): undefined reference to `log_msg_new_empty'
syslog-node.c:(.text+0xb0): undefined reference to `log_msg_set_value'
syslog-node.c:(.text+0xc9): undefined reference to `log_msg_set_value'
syslog-node.c:(.text+0xdf): undefined reference to `pattern_db_process'
syslog-node.c:(.text+0xeb): undefined reference to `log_msg_unref'
/tmp/ccam1ao5.o: In function `reload_pattern_db':
syslog-node.c:(.text+0x1e2): undefined reference to `pattern_db_free'
syslog-node.c:(.text+0x1e7): undefined reference to `pattern_db_new'
syslog-node.c:(.text+0x20b): undefined reference to
`pattern_db_reload_ruleset'
syslog-node.c:(.text+0x225): undefined reference to
`pattern_db_set_emit_func'
/tmp/ccam1ao5.o: In function `load_pattern_db':
syslog-node.c:(.text+0x257): undefined reference to `pattern_db_free'
syslog-node.c:(.text+0x25c): undefined reference to `pattern_db_new'
syslog-node.c:(.text+0x280): undefined reference to
`pattern_db_reload_ruleset'
syslog-node.c:(.text+0x29a): undefined reference to
`pattern_db_set_emit_func'
/tmp/ccam1ao5.o: In function `initialize_engine':
syslog-node.c:(.text+0x2ba): undefined reference to `app_startup'
syslog-node.c:(.text+0x2c4): undefined reference to `msg_init'
syslog-node.c:(.text+0x2cb): undefined reference to
`resolvedConfigurablePaths'
syslog-node.c:(.text+0x2d0): undefined reference to
`resolved_configurable_paths_init'
syslog-node.c:(.text+0x2db): undefined reference to
`resolvedConfigurablePaths'
syslog-node.c:(.text+0x2e5): undefined reference to `cfg_new'
syslog-node.c:(.text+0x2fb): undefined reference to `cfg_set_global_paths'
syslog-node.c:(.text+0x311): undefined reference to `cfg_load_module'
syslog-node.c:(.text+0x327): undefined reference to `cfg_load_module'
syslog-node.c:(.text+0x32c): undefined reference to `pattern_db_global_init'
syslog-node.c:(.text+0x347): undefined reference to `pattern_db_free'
syslog-node.c:(.text+0x34c): undefined reference to `pattern_db_new'
syslog-node.c:(.text+0x370): undefined reference to
`pattern_db_reload_ruleset'
syslog-node.c:(.text+0x38a): undefined reference to
`pattern_db_set_emit_func'
/tmp/ccam1ao5.o: In function `shutdown':
syslog-node.c:(.text+0x39a): undefined reference to `app_shutdown'
collect2: error: ld returned 1 exit status

Those functions are available in the shared libraries.nm command output
shows the same

nsaboo at ubuntu:~/Desktop/Cproject$ nm
syslog/syslog-ng-3.25.1/install/lib/syslog-ng/libdbparser.so | grep T |
grep 'pattern_db_set_emit_func'
0000000000010d40 T pattern_db_set_emit_func
nsaboo at ubuntu:~/Desktop/Cproject$ nm
syslog/syslog-ng-3.25.1/install/lib/syslog-ng/libdbparser.so | grep T |
grep 'pattern_db_new'
0000000000010ef0 T pattern_db_new
nsaboo at ubuntu:~/Desktop/Cproject$ nm
syslog/syslog-ng-3.25.1/install/lib/syslog-ng/libdbparser.so | grep T |
grep 'pattern_db_reload_ruleset'
0000000000010cc0 T pattern_db_reload_ruleset
nsaboo at ubuntu:~/Desktop/Cproject$ nm
syslog/syslog-ng-3.25.1/install/lib/libsyslog-ng.so.0 | grep T | grep
'log_msg_set_value'
0000000000080df0 T log_msg_set_value
00000000000811d0 T __log_msg_set_value_by_name
0000000000081220 T log_msg_set_value_indirect
nsaboo at ubuntu:~/Desktop/Cproject$ nm
syslog/syslog-ng-3.25.1/install/lib/libsyslog-ng.so | grep T | grep
'msg_init'
0000000000051990 T msg_init
nsaboo at ubuntu:~/Desktop/Cproject$ nm
syslog/syslog-ng-3.25.1/install/lib/libsyslog-ng.so | grep T | grep
'cfg_new'
0000000000039200 T cfg_new
0000000000039360 T cfg_new_snippet
0000000000039390 T cfg_new_subordinate


I understand this is the C linking error where I am including all the
dynamic shared libraries and header files, but not able to figure out what
is causing this issue.
Can someone please help me to determine what am I missing here ?

Thanks,
Nitish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.balabit.hu/pipermail/syslog-ng/attachments/20200305/c0b21fbd/attachment.html>


More information about the syslog-ng mailing list