[Mingw-users] Linker undefined reference error, fresh MinGW install

Back to archive index
Derek Harter Derek****@tamuc*****
Sat Jun 6 09:29:47 JST 2020


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 at 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 at 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 at 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 at 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: Derek****@tamuc*****
  URL: http://harter.pro
  PGP Public Key:
       http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x613BC988DE797012
    - 3, 2, 1, Lets Jam!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/mingw-users/attachments/20200605/9b9206db/attachment.html>


More information about the MinGW-Users mailing list
Back to archive index