banana.cpp: In function ‘int uosaarch_line_parse(char*)’: banana.cpp:70:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ /usr/bin/ld: /tmp/ccljSzhB.o: in function `__static_initialization_and_destruction_0(int, int)': banana.cpp:(.text+0x1c0): undefined reference to `std::ios_base::Init::Init()' /usr/bin/ld: banana.cpp:(.text+0x1d4): undefined reference to `std::ios_base::Init::~Init()' /usr/bin/ld: banana.cpp:(.text+0x1d8): undefined reference to `std::ios_base::Init::~Init()' collect2: error: ld returned 1 exit status
时间: 2024-04-18 13:30:40 浏览: 33
这些错误和警告都是关于在编译和链接过程中出现的问题。
1. "control reaches end of non-void function [-Wreturn-type]" 是一个警告,意思是在一个非 void 类型的函数中,函数的结尾没有返回值。编译器会发出这个警告,因为这可能会导致未定义的行为。你可以通过在函数的结尾添加一个返回语句来解决这个问题。
2. "/usr/bin/ld: undefined reference to 'std::ios_base::Init::Init()'" 和 "/usr/bin/ld: undefined reference to 'std::ios_base::Init::~Init()'" 是链接错误,意思是在链接时找不到对应的符号。这通常是因为你在代码中使用了某些需要链接的标准库函数或对象,但没有正确链接这些库。你需要确保在编译和链接时正确地指定需要链接的标准库。
3. "collect2: error: ld returned 1 exit status" 是链接器返回的错误状态码。它表示在链接过程中发生了错误。要解决这个问题,你需要检查你的代码和编译选项,并确保正确地链接所有需要的库。
综上所述,你需要注意解决函数返回值问题,并检查你的编译和链接过程,确保正确地链接所需的库。
相关问题
warning: ‘struct rev’ declared inside parameter list will not be visible outside of this definition or declaration 54 | int parse_1_REGISTER(struct rev *parse_msg,char * message) | ^~~ sip.c: In function ‘parse_1_REGISTER’: sip.c:77:14: error: dereferencing pointer to incomplete type ‘struct rev’ 77 | parse_msg->server_id = strtok(NULL, "@");啥意思
这个错误提示是因为在函数参数列表中声明了一个结构体指针类型的参数 struct rev *parse_msg,但是编译器并没有找到这个结构体的定义。这通常是因为在当前文件中没有定义这个结构体,或者是因为这个结构体定义在其他文件中,但是当前文件没有包含其头文件。
在函数中的这行代码 parse_msg->server_id = strtok(NULL, "@"); 的意思是使用指针 parse_msg 所指向的结构体变量的 server_id 成员变量来存储 strtok 函数的返回值。但是,由于编译器无法确定结构体的大小和成员变量的偏移量,所以无法正确解析这行代码。
要解决这个问题,你需要在当前文件中或者在头文件中定义 struct rev 结构体,并确保在使用这个结构体之前进行了声明或者包含了其头文件。
gcc cJSON.c json.c -o j /usr/bin/ld: /tmp/ccwuW79V.o: in function `parse_number': cJSON.c:(.text+0x4c5): undefined reference to `pow' /usr/bin/ld: /tmp/ccwuW79V.o: in function `print_number': cJSON.c:(.text+0x833): undefined reference to `floor' collect2: error: ld returned 1 exit status这是为啥
这个错误的原因是编译器找不到函数pow()和floor()的定义。 pow()函数用于计算幂次方,floor()函数用于向下取整。
解决这个问题,您需要在编译命令中链接数学库(libm)。您可以尝试以下命令:
```
gcc cJSON.c json.c -o j -lm
```
其中,"-lm"参数会链接数学库,这样就可以解决pow()和floor()函数未定义的问题。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)