CYGWIN에서 stdio에 대해 iostream을 사용하면 링크에러가...?

maddog의 이미지

WIN32에서 CYGWIN을 사용하고 있습니다. 뭐, 다양한 목적으로 사용하고
있는데요, 이상한건 C++로 컴파일할때 iostream을 사용하면 꼭 링크에러가
난다는 것입니다. 덕분에 printf를 여전히 사용하고 있습니다. (뭐, 그런 이유가
아니래도 printf를 선호하기는 하지만요.)

원인이 뭘까요...? 참고로 CYGWIN은 거의 모든 옵션을 다 설치했습니다.
(X윈도서버도 돌아갑니다. 이건 좀 놀랬죠. 헐..) 하드도 제법 차지하죠.
되야 되는 넘이 안되니 참 깝깝하네요. 내가 모자란 탓인지... --;

aquarius의 이미지

gcc 2.95 쓰면 됩니다

maddog의 이미지

gcc 버전 2.95.3-5 로 되어 있네요.
그문제는 아닌거 같네요.
다른 해결 방안은 없을까요?

ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
재미없는 일은 하지 않겠다는 인간 쓰레기. ㅡ,.ㅡ;;
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ

eungkyu의 이미지

에러 메시지를 좀 더 자세히 보여주셔야 도움을 쉽게 얻을 수 있을 듯 하네요 :)

ageldama의 이미지

g++의 이전 버젼의 stl/iostream은 문제가 많았다고 알고 있습니 :evil:
STLport을 사용해보세요.

http://www.stlport.org/

----
The future is here. It's just not widely distributed yet.
- William Gibson

maddog의 이미지

우선 간단한 코드입니다. (코드에서 잘못됐나요? -.-;;)

#include <iostream>

using namespace std ;

int main( void )
{
  cout << "Hello, World.\n" ;
  return 0 ;
}

컴파일 하면 컴파일 오류는 없구요 다음과 같이 링크에러가 발생합니다.

Quote:

E:\TEMP>gcc test.cpp
/cygdrive/c/temp/ccKcmutE.o(.text+0x24):test.cpp: undefined reference to `cout'
/cygdrive/c/temp/ccKcmutE.o(.text+0x29):test.cpp: undefined reference to `ostream::operator<<(char const *)'
collect2: ld returned 1 exit status

저의 어리석음을 일깨워주소서... -.-;;;

ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
재미없는 일은 하지 않겠다는 인간 쓰레기. ㅡ,.ㅡ;;
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ

김충길의 이미지

g++ 을 사용해야 하지 않나요?

screen + vim + ctags 좋아요~

maddog의 이미지

음... 일단 g++로 하니 되기는 되는데요...

gcc가 .cpp를 컴파일 못하나요? 제가 알기로 gcc는
.c 이외의 다른 소스는 적당한 프로그램(컴파일러)를
호출해주는 녀석으로 알고 있는데요... 아닌가... -.-;;;

(내가 말도안되는 단순한 걸줄 알았지... ㅠ.ㅠ;;)

이런 부끄러븐 일이... -.-;;

ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
재미없는 일은 하지 않겠다는 인간 쓰레기. ㅡ,.ㅡ;;
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ

eungkyu의 이미지

maddog wrote:
gcc가 .cpp를 컴파일 못하나요? 제가 알기로 gcc는
.c 이외의 다른 소스는 적당한 프로그램(컴파일러)를
호출해주는 녀석으로 알고 있는데요... 아닌가... -.-;;;

gcc는 C compiler, g++은 C++ compiler입니다 :)

vacancy의 이미지

#gcc -o hello hello.cc -lstdc++

ihavnoid의 이미지

manpage에 보면 g++은 gcc로의 간단한 링크라고 합니다...

Quote:

The C and C++ compilers are integrated; g++ is a script to
call gcc with options to recognize C++. gcc processes
input files through one or more of four stages: prepro-
cessing, compilation, assembly, and linking. This man
page contains full descriptions for only C++ specific
aspects of the compiler, though it also contains summaries
of some general-purpose options. For a fuller explanation
of the compiler, see gcc(1).

Consider the ravens: for they neither sow nor reap; which neither have storehouse nor barn; and God feedeth them: how much more are ye better than the fowls?
Luke 12:24

익명 사용자의 이미지

파일 확장자를 .cpp 가 아니라 .cc 로 해주세요.
gcc 를 verbose(-v) 옵션을 주고 컴파일을 하면 specs 라는 파일을 참조하는걸 볼 수 있는데, 확장자에 대한 처리방법이 여기에 기술되어 있습니다.

보통은 g++(c++)로 컴파일하도록 하는 확장자는 .cc 로 되어있을겁니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.