编译器/链接器错误
Compiler/linker error
我正在尝试使我的程序起作用(与以前的程序不同),而我仍然会收到一些编译器/链接器错误,我不知道如何解决,任何人都可以指导我一些解决方案修复链接器/编译器或其他内容?
这是构建日志IM获取:
-------------- Build: Debug in lab1hwfinal (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -Wall -fexceptions -g -I..Documents -c
C:UsersDekkillerDocumentslab1hwfinalmain.cpp -o objDebuglab1hwfinalmain.o
C:UsersDekkillerDocumentslab1hwfinalmain.cpp: In function 'int main()':
C:UsersDekkillerDocumentslab1hwfinalmain.cpp:19:5: error: 'complexType' was not
declared in this scope
complexType sum;
^
C:UsersDekkillerDocumentslab1hwfinalmain.cpp:19:17: error: expected ';' before
'sum'
complexType sum;
^
C:UsersDekkillerDocumentslab1hwfinalmain.cpp:26:15: error: 'exit' was not declared
in this scope
exit(1);
^
C:UsersDekkillerDocumentslab1hwfinalmain.cpp:45:38: error: 'atof' was not declared
in this scope
realpart= atof(strone.c_str());
^
C:UsersDekkillerDocumentslab1hwfinalmain.cpp:48:21: error: expected ';' before
'outpobj'
complexType outpobj(realpart, imaginarypart);
^
C:UsersDekkillerDocumentslab1hwfinalmain.cpp:51:54: error: 'outpobj' was not
declared in this scope
outputfile << "Object " << counter << "-" << outpobj << endl;
^
Process terminated with status 1 (0 minute(s), 0 second(s))
6 error(s), 0 warning(s) (0 minute(s), 0 second(s))
这是我的主要文件:
#include "Complex.h"
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
ofstream outputfile;
ifstream inputfile;
string str;
double realpart;
double imaginarypart;
int symbol;
char ch;
string strone;
string strtwo;
complexType sum;
int counter = 0;
inputfile.open("complex.txt");
if(inputfile.fail())
{
cout << "File opening failed." << endl;
exit(1);
}
outputfile.open("complexObj.txt");
inputfile >> str;
while(inputfile)
{
symbol=str.find("+");
ch = '+';
if(symbol < 0)
{
symbol = str.find("-");
ch = '-';
}
stringstream streamin(str);
getline(streamin, strone, ch);
getline(streamin, strtwo, 'i');
realpart= atof(strone.c_str());
imaginarypart= atof(strtwo.c_str());
complexType outpobj(realpart, imaginarypart);
counter++;
outputfile << "Object " << counter << "-" << outpobj << endl;
inputfile.close();
outputfile.close();
return 0;
}
}
我的标题类文件:
#ifndef COMPLEX_H
#define COMPLEX_H
#include <iostream>
class complexType
{
friend std::ostream& operator<<(std::ostream& os, const complexType& obj);
public:
complexType();
complexType(double r, double i);
complexType operator+(const complexType& objtwo);
private:
double real;
double imagine;
};
#endif // COMPLEX_H
这是我的类CPP文件:
#include "Complex.h"
#include <iostream>
using namespace std;
complexType::complexType()
{
real=0;
imagine=0;
}
complexType::complexType(double r, double i)
{
real=r;
imagine=i;
}
ostream& operator<<(ostream& os, const complexType& obj)
{
os << obj.real << "," << obj.imagine;
return os;
}
complexType complexType::operator+(const complexType& objtwo)
{
complexType sum;
sum.real = real + objtwo.real;
sum.imagine = imagine + objtwo.imagine;
return sum;
}
我很抱歉问了这样的类似问题,但我无法弄清楚我的链接器或编译器有什么问题。
我觉得像复杂。h是一个保留的名称。尝试重命名您的标题,并且应该起作用。
http://pubs.opengroup.org/onlinepubs/79999959899/basedefs/complex.h.html
相关文章:
- Netbeans 10:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
- CMake 错误:链接器命令失败,退出代码为 1 和 cpp.o 文件
- clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用) - 体系结构的未定义符号 x86_64:
- 如何修复 clang: 错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
- Android NDK.Build命令失败.未定义的引用.clang++:错误:链接器命令失败,退出代码为1
- 使用cmake错误链接boost日志
- 错误:链接器命令失败,退出代码为 1(使用 -v 查看调用):在 Macbook 上
- C++ XCODE ld:找不到体系结构x86_64 clang 的符号:错误:链接器命令失败,退出代码为 1(使用 -
- clang:错误:链接器命令失败,C++代码中的退出代码为 1(使用 -v 查看调用)
- 静态库中的 g++ 错误链接函数
- 未定义的参考错误链接天然函数Android
- C++编译错误:ld:找不到体系结构x86_64 clang 的符号:错误:链接器命令失败,退出代码为 1(使用 -v
- QT Q_PROPERTY错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
- ld:找不到体系结构x86_64 clang 的符号:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
- OSX MOJAVE -LD:架构X86_64 clang找不到符号:错误:链接器命令失败,出口代码1
- C 错误链接器命令失败了出口代码1(使用-V查看调用)
- LD:架构x86_64 clang找不到符号:错误:链接器命令失败,出口代码1(使用-v to See
- 聚输出错误 - 链接列表
- Xcode链接器错误:链接器命令失败,退出代码为1(使用-v查看调用)
- 尝试构建C DLIB示例无法与数百个未定义的参考错误链接