Why does my C++ program fail with “collect2.exe: error: ld returned 1 exit status” on Windows 11?

0
7
Asked By MellowCedar42 On

I'm writing my first C++ program on Windows 11. The code only includes , prints two messages, and returns 0, so it seems valid. However, every time I compile it, I get this linker error: "ld.exe: .../liblto_plugin.dll: error loading plugin: collect2.exe: error: ld returned 1 exit status." I installed the compiler by following a tutorial, but I'm not sure whether my compiler or linker configuration is correct. What should I check, and what does this error mean?

2 Answers

Answered By PixelHarbor7 On

The C++ code itself looks fine. The line about collect2.exe is only the final summary, so the important part is the earlier error message. In this case, the linker specifically says it could not load liblto_plugin.dll, which points to a compiler installation, environment, or Windows security issue rather than a problem with the program. It would also help to know the exact command you’re using to compile it and which toolchain is installed.

Answered By QuartzMango18 On

This can happen when Windows security blocks one of the compiler’s DLL files. The issue was resolved by disabling Smart App Control under Windows Security → App & browser control, allowing the linker plugin to load. Be careful when changing security settings, though—ideally confirm that the compiler came from a trusted source, and consider repairing or reinstalling the toolchain if possible.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.