C++体系结构x86_64的未定义符号
C++ Undefined symbols for architecture x86_64
我是c++的新手,正试图将文本保存到文本文件中。然而,当我运行该程序时,我一直从eclipse中得到这个错误,并且无法弄清楚出了什么问题:
Undefined symbols for architecture x86_64:
"StorageSave::execute(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
_main in SpendTracker.o
这是我的代码:
StorageSave.h:
#include <fstream>
#include <string>
#include <vector>
#include "Account/Account.h"
#ifndef STORAGE_STORAGESAVE_H_
#define STORAGE_STORAGESAVE_H_
class StorageSave {
public:
StorageSave();
virtual ~StorageSave();
std::string execute(std::string allData);
};
#endif /* STORAGE_STORAGESAVE_H_ */
StorageSave.cpp:
#include <iostream>
#include <fstream>
#include "StorageSave.h"
StorageSave::StorageSave() {
// TODO Auto-generated constructor stub
}
StorageSave::~StorageSave() {
// TODO Auto-generated destructor stub
}
std::string execute(std::string allData) {
std::ofstream file("hey.txt");
//std::ofstream *fileptr = &file;
if(!file.is_open()) {
std::cout << "Unable to open file." << std::endl;
} else {
std::string textData = "test";
file << textData;
file.close();
}
return "";
}
我认为你应该打开
std::string execute(std::string allData) {
进入
std::string StorageSave::execute(std::string allData) {
您使用execute作为成员函数并声明了它,但它被实现为自由函数
相关文章:
- vscode g++链路故障:体系结构x86_64的未定义符号
- 体系结构x86_64的未定义符号:std:terminate(),typeinfo,运算符delete[],运算符new
- C++ 中 dlsym 的未定义符号
- 仅在 MacOS 上析构函数的未定义符号
- OSX clang++:用于 cpp 文件中显式实例化模板的体系结构x86_64的未定义符号
- PCL 出错:体系结构x86_64 @pcl的未定义符号
- clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用) - 体系结构的未定义符号 x86_64:
- 体系结构x86_64的未定义符号:链接器错误
- C++ std::vector<int> 体系结构的未定义符号 x86_64:
- 生成文件:体系结构x86_64的未定义符号
- libc++abi未定义符号:_ZTVN10__cxxabif120__si-class_type_infoE
- Xcode"体系结构x86_64的未定义符号"
- 体系结构x86_64的未定义符号:找不到原因
- SWIG链接器:未定义符号:_ZN2cv8fastFreeEPv(cv::fastFree(void*))
- 如何修复架构x86_64的未定义符号,Boost Asio 1.58
- 在Qt5上去静态库:架构的未定义符号x86_64:
- 体系结构x86_64的未定义符号:c++/ h 文件和 cpp 文件
- 监视 SDK 下的未定义符号"__Unwind_SjLj_Unregister"
- 使用 Boost/Python 的未定义符号 - 复杂
- 建筑x86_64的未定义符号:"vtkDebugLeaksManager::vtkDebugLeaksManager()",引用自: