Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-4-20250514· AnthropicHugging Face LMArena Human Preference 140K

0/10 /tmp/ccQSriTR.o: In function main': function.cpp:(.text+0x0): multiple definition…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with DeepSeekdeepseek-r1-0528’s answer.
  1. User

    0/10 /tmp/ccQSriTR.o: In function main': function.cpp:(.text+0x0): multiple definition of main' /tmp/ccCZH5hD.o:fun.cpp:(.text+0x63): first defined here collect2: error: ld returned 1 exit status 用中文回答我

  2. Claude Assistant

    这个错误是因为你在多个文件中都定义了 main 函数。链接器发现了重复的 main 函数定义,所以报错了。

    从错误信息可以看出:

    • function.cpp 文件中有一个 main 函数
    • fun.cpp 文件中也有一个 main 函数

    解决方法:

    1. 删除其中一个 main 函数 - 通常一个程序只需要一个 main 函数作为程序入口点
    2. 重命名其中一个函数 - 如果两个函数都需要保留,可以把其中一个改名为其他函数名
    3. 分别编译 - 如果这两个文件是独立的程序,应该分别编译它们,而不是一起编译

    例如,如果要分别编译:

    g++ function.cpp -o function
    g++ fun.cpp -o fun
    

    检查一下你的代码,确保只有一个文件包含 main 函数,或者根据你的需求调整编译方式。

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.