错误提示collect2: error: ld returned 1 exit status怎么解决

sevendays sevendays 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
本人做了一个课后练习题 代码如下 编译的时候出现
[jli52@1005-20 chap_7]$ g++ -g struMeth.cpp -o struMeth
/tmp/ccNELBUx.o: In function `main':
/home/122/j/jli52/Documents/chap_7/struMeth.cpp:51: undefined reference to `calculate(box*)'
collect2: error: ld returned 1 exit status
collect2: error: ld returned 1 exit status
哪位大神能给解答一下 谢谢啦
还有一个问题 有个练习题 不太明白 有个结构candyBar 包含三个成员 分别是 名称 重量 和卡路里 要求用new来动态分配数组 而不是声明一个包含三个元素的candyBar数组 我不明白的是 如果是用数组的话 数组只能储存同一个类型的数据 但是这个结构中的数据类型是不同的 如何用数组去储存这些数据



#include<iostream>
#include<cmath>


struct box
{
char maker[40];
float height;
float width;
float length;
float volume;
};


const void show(box info);
box calculate (box *info);




const void show(box info,box info1)
{
using namespace std;
cout<<"The maker of the box is: "<<info1.maker<<endl;
cout<<"The height of the box is: "<<info1.height<<endl;
cout<<"The length of the box is: "<<info1.length<<endl;
cout<<"The volume of the box is: "<<info.volume<<endl;

}


box caculate (box *info)
{
box result;
result.volume=info->height*info->length*info->width;
return result;
}


int main()
{
using namespace std;
box info;
box result;
cout<<"Please enter the maker, height, width, and length of the box respectly"
<<endl;
cin.getline(info.maker,40);
cin>>info.height;
cin>>info.width;
cin>>info.length;
result=calculate(&info);
show(result,info);
return 0;
}



...全文

相关推荐

Dev C++编写C-C++程序 出现[Error] ld returned 1 exit status报错分析及解决.doc

Dev C++编写C-C++程序 出现[Error] ld returned 1 exit status报错分析及解决.doc

书博教育

python安装gevent库出现ERROR: Command errored out with exit status 1

今天安装gevent时出现 ERROR: Command errored out with exit status 1,后面还有一堆错误,好像是说“文件”、setup啊之类的,我在网上花了两小时查了很多方法(例如:升级pip、升级setuptool,然而并没用,难受),最后终于找到一个解决我问题的办法。 1、进入https://www.lfd.uci.edu/~gohlke/pythonlibs/,该网址按照首字母排序,找到自己对应的版本下载下来(我是用的3.8,64位,即下面第一个): Gevent: a coroutine-based networking library based o

weixin_38663733

python安装torch时遇到 ERROR: Command errored out with exit status 1:

python安装torch时遇到 ERROR: Command errored out with exit status 1: 之前用pycharm运行github上一个模型时,遇到了import torch失败的问题,而且用pip安装失败。我根据网上的教程我的博客里有详细教程用Anaconda安装了torch,问题确实得到了解决,torch安装成功。紧接着再运行模型时就发现了更多的错误,研究了很久发现是之前安装的torch版本有问题。再用pip安装就出现了上面的错误。 看到出现了这么多乱七八糟的东西就很慌,找了一下午,终于找到了最终的解决方法: 查看自己的python版本 点开自己的pyc

weixin_38626473

keil4 Error: User Command terminated, Exit-Code=1

今天我的朋友用了我发给他的文件后总是显示 Error: User Command terminated, Exit-Code = 1,在我这边又可以显示ok,排查了一下原因和网上的资料之后在这里做一下总结。

weixin_38587005

arduino 针对xp系统Id.exe文件

使用xp系统,在Arduino编译时,经常出现如下的错误: collect2.exe: error: ld returned 5 exit status exit status 1 Id.exe文件,详见如下 https://blog.csdn.net/m0_37738838/article/details/89636787

沸腾石灰
评论 2
收藏 已收藏
分享
返回顶部
sevendays
新手乐园 33,315 成员 41,769 内容