[ovs-dev] Help with error in <linux/types.h> when compiling custom library

Jarno Rajahalme jrajahalme at nicira.com
Tue Aug 5 22:04:45 UTC 2014


It might be helpful starting with the exact compile command line used by “make” on lib/my_library.c, it will have all the right include directory options you are missing from your gcc command line that might have an effect.

Given that your successful gcc line misses all the “-I” directives, I suspect you are not including <config.h> as the first include in your my_library.c?

You could start modifying the command line used by make towards your successful one one step at a time to figure out where the problem may be.

Hope this helps,

  Jarno

On Aug 5, 2014, at 8:22 AM, Jordi Palà <jordipalasole at gmail.com> wrote:

> Dear all,
> 
> We are testing a custom library that we want to include to
> openvswitch. This library uses netlink and the -DCONFIG_LIBNL20
> compilation flag.
> 
> We can compile the library standalone and it works, but when we add it
> to openvswitch the compilation crashes.
> 
> The way we add the library to openvswicth is the following:
> 
> 1) In lib/automake.mk we add:
> 
> lib_libopenvswitch_la_CFLAGS=-DCONFIG_LIBNL20
> 
> lib_libopenvswitch_la_SOURCES = \
> ...
> lib/my_library.c \
> lib/my_library.h
> 
> 2) However, when compiling we get the following error
> 
> In file included from /usr/include/linux/rtnetlink.h:8:0,
>                 from /usr/include/netlink/netlink.h:26,
>                 from /usr/include/netlink/genl/genl.h:15,
>                 from lib/my_library.h:21,
>                 from lib/my_library.c:1:
> /usr/include/linux/neighbour.h:11:2: error: unknown type name '__s32'
> 
> /usr/include/linux/neighbour.h includes /usr/include/linux/types.h who
> should be able to find the type __s32. Indeed the chain of includes in
> /usr/include/ should be:
> 
> neighbour.h -->  <asm/types.h> --> (I assume this translates into
> asm-generic/types.h) --> <asm-generic/int-ll64.h> ---> __s32 is
> defined here.
> 
> What puzzles me is that if we compile the library outside openvswitch
> everything works fine, and /usr/include/linux/neighbour.h can find the
> type. This is the compilation command that works from outside
> openvswitch:
> 
> gcc -O2 -g -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs
> -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration
> -DCONFIG_LIBNL20 -c -o my_library.o my_library.c
> 
> Any help is appreciated.
> 
> Best Regards
> 
> Jordi Pala
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev




More information about the dev mailing list