2
I am developing a software in C that receives information and need to verify that it is correct through a CRC-16, searching found a lib only for CRC called libcrc.org but also found something on linux and would like to use what is native since I am developing and the software will run on linux.
My question is, include in my source the hearder file but I received a dozen errors, I believe I must be missing something in gcc, follows:
$ gcc read. c -lm -I/usr/src/linux/include/.
In file included from /usr/src/linux/include/./linux/crc16.h:18:0,
from read.c:14:
/usr/src/linux/include/./linux/types.h:14:26: error: conflicting types for ‘fd_set’
typedef __kernel_fd_set fd_set;
^
In file included from /usr/include/sys/types.h:219:0,
from /usr/include/stdlib.h:314,
from read.c:6:
/usr/include/sys/select.h:75:5: note: previous declaration of ‘fd_set’ was here
} fd_set;
^
In file included from /usr/src/linux/include/./linux/crc16.h:18:0,
from read.c:14:
/usr/src/linux/include/./linux/types.h:15:25: error: conflicting types for ‘dev_t’
typedef __kernel_dev_t dev_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:60:17: note: previous declaration of ‘dev_t’ was here
typedef __dev_t dev_t;
^
In file included from /usr/src/linux/include/./linux/crc16.h:18:0,
from read.c:14:
/usr/src/linux/include/./linux/types.h:19:17: error: conflicting types for ‘nlink_t’
typedef __u32 nlink_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:75:19: note: previous declaration of ‘nlink_t’ was here
typedef __nlink_t nlink_t;
^
In file included from /usr/src/linux/include/./linux/crc16.h:18:0,
from read.c:14:
/usr/src/linux/include/./linux/types.h:25:26: error: conflicting types for ‘timer_t’
typedef __kernel_timer_t timer_t;
^
In file included from /usr/include/sys/types.h:132:0,
from /usr/include/stdlib.h:314,
from read.c:6:
/usr/include/time.h:103:19: note: previous declaration of ‘timer_t’ was here
typedef __timer_t timer_t;
^
In file included from /usr/src/linux/include/./linux/crc16.h:18:0,
from read.c:14:
/usr/src/linux/include/./linux/types.h:45:26: error: conflicting types for ‘loff_t’
typedef __kernel_loff_t loff_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:44:18: note: previous declaration of ‘loff_t’ was here
typedef __loff_t loff_t;
^
In file included from /usr/src/linux/include/./linux/crc16.h:18:0,
from read.c:14:
/usr/src/linux/include/./linux/types.h:112:17: error: conflicting types for ‘u_int64_t’
typedef __u64 u_int64_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:203:1: note: previous declaration of ‘u_int64_t’ was here
__u_intN_t (64, __DI__);
^
In file included from /usr/src/linux/include/./linux/crc16.h:18:0,
from read.c:14:
/usr/src/linux/include/./linux/types.h:113:17: error: conflicting types for ‘int64_t’
typedef __s64 int64_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:197:1: note: previous declaration of ‘int64_t’ was here
__intN_t (64, __DI__);
^
In file included from /usr/src/linux/include/./linux/crc16.h:18:0,
from read.c:14:
/usr/src/linux/include/./linux/types.h:134:23: error: conflicting types for ‘blkcnt_t’
typedef unsigned long blkcnt_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:235:20: note: previous declaration of ‘blkcnt_t’ was here
typedef __blkcnt_t blkcnt_t; /* Type to count number of disk blocks. */ ^
In file included from /usr/lib64/gcc/x86_64-slackware-linux/4.8.2/include/stdint.h:9:0,
from read.c:16:
/usr/include/stdint.h:55:27: error: conflicting types for ‘uint64_t’
typedef unsigned long int uint64_t;
^
In file included from /usr/src/linux/include/./linux/crc16.h:18:0,
from read.c:14:
/usr/src/linux/include/./linux/types.h:111:17: note: previous declaration of ‘uint64_t’ was here
typedef __u64 uint64_t;
^
bash-4.2$ gcc read.c -lm -I/usr/src/linux/include/.
bash-4.2$ gcc read.c -lm -I/usr/src/linux/include/.
In file included from /usr/include/linux/if_alg.h:16:0,
from read.c:16:
/usr/src/linux/include/./linux/types.h:14:26: error: conflicting types for ‘fd_set’
typedef __kernel_fd_set fd_set;
^
In file included from /usr/include/sys/types.h:219:0,
from /usr/include/stdlib.h:314,
from read.c:6:
/usr/include/sys/select.h:75:5: note: previous declaration of ‘fd_set’ was here
} fd_set;
^
In file included from /usr/include/linux/if_alg.h:16:0,
from read.c:16:
/usr/src/linux/include/./linux/types.h:15:25: error: conflicting types for ‘dev_t’
typedef __kernel_dev_t dev_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:60:17: note: previous declaration of ‘dev_t’ was here
typedef __dev_t dev_t;
^
In file included from /usr/include/linux/if_alg.h:16:0,
from read.c:16:
/usr/src/linux/include/./linux/types.h:19:17: error: conflicting types for ‘nlink_t’
typedef __u32 nlink_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:75:19: note: previous declaration of ‘nlink_t’ was here
typedef __nlink_t nlink_t;
^
In file included from /usr/include/linux/if_alg.h:16:0,
from read.c:16:
/usr/src/linux/include/./linux/types.h:25:26: error: conflicting types for ‘timer_t’
typedef __kernel_timer_t timer_t;
^
In file included from /usr/include/sys/types.h:132:0,
from /usr/include/stdlib.h:314,
from read.c:6:
/usr/include/time.h:103:19: note: previous declaration of ‘timer_t’ was here
typedef __timer_t timer_t;
^
In file included from /usr/include/linux/if_alg.h:16:0,
from read.c:16:
/usr/src/linux/include/./linux/types.h:45:26: error: conflicting types for ‘loff_t’
typedef __kernel_loff_t loff_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:44:18: note: previous declaration of ‘loff_t’ was here
typedef __loff_t loff_t;
^
In file included from /usr/include/linux/if_alg.h:16:0,
from read.c:16:
/usr/src/linux/include/./linux/types.h:111:17: error: conflicting types for ‘uint64_t’
typedef __u64 uint64_t;
^
In file included from /usr/lib64/gcc/x86_64-slackware-linux/4.8.2/include/stdint.h:9:0,
from read.c:15:
/usr/include/stdint.h:55:27: note: previous declaration of ‘uint64_t’ was here
typedef unsigned long int uint64_t;
^
In file included from /usr/include/linux/if_alg.h:16:0,
from read.c:16:
/usr/src/linux/include/./linux/types.h:112:17: error: conflicting types for ‘u_int64_t’
typedef __u64 u_int64_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:203:1: note: previous declaration of ‘u_int64_t’ was here
__u_intN_t (64, __DI__);
^
In file included from /usr/include/linux/if_alg.h:16:0,
from read.c:16:
/usr/src/linux/include/./linux/types.h:113:17: error: conflicting types for ‘int64_t’
typedef __s64 int64_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:197:1: note: previous declaration of ‘int64_t’ was here
__intN_t (64, __DI__);
^
In file included from /usr/include/linux/if_alg.h:16:0,
from read.c:16:
/usr/src/linux/include/./linux/types.h:134:23: error: conflicting types for ‘blkcnt_t’
typedef unsigned long blkcnt_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:235:20: note: previous declaration of ‘blkcnt_t’ was here
typedef __blkcnt_t blkcnt_t; /* Type to count number of disk blocks. */ ^
bash-4.2$ gcc read.c -lm
bash-4.2$ gcc read.c -lm -I/usr/src/linux/include/.
bash-4.2$ gcc read.c -lm -I/usr/src/linux/include/.
In file included from /usr/src/linux/include/./linux/kernel.h:6:0,
from read.c:15:
/usr/src/linux/include/./linux/linkage.h:7:25: fatal error: asm/linkage.h: No such file or directory
#include <asm/linkage.h>
^
compilation terminated.
bash-4.2$ gcc read.c -lm -I/usr/src/linux/include/.
In file included from /usr/src/linux/include/./linux/list.h:4:0,
from /usr/src/linux/include/./linux/module.h:9,
from read.c:15:
/usr/src/linux/include/./linux/types.h:14:26: error: conflicting types for ‘fd_set’
typedef __kernel_fd_set fd_set;
^
In file included from /usr/include/sys/types.h:219:0,
from /usr/include/stdlib.h:314,
from read.c:6:
/usr/include/sys/select.h:75:5: note: previous declaration of ‘fd_set’ was here
} fd_set;
^
In file included from /usr/src/linux/include/./linux/list.h:4:0,
from /usr/src/linux/include/./linux/module.h:9,
from read.c:15:
/usr/src/linux/include/./linux/types.h:15:25: error: conflicting types for ‘dev_t’
typedef __kernel_dev_t dev_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:60:17: note: previous declaration of ‘dev_t’ was here
typedef __dev_t dev_t;
^
In file included from /usr/src/linux/include/./linux/list.h:4:0,
from /usr/src/linux/include/./linux/module.h:9,
from read.c:15:
/usr/src/linux/include/./linux/types.h:19:17: error: conflicting types for ‘nlink_t’
typedef __u32 nlink_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:75:19: note: previous declaration of ‘nlink_t’ was here
typedef __nlink_t nlink_t;
^
In file included from /usr/src/linux/include/./linux/list.h:4:0,
from /usr/src/linux/include/./linux/module.h:9,
from read.c:15:
/usr/src/linux/include/./linux/types.h:25:26: error: conflicting types for ‘timer_t’
typedef __kernel_timer_t timer_t;
^
In file included from /usr/include/sys/types.h:132:0,
from /usr/include/stdlib.h:314,
from read.c:6:
/usr/include/time.h:103:19: note: previous declaration of ‘timer_t’ was here
typedef __timer_t timer_t;
^
In file included from /usr/src/linux/include/./linux/list.h:4:0,
from /usr/src/linux/include/./linux/module.h:9,
from read.c:15:
/usr/src/linux/include/./linux/types.h:45:26: error: conflicting types for ‘loff_t’
typedef __kernel_loff_t loff_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:44:18: note: previous declaration of ‘loff_t’ was here
typedef __loff_t loff_t;
^
In file included from /usr/src/linux/include/./linux/list.h:4:0,
from /usr/src/linux/include/./linux/module.h:9,
from read.c:15:
/usr/src/linux/include/./linux/types.h:112:17: error: conflicting types for ‘u_int64_t’
typedef __u64 u_int64_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:203:1: note: previous declaration of ‘u_int64_t’ was here
__u_intN_t (64, __DI__);
^
In file included from /usr/src/linux/include/./linux/list.h:4:0,
from /usr/src/linux/include/./linux/module.h:9,
from read.c:15:
/usr/src/linux/include/./linux/types.h:113:17: error: conflicting types for ‘int64_t’
typedef __s64 int64_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:197:1: note: previous declaration of ‘int64_t’ was here
__intN_t (64, __DI__);
^
In file included from /usr/src/linux/include/./linux/list.h:4:0,
from /usr/src/linux/include/./linux/module.h:9,
from read.c:15:
/usr/src/linux/include/./linux/types.h:134:23: error: conflicting types for ‘blkcnt_t’
typedef unsigned long blkcnt_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:235:20: note: previous declaration of ‘blkcnt_t’ was here
typedef __blkcnt_t blkcnt_t; /* Type to count number of disk blocks. */ ^
In file included from /usr/src/linux/include/./linux/stat.h:5:0,
from /usr/src/linux/include/./linux/module.h:10,
from read.c:15:
/usr/include/asm/stat.h:80:8: error: redefinition of ‘struct stat’
struct stat {
^
In file included from /usr/include/fcntl.h:68:0,
from read.c:12:
/usr/include/bits/stat.h:46:8: note: originally defined here
struct stat
^
/usr/include/asm/stat.h:94:16: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘.’ token
unsigned long st_atime;
^
/usr/include/asm/stat.h:129:16: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘.’ token
unsigned int st_atime;
^
In file included from /usr/src/linux/include/./linux/kernel.h:6:0,
from /usr/src/linux/include/./linux/cache.h:4,
from /usr/src/linux/include/./linux/time.h:4,
from /usr/src/linux/include/./linux/stat.h:18,
from /usr/src/linux/include/./linux/module.h:10,
from read.c:15:
/usr/src/linux/include/./linux/linkage.h:7:25: fatal error: asm/linkage.h: No such file or directory
#include <asm/linkage.h>
^
compilation terminated.
bash-4.2$ gcc read.c -lm -I/usr/src/linux/include/.
In file included from /usr/src/linux/include/./linux/crc16.h:18:0,
from read.c:15:
/usr/src/linux/include/./linux/types.h:14:26: error: conflicting types for ‘fd_set’
typedef __kernel_fd_set fd_set;
^
In file included from /usr/include/sys/types.h:219:0,
from /usr/include/stdlib.h:314,
from read.c:6:
/usr/include/sys/select.h:75:5: note: previous declaration of ‘fd_set’ was here
} fd_set;
^
In file included from /usr/src/linux/include/./linux/crc16.h:18:0,
from read.c:15:
/usr/src/linux/include/./linux/types.h:15:25: error: conflicting types for ‘dev_t’
typedef __kernel_dev_t dev_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:60:17: note: previous declaration of ‘dev_t’ was here
typedef __dev_t dev_t;
^
In file included from /usr/src/linux/include/./linux/crc16.h:18:0,
from read.c:15:
/usr/src/linux/include/./linux/types.h:19:17: error: conflicting types for ‘nlink_t’
typedef __u32 nlink_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:75:19: note: previous declaration of ‘nlink_t’ was here
typedef __nlink_t nlink_t;
^
In file included from /usr/src/linux/include/./linux/crc16.h:18:0,
from read.c:15:
/usr/src/linux/include/./linux/types.h:25:26: error: conflicting types for ‘timer_t’
typedef __kernel_timer_t timer_t;
^
In file included from /usr/include/sys/types.h:132:0,
from /usr/include/stdlib.h:314,
from read.c:6:
/usr/include/time.h:103:19: note: previous declaration of ‘timer_t’ was here
typedef __timer_t timer_t;
^
In file included from /usr/src/linux/include/./linux/crc16.h:18:0,
from read.c:15:
/usr/src/linux/include/./linux/types.h:45:26: error: conflicting types for ‘loff_t’
typedef __kernel_loff_t loff_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:44:18: note: previous declaration of ‘loff_t’ was here
typedef __loff_t loff_t;
^
In file included from /usr/src/linux/include/./linux/crc16.h:18:0,
from read.c:15:
/usr/src/linux/include/./linux/types.h:112:17: error: conflicting types for ‘u_int64_t’
typedef __u64 u_int64_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:203:1: note: previous declaration of ‘u_int64_t’ was here
__u_intN_t (64, __DI__);
^
In file included from /usr/src/linux/include/./linux/crc16.h:18:0,
from read.c:15:
/usr/src/linux/include/./linux/types.h:113:17: error: conflicting types for ‘int64_t’
typedef __s64 int64_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:197:1: note: previous declaration of ‘int64_t’ was here
__intN_t (64, __DI__);
^
In file included from /usr/src/linux/include/./linux/crc16.h:18:0,
from read.c:15:
/usr/src/linux/include/./linux/types.h:134:23: error: conflicting types for ‘blkcnt_t’
typedef unsigned long blkcnt_t;
^
In file included from /usr/include/stdlib.h:314:0,
from read.c:6:
/usr/include/sys/types.h:235:20: note: previous declaration of ‘blkcnt_t’ was here
typedef __blkcnt_t blkcnt_t; /* Type to count number of disk blocks. */
My question is, how to compile Linux C libraries?
The library you’ve added has conflicting settings for something you already use. That’s what your error messages say
– Leonardo Alves Machado
Are you developing for the kernel? Are you sure you can use the standard library in this case? Isn’t it subject to a reduced subset of functions? I ask this because the definitions in
crc16.h
(definingdev_t
as__kernel_dev_t
, contrary to thestblib.h
definingdev_t
as__dev_t
)– Jefferson Quesado