今天port 3.7的代码,make一下600多行出错。想想以前也有过类似现象,还是老老实实把以后编译出错的问题都记录一下吧。
1.error: storage class specified for parameter
函数声明少“;”,(一个分号300多个错误,检查到吐。)
2.make kdi
如果出现奇怪的问题,可尝试clean build.
3./usr/include/libxml2/libxml/parser.h:801:29: error: libxml/encoding.h: No such file or directory
/usr/include/libxml2/libxml/parser.h:802:26: error: libxml/xmlIO.h: No such file or directory
/usr/include/libxml2/libxml/parser.h:813: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
/usr/include/libxml2/libxml/parser.h:815: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’等等
没有链接到库 -I/usr/include/libxml2
4.
while(*s++ = *t++)
;
warning: suggest parentheses around assignment used as truth value
理由:在C语言中,非0即代表TRUE,反之为FALSE。上面的语句以*s的值用于最后的判断。但是由于长期的编程实践告诉我们,人们经常在“=”和“==”的使用上出现手误,所以gcc编译器为此要求我们明确地告诉编译器它是“=”而不是“==”,是故意,而非手误。
既然我们的语句如上所示,并非要用“==”,因此我们只需修改成下列样式即可:
while((*s++ = *t++)) ;
2014.2.8
- gcc -c test.c
- gcc –c main.c
- gcc -o main main.o
- main.o: In function `main':
- main.c:(.text+0x7): undefined reference to `test'
- collect2: ld returned 1 exit status
- gcc -o main main.o test.o
- gcc -o main main.c //缺少test()的实现文件
- gcc -o main main.c test.c //ok,没问题了
- gcc -c test.c
- ar -rc test.a test.o
- gcc -c main.c
- gcc -o main main.o
- /tmp/ccCPA13l.o: In function `main':
- main.c:(.text+0x7): undefined reference to `test'
- collect2: ld returned 1 exit status
- gcc -o main main.o ./test.a //注:./ 是给出了test.a的路径
- gcc -o main main.c ./test.a //同样,如果不加test.a也会报错
- gcc -c func.c
- gcc -c test.c
- gcc -c main.c
- ar –rc func.a func.o
- ar –rc test.a test.o
- gcc -o main main.o test.a
- test.a(test.o): In function `test':
- test.c:(.text+0x13): undefined reference to `func'
- collect2: ld returned 1 exit status
- gcc -o main main.o test.a func.a
- gcc -o main main.o func.a test.a
- test.a(test.o): In function `test':
- test.c:(.text+0x13): undefined reference to `func'
- collect2: ld returned 1 exit status