gcc 컴파일에러 : 도와주세요.
안녕하세요?
처음 질문 올립니다.
예전 질문을 검색하여 해결을 찾고 싶은데,
어떻게 찾아야할지도 모르겠습니다. ( 검색 질의어를 뭘로 할지.. )
그리고 하단에 BBCode 사용불가 라고 되어 있는데 어떻게하면 사용가 로 만들 수 있나요?
phpBB 도 영 익숙하지가 않군요. (^^)
제 리눅스 시스템은 Fedora core 3 입니다.
컴파일 데스트 하려는 코드는 다음과 같습니다.
prompt> cat test.cc
#include <iostream>
using namespace std;
int main (int argc, char **argv)
{
cout << "Hello world\n";
}
위 코드를 컴파일시 만나는 에러는 다음과 같습니다.
prompt> gcc -o test.out test.cc
/tmp/ccrTCoHz.o(.text+0xd) In function `std__verify_grouping(char const*, unsigned int, stdbasic_string<char, stdchar_traits<char>, stdallocator<char> > const&)'
undefined reference to `stdbasic_string<char, stdchar_traits<char>, stdallocator<char> >size() const'
/tmp/ccrTCoHz.o(.text+0x60) In function `std__verify_grouping(char const*, unsigned int, stdbasic_string<char, stdchar_traits<char>, stdallocator<char> > const&)'
undefined reference to `stdbasic_string<char, stdchar_traits<char>, stdallocator<char> >operator[](unsigned int) const'
/tmp/ccrTCoHz.o(.text+0x9d) In function `std__verify_grouping(char const*, unsigned int, stdbasic_string<char, stdchar_traits<char>, stdallocator<char> > const&)'
undefined reference to `stdbasic_string<char, stdchar_traits<char>, stdallocator<char> >operator[](unsigned int) const'
/tmp/ccrTCoHz.o(.text+0xc8) In function `std__verify_grouping(char const*, unsigned int, stdbasic_string<char, stdchar_traits<char>, stdallocator<char> > const&)'
undefined reference to `stdbasic_string<char, stdchar_traits<char>, stdallocator<char> >operator[](unsigned int) const'
/tmp/ccrTCoHz.o(.text+0x121) In function `main'
undefined reference to `stdcout'
/tmp/ccrTCoHz.o(.text+0x126) In function `main'
undefined reference to `stdbasic_ostream<char, stdchar_traits<char> >& stdoperator<< <stdchar_traits<char> >(stdbasic_ostream<char, stdchar_traits<char> >&, char const*)'
/tmp/ccrTCoHz.o(.text+0x152) In function `__static_initialization_and_destruction_0(int, int)'
undefined reference to `stdios_baseInitInit()'
/tmp/ccrTCoHz.o(.text+0x181) In function `__tcf_0'
undefined reference to `stdios_baseInit~Init()'
/tmp/ccrTCoHz.o(.eh_frame+0x11) undefined reference to `__gxx_personality_v0'
collect2 ld returned 1 exit status
제가 사용중인 gcc 버전은 다음과 같습니다.
prompt> gcc -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.2/specs
Configured with ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model posix
gcc version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)
가장 간단한 helllo world 조차도 출력 못하고 있습니다.
뭐가 문제일까요?
여러분의 답변을 기다립니다.
한 수 알려주시면 대단히 감사하겠습니다.
그게요..
gcc가 아니라 g++ 로 컴파일해보세요..
g++ -o test.out test.cc
Re: 그게요..
감사합니다.
g++로 하니까 컴파일이 되는군요.
그러나 gcc 라는 명령어로 컴파일하게 할 수는 없을까요?
그럴필요가 있어서 그렇습니다.
gcc 는 단지 컴파일러를 호출하는 기능을 한다고 어디선가 들었습니다.
제가 알고있는 것이 맞나요?
g++ 커맨드가 아닌 gcc 커맨드로 동작이 가능하도록 하는 방법을 좀 알려주시면 대단히 감사하겠습니다. (^^)
gcc -o test.out test.cc -lstdc++
gcc -o test.out test.cc -lstdc++
BBCode 사용은...
개인정보 수정을 통해서 고치세요.
I'm a dreamer.
:-) Do everything with all my passion.
댓글 달기