collect2.exe:错误:1d返回1退出状态

时间:2021-01-26 18:34:19

I am coding in c++ on SublimeText3 and using the command window in the folder to manually compile it and run it but when i try compile it using

我在SublimeText3上使用c ++进行编码,并使用文件夹中的命令窗口手动编译并运行它,但是当我尝试使用它编译时

g++ -Wall -pedantic -std=c++11 TheThirdTask.cpp -o TheThirdTask 

(TheThirdTask.cpp is the name of the file, see code below) it comes up with

(TheThirdTask.cpp是文件的名称,见下面的代码)它出现了

c:/mingnw/bin/../lib/gcc/mingw32/5.3.0/../../../libmmingwex.a(vsnprintf.o):(.text+0x0): multiple definition of ʽvsnprintf'
C:\Users\Sam\AppData\Local\Temp\cc5MFRJe.o:TheThirdTask.cpp:(.text$vsnprintf[_vsnprintf]+0x0): first defined here
collect2.exe: error: 1d returned 1 exit status

I am fairly new to coding, I only started when I started varsity at the beginning of the year so I have no idea what it is tell me. Please help, this is for a very important assignment.

我对编码很新,我只是在年初开始校队时开始,所以我不知道它是什么告诉我的。请帮忙,这是一项非常重要的任务。

TheThirdTask.cpp code:

#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(){
    int b;
    int val;
    int rem;
    int currentVal;
    string result;

    cin >> b;
    cin >> val;

    while(val != -1){   
        currentVal = val;

        do{

             rem = currentVal%b;

            if(rem > 9){
                char c = rem;
                c = c + 55;

                result = c + result;
                currentVal = floor(currentVal/b);
            }
            else{
                result = to_string(rem) + result;
                currentVal = floor(currentVal/b);
            }

        }while(currentVal != 0);

        cout << result << endl;
        cin >> val;
        rem = 0;
        currentVal = 0;
        result = "";
    }
    return 0;
}

1 个解决方案

#1


0  

how about trying out 2 separate commands

如何尝试2个单独的命令

try

g++ -Wall -c TheThirdTask.cpp

and then

g++ TheThirdTask.o

The above steps should create a binary with the default name

上述步骤应创建具有默认名称的二进制文件

or just go with

或者只是去

g++ -o YourBinaryName TheThirdTask.cpp

for C++ 11

对于C ++ 11

$ g++ -g -std=c++11 -Wall -pedantic TheThirdTask.cpp -o mybinary

#1


0  

how about trying out 2 separate commands

如何尝试2个单独的命令

try

g++ -Wall -c TheThirdTask.cpp

and then

g++ TheThirdTask.o

The above steps should create a binary with the default name

上述步骤应创建具有默认名称的二进制文件

or just go with

或者只是去

g++ -o YourBinaryName TheThirdTask.cpp

for C++ 11

对于C ++ 11

$ g++ -g -std=c++11 -Wall -pedantic TheThirdTask.cpp -o mybinary