* Can't link C++ program to libipset
@ 2015-03-18 11:20 Pavel Odintsov
2015-03-18 11:39 ` Pavel Odintsov
2015-03-18 12:01 ` Jan Engelhardt
0 siblings, 2 replies; 6+ messages in thread
From: Pavel Odintsov @ 2015-03-18 11:20 UTC (permalink / raw)
To: netfilter-devel
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
--
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can't link C++ program to libipset
2015-03-18 11:20 Can't link C++ program to libipset Pavel Odintsov
@ 2015-03-18 11:39 ` Pavel Odintsov
2015-03-18 12:01 ` Jan Engelhardt
1 sibling, 0 replies; 6+ messages in thread
From: Pavel Odintsov @ 2015-03-18 11:39 UTC (permalink / raw)
To: netfilter-devel
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can't link C++ program to libipset
2015-03-18 11:20 Can't link C++ program to libipset Pavel Odintsov
2015-03-18 11:39 ` Pavel Odintsov
@ 2015-03-18 12:01 ` Jan Engelhardt
2015-03-18 13:15 ` Pavel Odintsov
1 sibling, 1 reply; 6+ messages in thread
From: Jan Engelhardt @ 2015-03-18 12:01 UTC (permalink / raw)
To: Pavel Odintsov; +Cc: netfilter-devel
On Wednesday 2015-03-18 12:20, Pavel Odintsov wrote:
>
>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 [the snippet of] my code:
>https://gist.github.com/pavel-odintsov/b2277822e5c88e136550
>
>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]
This is a bug in your code, not ipset. In C++, string literals
have type const char *. In C, they have type char * but are still
immutable, so you better treat them as const char * in both cases.
>/tmp/ccWP0vdf.o:ipset.c:function ban_ip(char*, char*): error:
>undefined reference to 'ipset_session_init(int (*)(char const*, ...))'
It's an ipset bug. The ipset header files are missing
#ifdef __cplusplus
extern "C" {
#endif
...
wraps.
--
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can't link C++ program to libipset
2015-03-18 12:01 ` Jan Engelhardt
@ 2015-03-18 13:15 ` Pavel Odintsov
2015-03-18 20:03 ` Jozsef Kadlecsik
0 siblings, 1 reply; 6+ messages in thread
From: Pavel Odintsov @ 2015-03-18 13:15 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: netfilter-devel
Thank you, Jan! Could anybody commit this fix to ipset repo?
On Wed, Mar 18, 2015 at 3:01 PM, Jan Engelhardt <jengelh@inai.de> wrote:
>
> On Wednesday 2015-03-18 12:20, Pavel Odintsov wrote:
>>
>>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 [the snippet of] my code:
>>https://gist.github.com/pavel-odintsov/b2277822e5c88e136550
>>
>>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]
>
> This is a bug in your code, not ipset. In C++, string literals
> have type const char *. In C, they have type char * but are still
> immutable, so you better treat them as const char * in both cases.
>
>>/tmp/ccWP0vdf.o:ipset.c:function ban_ip(char*, char*): error:
>>undefined reference to 'ipset_session_init(int (*)(char const*, ...))'
>
> It's an ipset bug. The ipset header files are missing
>
> #ifdef __cplusplus
> extern "C" {
> #endif
> ...
> wraps.
--
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can't link C++ program to libipset
2015-03-18 13:15 ` Pavel Odintsov
@ 2015-03-18 20:03 ` Jozsef Kadlecsik
2015-03-18 20:07 ` Pavel Odintsov
0 siblings, 1 reply; 6+ messages in thread
From: Jozsef Kadlecsik @ 2015-03-18 20:03 UTC (permalink / raw)
To: Pavel Odintsov; +Cc: Jan Engelhardt, netfilter-devel
On Wed, 18 Mar 2015, Pavel Odintsov wrote:
> Thank you, Jan! Could anybody commit this fix to ipset repo?
Patch is applied to the ipset git tree - I hope I got it right, it is not
tested from C++ point of view.
Best regards,
Jozsef
-
E-mail : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.mta.hu
PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences
H-1525 Budapest 114, POB. 49, Hungary
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can't link C++ program to libipset
2015-03-18 20:03 ` Jozsef Kadlecsik
@ 2015-03-18 20:07 ` Pavel Odintsov
0 siblings, 0 replies; 6+ messages in thread
From: Pavel Odintsov @ 2015-03-18 20:07 UTC (permalink / raw)
To: Jozsef Kadlecsik; +Cc: Jan Engelhardt, netfilter-devel
Hello!
I tested it. It works perfectly! Thank you so much from C++ developers!
On Wed, Mar 18, 2015 at 11:03 PM, Jozsef Kadlecsik
<kadlec@blackhole.kfki.hu> wrote:
> On Wed, 18 Mar 2015, Pavel Odintsov wrote:
>
>> Thank you, Jan! Could anybody commit this fix to ipset repo?
>
> Patch is applied to the ipset git tree - I hope I got it right, it is not
> tested from C++ point of view.
>
> Best regards,
> Jozsef
> -
> E-mail : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.mta.hu
> PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
> Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences
> H-1525 Budapest 114, POB. 49, Hungary
--
Sincerely yours, Pavel Odintsov
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-03-18 20:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-18 11:20 Can't link C++ program to libipset Pavel Odintsov
2015-03-18 11:39 ` Pavel Odintsov
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
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.