Linker undefined reference error, fresh MinGW install
Derek Harter <[email protected]> Fri, 5 Jun 2020 19:29:47 -0500
| Newsgroups | gmane.comp.gnu.mingw.user |
|---|---|
| Message-ID | <CAJkeYCrEQgf5qWCE5SCaRuPZO1=c7gd6Skxy6BDc7Fy8FndS7A@mail.gmail.com> |
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.
Derek
--
Derek Harter, Ph.D., Associate Professor
Computer Science and Information Systems (SCI 355)
Texas A&M University
PO Box 3011
Commerce, TX 75429
Tel: (903) 468-8762 / Fax: (903) 886-5404
Email: [email protected]
URL: http://harter.pro
PGP Public Key:
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x613BC988DE797012
- 3, 2, 1, Lets Jam!
_______________________________________________
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