0

Compiling a simple C++ Hello World program from windows terminal by: g++ main.cpp gives this error:

d:/softwares/mingw/bin/...../x86_64-w64-mingw32/bin/ld.exe: cannot find -lstdc++
d:/softwares/mingw/bin/...../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc_s
d:/softwares/mingw/bin/...../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc_s
collect2.exe: error: ld returned 1 exit status

The c++ program:

#include <iostream>

int main()
{
    std::cout << "Hello C++!\n";
    return 0;
}

MinGW path is set up on windows

Al-Jaabir
  • 19
  • 4
  • 1
    Looks like a broken compiler installation, or several conflicting installations. I'd remove all of them and install the one from here: https://stackoverflow.com/q/30069830/2752075 – HolyBlackCat Feb 27 '22 at 16:24
  • I agree remove the broken most likely older version of mingw and install the current one using msys2. – drescherjm Feb 27 '22 at 16:27
  • Thanks for help, I reinstalled from above link and it is working fine now. – Al-Jaabir Feb 28 '22 at 07:57

1 Answers1

0

Try using g++ as linker instead of ld.

Brecht Sanders
  • 6,215
  • 1
  • 16
  • 40