cygwin에서 컴파일할때 에러가 납니다..

yjsyjs3030의 이미지

$ gcc yang.c -o yang `pkg-config --cflags gtk+-2.0`
yang.c: In function ‘main’:
yang.c:8:11: error: ‘gtkwidget’ undeclared (first use in this function)
yang.c:8:11: note: each undeclared identifier is reported only once for each function it appears in
yang.c:8:22: error: ‘window’ undeclared (first use in this function)
yang.c:10:22: error: ‘label’ undeclared (first use in this function)
yang.c:14:36: error: ‘gtk_window_toplevel’ undeclared (first use in this function)

gtk프로그래밍 연습중인데.. 음..어디가 문제인지 모르겠내요.
cygwin을 다시깔아버렸는데.. ㅠ
#include
int main( int argc,char *argv[] )

{
gtkwidget *window;

gtkwidget *label;

gtk_init (&argc, &argv);

window = gtk_window_new (gtk_window_toplevel);

label = gtk_label_new ("hello world");

gtk_container_add (gtk_container(window), label);

gtk_widget_show (label);

gtk_widget_show (window);

gtk_main ();

return(0);

}
소스는 예제 이구욤.. 어디가문제일까요..

jachin의 이미지

cygwin에 gtk 2 를 설치하신 것이겠죠?

http://ubuntuforums.org/archive/index.php/t-1268853.html

우분투 포럼 링크를 보면, 라이브러리 호출 방법에 따라 문제 해결이 되는 것 같습니다.
본래 글을 쓴 사람은,

gcc -o base base.c `pkg-config --libs --cflags gtk+-2.0`

라고 입력하여서 해결하였다고 하네요.

제가 생각하기에도 위의 명령행처럼 입력하시면 될 것 같습니다.

yjsyjs3030의 이미지

$ gcc -o yang yang.c `pkg-config --libs --cflags gtk+-2.0`
yang.c: In function ‘main’:
yang.c:8:11: error: ‘gtkwidget’ undeclared (first use in this function)
yang.c:8:11: note: each undeclared identifier is reported only once for each function it appears in
yang.c:8:22: error: ‘window’ undeclared (first use in this function)
yang.c:10:22: error: ‘label’ undeclared (first use in this function)
yang.c:14:36: error: ‘gtk_window_toplevel’ undeclared (first use in this function)

똑같은 에러가 뜨내요 ㅎ..
cygwin에 설치된것이 문제가 있나요?..

yjsyjs3030의 이미지

휴..
힘드네요 ㅎㅎ 간신히 책찾아서 컴파일까지 성공~ 햇습니다..

그런데 실행 파일 열때 에러가 나오내요 ㅎ..

$ ls
user yang.c yang.exe

user@user-6f5216d912 /cygdrive/c/cygwin/home
$ ./yang

(yang:3036): Gtk-WARNING **: cannot open display:

음.. 흑흑..정말 힘드내요 cygwin과 gtk....ㅠ

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.