Re: Can't link C++ program to libipset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx> 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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux