编译问题汇总¶
1 gcc¶
1.1 “'xxx' 不是一个类型名”¶
- 分析:此类错误就是编译器并没有找到 "xxx" 类的定义
- 原因:
- 没有包含头文件
- 多个文件中使用了相同的防止头文件重复包含的宏,导致某个头文件没有被包含进来
1.2 "error: implicit declaration of function"¶
- 错误如下
/root/nfs-ganesha/src/libntirpc/src/work_pool.c:301:3: error: implicit declaration of function ‘assert’ [-Werror=implicit-function-declaration]
assert(!wpt->wakeup);
- 原因:c++ 编译器默认开启了
-Werror=implicit-function-declaration
选项,当使用一个没用提前声明的方法时报错。 - 解决办法:头文件包含这个方法声明的问题。
1.3 错误:‘xxx’的声明指定了两个以上的数据类型¶
- 原因:在定义枚举或结构体、类时结尾没有加分号
;
。
1.4 error: multi-line comment¶
原因是宏定义非一行,在宏定义的行尾使用 \
连接符导致的。这时不能使用单行注释 //
,而要使用使用多行注释 /* */
。
- 示例
/*#define ATTR_MASK (BASIC_STATS | \
BTIME |\
VERSION)
*/
2 make¶
2.1 unable to guess system type¶
checking build system type... libltdl/config/config.guess: unable to guess system type
This script, last modified 2008-01-23, has failed to recognize
the operating system you are using. It is advised that you
download the most up to date version of the config scripts from
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
and
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
If the version you run (libltdl/config/config.guess) is already up to date, please
send the following data and any information you think might be
pertinent to <config-patches@gnu.org> in order to provide the needed
information to handle your system.
config.guess timestamp = 2008-01-23
uname -m = aarch64
uname -r = 4.19.90-2107.6.0.0098.oe1.bclinux.aarch64
uname -s = Linux
uname -v = #1 SMP Wed Sep 1 23:13:50 EDT 2021
/usr/bin/uname -p = aarch64
/bin/uname -X =
hostinfo =
/bin/universe =
/usr/bin/arch -k =
/bin/arch = aarch64
/usr/bin/oslevel =
/usr/convex/getsysinfo =
UNAME_MACHINE = aarch64
UNAME_RELEASE = 4.19.90-2107.6.0.0098.oe1.bclinux.aarch64
UNAME_SYSTEM = Linux
UNAME_VERSION = #1 SMP Wed Sep 1 23:13:50 EDT 2021
configure: error: cannot guess build type; you must specify one
出现这种问题的原因是识别不出系统架构类型,这时需要更新 2 个文件 config.guess 和 config.sub
下载地址:
- http://git.savannah.gnu.org/gitweb/?p=config.git ;a=blob_plain;f=config.guess;hb=HEAD
- http://git.savannah.gnu.org/gitweb/?p=config.git ;a=blob_plain;f=config.sub;hb=HEAD
从上面地址下载后替换项目下同名文件,再重新编译。