This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Link problems in g++ but not in gcc!!
- From: "L.Suresh" <suresh at comodogroup dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 31 Aug 2004 17:17:36 +0530
- Subject: Link problems in g++ but not in gcc!!
- Organization: Comodo
- Reply-to: suresh at comodogroup dot com
Hi,
I'm having link problems when i compile my program iptables.cpp with
g++.
I have the following:
/usr/lib/libipq.a
/usr/include/libipq.h
/usr/share/man/man3/libipq.3.gz
I tried to compile like this.
g++ -o ipqtest iptables.cpp -lipq <<--- Fails to compile.
g++ -o ipqtest iptables.cpp /usr/lib/libipq.a
gcc -o ipqtest iptables.c -lipq <-- Compiles!!
I get the following error when i compile with g++. But when i change my
file name iptables.cpp to iptables.c and compile, it compiles without
any problems!!
Symbol list of libipq.a is:
libipq.o:
U bind
U close
U __errno_location
U fprintf
U fputc
U fputs
U free
U fwrite
U getpid
00000260 T ipq_create_handle
00000550 T ipq_ctl
000003a0 T ipq_destroy_handle
00000000 D ipq_errmap
00000000 b ipq_errno
00000560 T ipq_errstr
00000460 T ipq_get_msgerr
00000470 T ipq_get_packet
00000450 T ipq_message_type
00000090 t ipq_netlink_recvfrom
00000050 t ipq_netlink_sendmsg
00000000 t ipq_netlink_sendto
00000580 T ipq_perror
00000440 T ipq_read
000003d0 T ipq_set_mode
00000480 T ipq_set_verdict
00000240 t ipq_strerror
U malloc
U recvfrom
U select
U sendmsg
U sendto
U socket
U stderr
U strerror
Error while compiling.
/tmp/ccEVoYgQ.o(.text+0xf): In function `die(ipq_handle*)':
: undefined reference to `ipq_perror(char const*)'
/tmp/ccEVoYgQ.o(.text+0x1d): In function `die(ipq_handle*)':
: undefined reference to `ipq_destroy_handle(ipq_handle*)'
/tmp/ccEVoYgQ.o(.text+0x37): In function `mains(int, char**)':
: undefined reference to `ipq_create_handle(unsigned, unsigned)'
/tmp/ccEVoYgQ.o(.text+0x6f): In function `mains(int, char**)':
: undefined reference to `ipq_set_mode(ipq_handle const*, unsigned char,
unsigned)'
/tmp/ccEVoYgQ.o(.text+0xa6): In function `mains(int, char**)':
: undefined reference to `ipq_read(ipq_handle const*, unsigned char*,
unsigned, int)'
/tmp/ccEVoYgQ.o(.text+0xd2): In function `mains(int, char**)':
: undefined reference to `ipq_message_type(unsigned char const*)'
/tmp/ccEVoYgQ.o(.text+0x104): In function `mains(int, char**)':
: undefined reference to `ipq_get_msgerr(unsigned char const*)'
/tmp/ccEVoYgQ.o(.text+0x12f): In function `mains(int, char**)':
: undefined reference to `ipq_get_packet(unsigned char const*)'
/tmp/ccEVoYgQ.o(.text+0x154): In function `mains(int, char**)':
: undefined reference to `ipq_set_verdict(ipq_handle const*, unsigned,
unsigned, unsigned, unsigned char*)'
collect2: ld returned 1 exit status
Any help would be highly appreciated.
Thanks,
L.Suresh