On Sun, 2002-05-26 08:46:52 +0800, bert <[EMAIL PROTECTED]> wrote in message <[EMAIL PROTECTED]>: > When I test the sample code given by manpage of libipq, I use the fallowing command >to compile. > "g++ sample.cpp -o sample -lipq" > but there are some link errors. > why?? > I have downloaded the ipchains and using "make ,make install ,make install-devel" to >build it. > How to deal with problems? > Thanks > > [root@ir kern]# g++ sample.cpp -lipq
First, never ever compile as user "root". Root privileges have never been required to compile some C code... Second, you're using a C++ compiler and C++ sources. This means that all identifers (variables and functions and so on) are in C++ namespace (which means that basically they get their type added to their name; > /tmp/cczHtLb0.o: In function `die(ipq_handle *)': > /tmp/cczHtLb0.o(.text+0xf): undefined reference to `ipq_perror(char const *)' ...this is why the linker says "undefined reference to `ipq_perror(char const *)'" ^^^^^^^^^^^^^^ However, libipq functions are C functions which are within C namespace. So you can't access them from C++ [1]. MfG, JBG [1] You can, of course, put "#ifdev __cplusplus ... extern C { ... }" around the libipq header files so that the C++ compiler knows that these functions are written in C, not in C++... -- Jan-Benedict Glaw . [EMAIL PROTECTED] . +49-172-7608481 -- New APT-Proxy written in shell script -- http://lug-owl.de/~jbglaw/software/ap2/
msg01047/pgp00000.pgp
Description: PGP signature