2

Estou desenvolvendo um software em C que recebe uma informação e preciso verificar se a mesma esta correta através de um CRC-16, pesquisando encontrei uma lib só para CRC chamada libcrc.org mas também encontrei algo no linux e gostaria de usar o que é nativo já que estou desenvolvendo e o software será rodado no linux.

Minha dúvida é, inclui no meu fonte o hearder file mas recebi uma dezena de erros, acredito que deva estar faltando algo no gcc, segue:

$ 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.  */

Minha pergunta é, como compilar bibliotecas em C do Linux?

2
  • 1
    A biblioteca que adicionaste está com definições conflitantes com algo que tu já usas. É isso que dizem tuas mensagens de erro Commented 6/03/2018 às 20:22
  • 1
    Você está desenvolvendo para o kernel? Tem certeza que nesse caso você pode usar a biblioteca padrão? Não está sujeito a um subconjunto reduzido de funções? Pergunto isso porque entrou em choque as definições em crc16.h (que define dev_t como __kernel_dev_t, contrário da stblib.h que define dev_t como __dev_t) Commented 7/03/2018 às 11:40

1 Resposta 1

1

Parece que você usou include de bibliotecas que definem os mesmos símbolos. Procure em quais arquivos a função fd_set está definida para ter uma ideia de quem são os candidatos ao conflito.

Além disso, o melhor é você usar uma ferramenta de build tal como make ou a mais moderna CMake. Gerenciar a construção da aplicação manualmente não é um caminho razoável porque você vai acabar tendo mais dependências e isso vai dificultar muito.

1
  • Isso explica o conflito de tipos, mas ainda tem mais coisa por baixo, como a aparente falta de configurar diretório de inclusão através do -I (traço i-maiúsculo) Commented 7/03/2018 às 11:35

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .