对“xxx”的未定义引用:

目录

错误一:

错误二:

错误三:

错误四:


 

错误一:

这样表示着某个源文件中的函数没有申明便引用???

解决办法:加上那个源文件(含路径)。

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函数,去掉一个

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
TypeError: Cannot read properties of undefined (reading 'xxx') 是一种常见的错误类型,通常表示在访问一个未定义的属性时出现了问题。这个错误可能由多种原因引起,以下是一些可能的原因和解决方法: 1. 对象属性不存在:当你尝试访问一个对象的属性时,如果该属性不存在,就会出现这个错误。要解决这个问题,你可以先检查对象是否存在该属性,可以使用`hasOwnProperty`方法来检查对象是否拥有该属性。 例子:如果你想访问 `student.height.a`,你可以先检查 `student.height` 是否存在,然后再访问 `student.height.a` 属性。 2. 对象未定义:当你尝试访问一个未定义的对象时,就会出现这个错误。要解决这个问题,你可以先确保对象已经正确地初始化或赋值。 例子:在访问 `student.height.a` 之前,你需要先确保 `student` 对象已经被正确地定义和赋值。 3. 引用错误的对象:有时候,你可能会错误地引用了一个不存在的对象或从一个不存在的对象中访问属性。要解决这个问题,你需要检查代码中是否有错误的对象引用,并确保引用的对象是正确的。 例子:如果你想访问 `a.name`,你需要确保 `a` 对象已经正确地定义和赋值。 请根据你的具体情况检查代码并尝试以上解决方法。如果问题仍然存在,请提供更多的代码和错误信息以便我们提供进一步的帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值