簡體   English   中英

C ++:`mainCRTStartup'錯誤的多重定義等

[英]C++ : multiple definition of `mainCRTStartup' error etc

所以我對c ++很新,我用代碼塊編寫了這個程序:

#include<iostream>

using namespace std;

int main()
{
    cout << "Hello World!" << endl;
    return 0;
}

當我構建它運行它,我得到一個錯誤。 這是構建日志:

-------------- Build: Debug in HelloWorld (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe  -o bin\Debug\CPP_1.exe obj\Debug\main.o   
obj\Debug\main.o:crt1.c:(.text+0x280): multiple definition of `mainCRTStartup'
c:/programfiles(x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../crt2.o:crt1.c:(.text+0x280): first defined here
obj\Debug\main.o:crt1.c:(.text+0x2a0): multiple definition of `WinMainCRTStartup'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../crt2.o:crt1.c:(.text+0x2a0): first defined here
obj\Debug\main.o:crt1.c:(.text+0x2c0): multiple definition of `atexit'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../crt2.o:crt1.c:(.text+0x2c0): first defined here
obj\Debug\main.o:crt1.c:(.text+0x2d0): multiple definition of `_onexit'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../crt2.o:crt1.c:(.text+0x2d0): first defined here
obj\Debug\main.o:cygming-crtbegin.c:(.text+0x2e0): multiple definition of `__gcc_register_frame'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/crtbegin.o:cygming-crtbegin.c:(.text+0x0): first defined here
obj\Debug\main.o:cygming-crtbegin.c:(.text+0x32c): multiple definition of `__gcc_deregister_frame'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/crtbegin.o:cygming-crtbegin.c:(.text+0x4c): first defined here
obj\Debug\main.o:crt1.c:(.bss+0x4): multiple definition of `_argc'
c:/program files  (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../crt2.o:crt1.c:(.bss+0x4):first defined here
obj\Debug\main.o:crt1.c:(.bss+0x0): multiple definition of `_argv'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../crt2.o:crt1.c:(.bss+0x0): first defined here
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/crtbegin.o:cygming-crtbegin.c:(.text+0x45): undefined reference to `_Jv_RegisterClasses'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 1 second(s))
13 error(s), 0 warning(s) (0 minute(s), 1 second(s))

我根本無法弄清楚它為什么不起作用。 如果有人能幫助我,我會非常感激。

我遇到了同樣的問題 - 事實證明這是一個不用-o name.exe指定輸出的壞情況如果編譯器在其移交的源文件中找到一個二進制文件,它就會拋出一個特定的錯誤 - 而是嘗試使用它作為一些圖書館 - 當它發現兩個主要和一切都出現時出錯了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM