一、错误信息
warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 2 has type ‘__time_t’ [-Wformat=] printf("time %u:%u\n",tv.tv_sec,tv.tv_usec);warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘__suseconds_t’ [-Wformat=]
开始的时候没有注意到错误信息最后的[-Wformat=]提醒,一直以为是类型匹配错了,把%u改成了%llu仍旧是不行。最后才注意到提醒。 然后在Ubuntu官网找到了原因: NOTE: In Ubuntu 8.10 and later versions this option is enabled by default for C, C++, ObjC, ObjC++. To disable, use -Wformat=0. 然后在编译的时候改成了:gcc test.c -Wformat=0 就没问题了。Wformat这个配置在Centos下默认是关闭的,所以一直没报错,如果编译的时候打开,也会提示一样的错误。 看来不同的平台,很多默认的设置还是不一样的。 Ubuntu官网的解释:http://manpages.ubuntu.com/manpages/oneiric/en/man1/gcc.1.html
二、错误:
dso.o:在函数‘dso_load(char const*, char const*)’中:
dso.cpp:(.text+0x3c):对‘dlopen’未定义的引用
dso.cpp:(.text+0x4c):对‘dlsym’未定义的引用
dso.cpp:(.text+0xb5):对‘dlerror’未定义的引用
dso.cpp:(.text+0x13e):对‘dlclose’未定义的引用
编译c ,如果引用了.o文件,多个.o文件吧,不能直接运行gcc demo.c -o demo,需要分步骤进行
以下是解决方案:
(在多个.o的地方运行 gcc demo1.o demo2.0 -o demo)
https://jingyan.baidu.com/article/d5a880eb8fa71d13f147cc88.html
http://blog.csdn.net/qq_29350001/article/details/53339861
我是小白,在开发科大讯飞语音唤醒的时候学习到的