English 中文(简体)
包括C的负责人档案和汇编
原标题:including header files in C and compile

I am working with an open source project called snort , which is written in C, under Linux. I opened project in netbeans correctly and now I am going to do some changes in this source code. The src folder of program contains several folders and also each folder has some folders. I heard that netbeans is able to generate make files. I am doing some changes in src files in folder XFolder and want to use a library function in another folder in my project (YFolder). I included .h file and used the function correctly.

#include"../YFolder/lib.h"

现在,当我能够汇编节目时,我是奥基,但当我使用在制作过程中创建的有活力的图书馆“(共有物体档案)”时,我看到了一个错误,即是指我从没有界定的其他文件中使用的功能,并看到这一错误;(fxhash_new是我所说的外部功能的名称)。

libsf_sip_preproc.so: undefined symbol: sfxhash_new

我还编辑了《马克茨》。 (。 但效果不佳。 谁能帮助我?

EDIT:

I am in folder src/dynamic-preprocessor/sip I want to use a function in file: src/sfutil/sfxHash.c the function name is sfxhash_new(... ... ...) I included sfxHash.h correctly. I did some changes In my Makefile.am but the main makefile is this.

MyMakfile.am file:

## $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
问题回答

After making changes in Makefile.am file, the changes are not reflected immediately (i.e. if you run configure & make you will not see the changes). You should generate/update the corresponding Makefile.in file first. For that you need to run automake command in the topmost directory of the source tree (where configure.in or configure.ac resides). To make sure that your Makefile.am changes to include new sources will successfully be reflected in the build, check that libsf_sip_preproc_la_SOURCES is same set of files in Makefile.am as well as Makefile.in. Now, run configure and make commands.
Note that adding a file from one place to another in the source tree may bring in its own set of dependencies i.e. sfxhash source files may include files & link to libraries which are not present as part of Makefile.am in question, in which case you may have to update INCLUDES to include the directory needed by the source and/or add new libraries in libsf_sip_preproc_la_LIBADD. Avoid mixing .la & .a files in libsf_sip_preproc_la_LIBADD.
Hope this helps!

如你写的:

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

如果SO_WITH_STATIC_LIB真的,我认为这行文如下:

libsf_sip_preproc_la_LIBADD = ../libsf_dynamic_preproc.la

应当:

libsf_sip_preproc_la_LIBADD = ../libsf_dynamic_preproc.a

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





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...