苹果Mach O连接器错误
Apple Mach O Linker error?
#include <iostream>
#include <cctype>
#include <string>
using namespace std;
int main()
{
string text;
string numbers;
string characters;
string spaces;
getline(cin, text);
int i;
for (i=0; i<text.length(); i++)
{
if (isalpha(text[i]))
{
characters += text[i];
}
else if (isdigit(text[i]))
{
numbers +=text[i];
}
else
{
spaces +=text[i];
}
}
cout<<"Numbers in the string: "<<numbers<<endl
<<"Alphabets in the string: "<<characters<<endl
<<"Spaces in the string: "<<spaces.length()<<endl<<endl;
string searchstr;
string replacestr;
double n = text.length();
cout<<"Enter a word to search: "<<endl;
getline(cin, searchstr);
cout<<"Enter a replacement word: "<<endl;
getline (cin, replacestr);
double position = text.find(searchstr, 0);
text.replace (position, n, replacestr);
cout<<"Replaced string is: "<<endl
<<text<<endl<<endl;
return 0;
}
我不知道这是怎么回事。这与正在使用的库有关吗?
Error:
Ld "/Users/andy/Library/Developer/Xcode/DerivedData/Project_4-fgfiiphpwijunsfidkthbsqbxgvb/Build/Products/Debug/Project 4" normal x86_64
cd "/Users/andy/Desktop/EECS138/Project 4"
setenv MACOSX_DEPLOYMENT_TARGET 10.8
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Users/andy/Library/Developer/Xcode/DerivedData/Project_4-fgfiiphpwijunsfidkthbsqbxgvb/Build/Products/Debug -F/Users/andy/Library/Developer/Xcode/DerivedData/Project_4-fgfiiphpwijunsfidkthbsqbxgvb/Build/Products/Debug -filelist "/Users/andy/Library/Developer/Xcode/DerivedData/Project_4-fgfiiphpwijunsfidkthbsqbxgvb/Build/Intermediates/Project 4.build/Debug/Project 4.build/Objects-normal/x86_64/Project 4.LinkFileList" -mmacosx-version-min=10.8 -stdlib=libc++ -o "/Users/andy/Library/Developer/Xcode/DerivedData/Project_4-fgfiiphpwijunsfidkthbsqbxgvb/Build/Products/Debug/Project 4"
duplicate symbol _main in:
/Users/andy/Library/Developer/Xcode/DerivedData/Project_4-fgfiiphpwijunsfidkthbsqbxgvb/Build/Intermediates/Project 4.build/Debug/Project 4.build/Objects-normal/x86_64/main.o
/Users/andy/Library/Developer/Xcode/DerivedData/Project_4-fgfiiphpwijunsfidkthbsqbxgvb/Build/Intermediates/Project 4.build/Debug/Project 4.build/Objects-normal/x86_64/File.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation
不知道为什么Xcode不能构建/运行程序,它在CodeBlocks中工作得很好。有什么帮助,为什么它给我这个错误?
从您的错误中,似乎您有一个文件main
和另一个文件File
, 都定义了main()
函数。
main()
是程序的入口点。不能为程序的开始定义两个不同的函数
相关文章:
- MySQL C++连接器链接错误
- Visual Studio 2017 中的 MySQL 连接器/C++ 错误"Unresolved external symbol _get_driver_instance"
- 循环中的MySQL连接器/C 错误
- MySQL C++连接器程序抛出错误 15
- MySQL 连接器错误,将代码从 Java 转换为 C++
- 从源代码构建 MySQL 连接器/C++(找不到 Boost 库错误)
- "int8_t":尝试将MySQL CPP连接器连接到Visual Studio 2010时Config.h中的重新定义错误
- Mysql c++ 连接器错误
- MySQL / C ++连接器错误:使用旧的(4.1.1之前)身份验证协议的连接被拒绝
- MySQL / C ++连接器错误:libmysqlcppconn.so.7:无法打开Sahred目标文件:没有这样的文
- 连接器/C++-必要的库+错误
- MySQL C++连接器MySQL_Prepared_Statement::getUpdateCount错误
- mysql c++连接器错误:连接器命令失败,退出代码为1
- MySQL:"Commands out of Sync"错误(C 连接器)
- Boost 1.59连接器错误
- 使Boost连接器错误
- Eclipse CDT中的POSIX IPC连接器错误
- 苹果Mach O连接器错误
- c++ MySQL连接器链接错误
- 编译mysql连接器c++与mingw,编译错误