体系结构x86_64的未定义符号
Undefined Symbol(s) for architecture x86_64
所以我已经浏览了一段时间来弄清楚这是怎么回事,但很多时候是因为程序缺少main
或其他东西,但我的程序有所有需要的方法。
#include <iostream>
#include <string>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int my_int;
bool isPalimdrome(int);
bool isBinaryPalimdrom(std::string);
std::string base10To2(int);
std::string reverse(std::string);
int main() {
int num = 0;
int sum = 0;
while (num < 1000000) {
std::string num_bin = base10To2(num);
if (isPalimdrome(num) && isBinaryPalimdrom(num_bin) ){
sum += num;
}
num++;
}
return 0;
}
bool isPalimdrome(int x) {
std::ostringstream strs;
strs << x;
const std::string ori = strs.str();
const std::string rev = reverse(ori);
if (rev.compare(ori) == 0) return true;
return false;
}
bool isBinaryPalimdrome(std::string s) {
const std::string ori = s;
const std::string rev = reverse(ori);
if (rev.compare(ori) == 0) return true;
return false;
}
std::string base10To2(int x) {
std::string out = "";
while (x != 0) {
if (x % 2 == 0)
out += "0";
else
out += "1";
x /= 2;
}
return out;
}
std::string reverse(std::string s) {
std::string result = "";
for (const char& x : s) {
result = x + result;
}
//std::cout << "This is the original " <<
// s << std::endl;
//std::cout << "This is the reversed " <<
// result << std::endl;
return result;
}
我发布了完整的代码以防万一,但我相信它与我的isBinaryPalimdrome()
函数有关,这是我得到的错误:
Undefined symbols for architecture x86_64:
"isBinaryPalimdrom(std::string)", referenced from:
_main in Problem36-cae975.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Problem36] Error 1
我在Mac上编程,如果有关系的话。
我猜是打字错误造成了疼痛:你宣称:
bool isBinaryPalimdrom(std::string);
但是你定义了
bool isBinaryPalimdrome(std::string s)
// ^
相关文章:
- 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()",引用自: