目录
错误一:
这样表示着某个源文件中的函数没有申明便引用???
解决办法:加上那个源文件(含路径)。
g++ ./src/*.cpp -o link -I ./inc/ /usr/bin/ld: /tmp/ccr6ZgbQ.o: in function `main': main.cpp:(.text+0x35): undefined reference to `List<int>::list_insert_head(int)' /usr/bin/ld: main.cpp:(.text+0x46): undefined reference to `List<int>::list_insert_head(int)' /usr/bin/ld: main.cpp:(.text+0x57): undefined reference to `List<int>::list_insert_head(int)' /usr/bin/ld: main.cpp:(.text+0x68): undefined reference to `List<int>::list_insert_head(int)' /usr/bin/ld: main.cpp:(.text+0x79): undefined reference to `List<int>::list_insert_head(int)' /usr/bin/ld: /tmp/ccr6ZgbQ.o:main.cpp:(.text+0x8a): more undefined references to `List<int>::list_insert_head(int)' follow /usr/bin/ld: /tmp/ccr6ZgbQ.o: in function `main': main.cpp:(.text+0xda): undefined reference to `List<int>::list_show()' /usr/bin/ld: main.cpp:(.text+0xeb): undefined reference to `List<int>::list_delete_data(int)' /usr/bin/ld: main.cpp:(.text+0xf7): undefined reference to `List<int>::list_show()' collect2: error: ld returned 1 exit status make: *** [makefile:2:all] 错误 1 h@ubuntu:/mnt/U_share/caogao/c++/8.10/list$ make g++ ./src/*.cpp -o link -I ./inc/ h@ubuntu:/mnt/U_share/caogao/c++/8.10/list$ ./link 12 12 16 12 14 12 15 13 12 12 16 14 15 13
8 #include "linklist.h" 9 //#include "linklist.cpp" //解开这个源文件的声明便可解决 10 int main(void)
错误二:
内存不足:
delete: out of memory
=============leading_in words===========
sockfd:4
server init and start success.
xxxxxxxxx
yyyyyyyy===================================
未定义唯一标识符,并对其进行传参
备注:也可以不进行传参,对函数内打开,关闭,比如read、write、一个函数内打开后再关闭
====================================
sockfd:4
server init and start success.
xxxxxxxxx
yyyyyyyy
0x7f6dfc000b68
错误三:
main.c: In function ‘staff_register’: main.c:10:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token 10 | { | ^ In file included from main.c:7: sql.h:65:5: error: old-style parameter declarations in prototyped function definition 65 | int staff_register(sqlite3 *db, const char *name) | ^~~~~~~~~~~~~~ main.c:26: error: expected ‘{’ at end of input 26 | } |
staff_register函数后面没有加分号
错误四:
gcc *.c -lsqlite3 -lpthread /usr/bin/ld: /tmp/ccc5SRsd.o: in function `main': mmm.c:(.text+0x0): multiple definition of `main'; /tmp/ccknllra.o:main.c:(.text+0x0): first defined here collect2: error: ld returned 1 exit status make: *** [makefile:2:all] 错误 1
有两个main函数,去掉一个