From: Pavel Odintsov <pavel.odintsov@gmail.com>
To: netfilter-devel@vger.kernel.org
Subject: Re: Can't link C++ program to libipset
Date: Wed, 18 Mar 2015 14:39:04 +0300 [thread overview]
Message-ID: <CALgsdbduFoefiSXZYwDWxPXkk_GRQoUUJABRhtA-fNmZV+2G+A@mail.gmail.com> (raw)
In-Reply-To: <CALgsdbeBy=wDnyEpZTrGb0=HKPB9kcS03m=jPzCLfzotyA7P8Q@mail.gmail.com>
Thanks to Pavel Boldin for help with solving this issue offlist!
Fix very simple:
extern "C" {
#include <libipset/data.h> /* enum ipset_data */
#include <libipset/parse.h> /* ipset_parse_* */
#include <libipset/session.h> /* ipset_session_* */
#include <libipset/types.h> /* struct ipset_type */
#include <libipset/ui.h> /* core options, commands */
#include <libipset/utils.h> /* STREQ */
}
Could developers add this declaration to libipset?
Thank you!
On Wed, Mar 18, 2015 at 2:20 PM, Pavel Odintsov
<pavel.odintsov@gmail.com> wrote:
> Hello, folks!
>
> I trying to integrate ipset to my flood monitoring toolkit
> https://github.com/FastVPSEestiOu/fastnetmon but can't link it
> correctly.
>
> Here you can find my code:
> https://gist.github.com/pavel-odintsov/b2277822e5c88e136550
>
> I installed recent version from Git:
> cd /usr/src
> git clone git://git.netfilter.org/ipset.git
> apt-get install -y automake libtool
> ./autogen.sh
> ./configure --prefix=/opt/ipset
> make install
>
> And tried link my tool with libipset but haven't any success:
> g++ ipset.c -I/opt/ipset/include/ -L/opt/ipset/lib -lipset
> ipset.c: In function ‘int main()’:
> ipset.c:15:37: warning: deprecated conversion from string constant to
> ‘char*’ [-Wwrite-strings]
> ipset.c:15:37: warning: deprecated conversion from string constant to
> ‘char*’ [-Wwrite-strings]
> /tmp/ccWP0vdf.o:ipset.c:function ban_ip(char*, char*): error:
> undefined reference to 'ipset_session_init(int (*)(char const*, ...))'
> /tmp/ccWP0vdf.o:ipset.c:function ban_ip(char*, char*): error:
> undefined reference to 'ipset_parse_setname(ipset_session*, ipset_opt,
> char const*)'
> /tmp/ccWP0vdf.o:ipset.c:function ban_ip(char*, char*): error:
> undefined reference to 'ipset_type_get(ipset_session*, ipset_cmd)'
> /tmp/ccWP0vdf.o:ipset.c:function ban_ip(char*, char*): error:
> undefined reference to 'ipset_session_error(ipset_session const*)'
> /tmp/ccWP0vdf.o:ipset.c:function ban_ip(char*, char*): error:
> undefined reference to 'ipset_parse_elem(ipset_session*, bool, char
> const*)'
> /tmp/ccWP0vdf.o:ipset.c:function ban_ip(char*, char*): error:
> undefined reference to 'ipset_session_error(ipset_session const*)'
> /tmp/ccWP0vdf.o:ipset.c:function ban_ip(char*, char*): error:
> undefined reference to 'ipset_cmd(ipset_session*, ipset_cmd, unsigned
> int)'
> /tmp/ccWP0vdf.o:ipset.c:function ban_ip(char*, char*): error:
> undefined reference to 'ipset_session_fini(ipset_session*)'
> collect2: error: ld returned 1 exit status
>
> But if i change g++ to gcc everything passed with flying colors:
> gcc ipset.c -I/opt/ipset/include/ -L/opt/ipset/lib -lipset
>
> My toolkit written in C++ and I need ability to link it directly with libipset.
>
> Thank you for attention to my problem!
>
> --
> Sincerely yours, Pavel Odintsov
--
Sincerely yours, Pavel Odintsov
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-03-18 11:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-18 11:20 Can't link C++ program to libipset Pavel Odintsov
2015-03-18 11:39 ` Pavel Odintsov [this message]
2015-03-18 12:01 ` Jan Engelhardt
2015-03-18 13:15 ` Pavel Odintsov
2015-03-18 20:03 ` Jozsef Kadlecsik
2015-03-18 20:07 ` Pavel Odintsov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CALgsdbduFoefiSXZYwDWxPXkk_GRQoUUJABRhtA-fNmZV+2G+A@mail.gmail.com \
--to=pavel.odintsov@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).