我正在开发一个名为snort的开源项目,它是用C语言编写的,在Linux下。我正确地在netbeans中打开了项目,现在我将对此源代码进行一些更改。程序的src文件夹包含多个文件夹,每个文件夹也有一些文件夹。我听说netbeans能够生成make文件。我正在对文件夹XFolder中的src文件进行一些更改,并希望在我的项目(YFolder)中的另一个文件夹中使用库函数。我包含了.h文件并正确使用了该功能。在C中包含头文件并编译
#include"../YFolder/lib.h"
现在,当我可以编译该程序,这是好的,但是,当我使用动态库“所以(共享对象文件)”,在化妆过程创建的;并运行程序,我看到一个错误,这意味着我从其他文件夹中使用的功能未定义,看到这个错误; (sfxhash_new是我调用的外部函数的名称)。
libsf_sip_preproc.so:未定义符号:sfxhash_new
我还编辑Makefile.am并补充说封装(../YFolder/lib.c and lib.h
)的来源;但没有效果。任何人都可以帮助我吗?
编辑:
我在文件夹中的src /动态预处理器/ 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 @[email protected]
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
你必须把'-lnet -lpcre'等标志放在LDFLAGS的最后,你做了吗? – 2012-05-06 04:02:10
这可能也有帮助[here](http://stackoverflow.com/questions/480764/linux-error-while-loading-shared-libraries-cannot-open-shared-object-file-no-s) – ervinbosenbacher
另请注意'未定义符号'错误与正确或不正确的头文件包含无关;他们是链接器错误,并显示一些库缺失。 – 2012-05-06 04:05:30