Mingw GCC Linker在使用std选项标志时出现了抱怨。

问题描述 投票:0回答:1

我正在使用Mingw的gcc编译器,但是当我开始使用-std选项时,链接器开始抱怨引用(除了-std=gnuXX)。

我找不到关于这个问题的任何东西(也许我真的不擅长研究),因为大多数结果都是在linux上的,或者与ld的其他问题有关。

这是我输入的命令。gcc src/main.c -o bin/main.exe -std=c11 同样的情况发生在C89,C99,C17等。

这是我的测试代码。

#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    printf("Cool\n");
    return EXIT_SUCCESS;
}

下面是命令输出

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'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/libgcc_eh.a(emutls.o): in function `_gthread_mutex_init_function':
/home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:639: undefined reference to `CreateSemaphoreW@16'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/libgcc_eh.a(emutls.o): in function `_gthread_key_create':
/home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:590: undefined reference to `TlsAlloc@0'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: /home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:597: undefined reference to `__mingwthr_key_dtor'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/libgcc_eh.a(emutls.o): in function `_gthread_getspecific':
/home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:621: 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/libgcc_eh.a(emutls.o): in function `_gthread_mutex_lock':
/home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:655: undefined reference to `InterlockedIncrement@4'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/libgcc_eh.a(emutls.o): in function `_gthread_mutex_unlock':
/home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:689: undefined reference to `InterlockedDecrement@4'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: /home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:690: undefined reference to `ReleaseSemaphore@12'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/libgcc_eh.a(emutls.o): in function `_gthread_setspecific':
/home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:629: undefined reference to `TlsSetValue@8'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/libgcc_eh.a(emutls.o): in function `_gthread_once':
/home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:562: undefined reference to `InterlockedIncrement@4'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/libgcc_eh.a(emutls.o): in function `_gthread_mutex_lock':
/home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:656: undefined reference to `WaitForSingleObject@8'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: /home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:662: undefined reference to `InterlockedDecrement@4'
collect2.exe: error: ld returned 1 exit status

我也在想我应该用Mingw-w64还是ClangLLVM来代替... ?

EDIT : 用Mingw-w64很好用,所以我换了,谢谢!

c linker mingw ld
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.