我已经为我的树莓派设置了一个交叉编译器,我在这里找到的那个:Installing Raspberry Pi Cross-Compiler
现在一切正常,直到我想使用 I2c 库 (i2c-dev.h)。
用arm-linux-gnueabihf-g++编译器编译下面的代码时,报错:
In file included from src/I2c.cpp:8:0:
src/../Include/I2c.h:29:18: error: field ‘message’ has incomplete type
struct i2c_msg message;
^
与此同时,当我在 raspi 上编译代码时,它只是运行。
#ifndef I2C_H_
#define I2C_H_
#include <linux/i2c-dev.h> // Defines i2c_msg
#include ...
using namespace std;
typedef struct {
struct i2c_msg message;
void (*callback)(int);
int messageID;
} t_msgQueue;
关于可能的原因的任何想法,或者关于如何使交叉编译器正常工作的解决方案?
最佳答案
我的第一个怀疑是 RPi 和交叉编译器之间的 GCC 版本不同;众所周知,GCC 会随着时间的推移改变它处理#include 语句的方式。
除非存在版本差异,否则请检查以确保主机包含文件未在某处意外获取。
关于c++ - 交叉编译器 raspberry pi 不完整类型,而 native 编译器工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45536409/