包括C语言中的头文件和编译

saj*_*jad 5 c netbeans shared-libraries include snort

我正在使用一个名为snort的开源项目,该项目是用Linux编写的.我正确地在netbeans中打开项目,现在我将对此源代码进行一些更改.程序的src文件夹包含几个文件夹,每个文件夹也有一些文件夹.我听说netbeans能够生成make文件.我正在对文件夹XFolder中的src文件进行一些更改,并希望在我的项目(YFolder)中的另一个文件夹中使用库函数.我包含.h文件并正确使用了该功能.

#include"../YFolder/lib.h"
Run Code Online (Sandbox Code Playgroud)

现在,当我可以编译程序时,它是好的,但是当我使用在make进程中创建的动态库".so(共享对象文件)"时; 并运行程序,我看到一个错误,这意味着我从其他未定义的文件夹中使用的函数,并看到此错误; (sfxhash_new是我调用的外部函数的名称).

libsf_sip_preproc.so:未定义的符号:sfxhash_new

我还编辑了Makefile.am并添加了该包的源代码(../YFolder/lib.c and lib.h); 但没有效果.有人可以帮我吗?

编辑:

我在文件夹src/dynamic-preprocessor/sip我想在文件中使用一个函数:src/sfutil/sfxHash.c函数名是sfxhash_new(...... ......)我正确地包含了sfxHash.h.我在Makefile.am中做了一些更改,但主要的makefile就是这个.

我的Makefile.am文件:

## $Id
AUTOMAKE_OPTIONS=foreign no-dependencies

INCLUDES = -I../include -I${srcdir}/../libs -I$(srcdir)/includes

libdir = ${exec_prefix}/lib/snort_dynamicpreprocessor

lib_LTLIBRARIES = libsf_sip_preproc.la

libsf_sip_preproc_la_LDFLAGS = -shared -export-dynamic -module @XCCFLAGS@
if SO_WITH_STATIC_LIB
libsf_sip_preproc_la_LIBADD = ../libsf_dynamic_preproc.la
else
nodist_libsf_sip_preproc_la_SOURCES = \
../include/sf_dynamic_preproc_lib.c \
../include/sf_ip.c \

endif

libsf_sip_preproc_la_SOURCES = \
spp_sip.c \
spp_sip.h \
sip_config.c \
sip_config.h \
sip_parser.c \
sip_parser.h \
sip_dialog.c \
sip_dialog.h \
sip_roptions.c \
sip_roptions.h \
sip_utils.c \
sip_utils.h \
sip_debug.h \
../include/sfxhash.c \   -----------------> I have copied src files in this dictionary
../include/sfxhash.h     ------------------>

EXTRA_DIST = \
sf_sip.dsp

all-local: $(LTLIBRARIES)
    $(MAKE) DESTDIR=`pwd`/../build install-libLTLIBRARIES
Run Code Online (Sandbox Code Playgroud)

MYM*_*Neo 1

正如你所写:

libsf_sip_preproc_la_LDFLAGS = -shared -export-dynamic -module @XCCFLAGS@
if SO_WITH_STATIC_LIB
libsf_sip_preproc_la_LIBADD = ../libsf_dynamic_preproc.la
else
nodist_libsf_sip_preproc_la_SOURCES = \
../include/sf_dynamic_preproc_lib.c \
../include/sf_ip.c \

endif
Run Code Online (Sandbox Code Playgroud)

如果 SO_WITH_STATIC_LIB 为 true,我认为这一行:

libsf_sip_preproc_la_LIBADD = ../libsf_dynamic_preproc.la
Run Code Online (Sandbox Code Playgroud)

应该

libsf_sip_preproc_la_LIBADD = ../libsf_dynamic_preproc.a
Run Code Online (Sandbox Code Playgroud)

这是我的想法,你可以尝试一下。