Re: Linker undefined reference error, fresh MinGW install
Eli Zaretskii <eliz-mXXj517/[email protected]> Sat, 06 Jun 2020 09:46:02 +0300
| Newsgroups | gmane.comp.gnu.mingw.user |
|---|---|
| Message-ID | <[email protected]> |
> From: Derek Harter <[email protected]> > Date: Fri, 5 Jun 2020 19:29:47 -0500 > > I'm wondering if anyone has more information or knows what the issue is here. I am using a fresh MinGW > install with GCC 9.2.0 on Windows 10. > > ``` > C:\Users\dash\repos\link-bug>g++ --version > g++ (MinGW.org GCC Build-20200227-1) 9.2.0 > Copyright (C) 2019 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There is NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > ``` > > The following minimal example causes a linker undefined error with g++/ld. > > ```c++ > #include <iostream> > #include <string> > using namespace std; > > int main(int argc, char* argv[]) > { > cout << to_string(42) << endl; > return 0; > } > ``` > > ``` > C:\Users\dash\repos\link-bug>g++ main.cpp -o main > c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: > c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingw32.a(mbrscan.o):(.text+0xb6): undefined reference to > `SetLastError@4' > c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: > c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingw32.a(wcharmap.o):(.text+0x208): undefined reference to > `WideCharToMultiByte@32' > c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: > c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingwex.a(codeset.o):(.text+0xbe): undefined reference to > `GetCPInfo@8' > c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: > c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingwex.a(codeset.o):(.text+0x143): undefined reference to > `GetCPInfo@8' > collect2.exe: error: ld returned 1 exit status > ``` > > Any ideas? That should of course link without needing to specify any additional libraries for linking. The > minimal example works fine on Gnu GCC 9.3.0 on linux and on MacOS. Are you using MinGW Runtime v5.3.2? If so, upgrade to 5.3.3 or downgrade to 5.3.1. This seems to be a known problem with 5.3.2. _______________________________________________ MinGW-Users mailing list [email protected] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.osdn.me/mailman/listinfo/mingw-users Also: mailto:[email protected]?subject=unsubscribe