2013-12-18 3 views
0

최근 Turbo-C++ 대신 표준 호환 C++을 작성하기로 결정하여 cygwin을 Windows 7에 다운로드하고 g ++를 설치했습니다. 나는 안녕하세요 세계 프로그램을 실행하려고 :g ++ (cygwin)의 다중 선언 오류

#include<iostream> 

using namespace std; 

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

및 Cygwin에서 이것을 입력 : 나는 확실히 수행 바랬

g++ test.cpp -o test 
g++ test 

, 나는 내 마음은 이해할 수없는이 거대한 벽에 의해 파괴 찾기 위해 입력을 누르면 텍스트 :

$ g++ test.exe 
test.exe: In function `mainCRTStartup': 
/usr/src/debug/cygwin-1.7.27-2/winsup/cygwin/crt0.c:23: multiple definition of `mainCRTStartup' 
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../lib/crt0.o:/usr/src/debug/cygwin-1.7.27-2/winsup/cygwin/crt0.c:23: first defined here 
test.exe: In function `mainCRTStartup': 
/usr/src/debug/cygwin-1.7.27-2/winsup/cygwin/crt0.c:23: multiple definition of `WinMainCRTStartup' 
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../lib/crt0.o:/usr/src/debug/cygwin-1.7.27-2/winsup/cygwin/crt0.c:23: first defined here 
test.exe:cygming-crtbegin.c:(.text+0x60): multiple definition of `__gcc_register_frame' 
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/crtbegin.o:cygming-crtbegin.c:(.text+0x10): first defined here 
test.exe:cygming-crtbegin.c:(.text+0xc0): multiple definition of `__gcc_deregister_frame' 
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/crtbegin.o:cygming-crtbegin.c:(.text+0x70): first defined here 
test.exe:crt0.c:(.text+0x50): multiple definition of `.weak._Jv_RegisterClasses.__gcc_register_frame' 
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/crtbegin.o:cygming-crtbegin.c:(.text+0x0): first defined here 
test.exe:cygming-crtend.c:(.idata+0x178): multiple definition of `__imp__ZSt4cout' 
test.exe:cygming-crtend.c:(.idata+0x178): first defined here 
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/crtbegin.o:cygming-crtbegin.c:(.text+0x35): undefined reference to `_Jv_RegisterClasses' 
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/crtbegin.o:cygming-crtbegin.c:(.text+0x35): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_Jv_RegisterClasses' 
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../x86_64-pc-cygwin/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/4.8.2/crtbegin.o: bad reloc address 0x0 in section `.pdata' 
collect2: error: ld returned 1 exit status 

제발 누군가 제발 내가 뭘 잘못하고 있는지 말해 줄래?

+0

왜'g ++ test.exe'인가? './test'로 실행하고 싶지 않으십니까? –

+0

이 방법으로 해결할 것이라고는 약속하지 않지만'test' 대신'test.o'를 컴파일하고'g ++ test' 대신'g ++ test.o'를 사용하여 컴파일을 시도하십시오. –

+0

프로그램 테스트의 이름을 지정하지 않은 것이 더 낫습니다. 그것을 ctest 나 cpptest와 같이 호출하십시오. test는 유닉스에서 명령이다. ./test 대신 test를 입력하면 아무 것도 출력되지 않고 프로그램에서 아무 것도 인쇄하지 않는 이유를 알아 내려고 노력하면서 여러 번 서클에서 돌아 다니게됩니다. – cup

답변

3

g++ test 명령

g++ test.cpp -o test 컴파일하고 코드를 연결합니다 명령에 대한 필요가 없습니다. 당신은 그것을 사용하여 실행할 수 있습니다 ./test.exe