linux下的一个C程序,为什末有错误????

hanchen528 2003-05-06 01:27:53
有一个程序是这样tt.c
#include <newt.h>
int main(int argc,char *argv[])
{
newtComponent form,button;
newtInit();
newtCls();
//在窗口底部写帮助信息
newtPushHelpLine("Press button to exit....");
//建立窗口
newtOpenWindow(10,5,40,6,"ButtonSample");
//建立按钮
button =newtButton(10,1,"HelloWorld");
//建立Form
form=newtForm(NULL,NULL,0);
//把按钮加入form
newtFormAddComponents(form,button,NULL);
//进入Form循环
newtRunForm(form);
//关闭form
newtFromDestroy(form);
//复原
newtFinished();


}
gcc -o prog tt.c

有错误


...全文
39 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
kare 2003-05-15
  • 打赏
  • 举报
回复
如何制作makefile文件:

Automake 所产生的 Makefile 除了可以做到程式的编译和连结,也已经把如何产生程式文件 (如 manual page, info 档及 dvi 档) 的动作,还有把原始程式包装起来以供散布的动作都考虑进去了,所以原始程式所存放的目录架构最好符合 GNU 的标准惯例,接下来我拿 hello.c 来做为例子。
在工作目录下建立一个新的子目录 "hello" 子目录,这个目录将作为我们存放 hello 这个程式及其相关档案的地方:
# mkdir hello

# cd hello
用编辑器写个 hello.c 档,
#include <stdio.h>

int main(int argc, char** argv)
{
printf(``Hello, GNU!\n'');
return 0;
}

接下来就要用 Autoconf 及 Automake 来帮我们产生 Makefile 档了,

1)、
用 autoscan 产生一个 configure.in 的雏型,执行 autoscan 後会产生一个configure.scan 的档案,我们可以用它做为 configure.in 档的蓝本。

# autoscan
# ls
configure.scan hello.c

2)、
编辑 configure.scan 档,如下所示,并且把它的档名改成 configure.in

# Process this file with autoconf to produce a configure script.

AC_INIT(hello.c)

AM_INIT_AUTOMAKE(hello, 1.0)

# Checks for programs.

AC_PROG_CC

# Checks for libraries.

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_OUTPUT(Makefile)

改名:
# mv configure.scan configure.in

3)、
执行 aclocal 和 autoconf ,分别会产生 aclocal.m4 及 configure 两个档案

# aclocal

# autoconf

# ls

aclocal.m4 configure configure.in hello.c

4)、
编辑 Makefile.am 档,内容如下

AUTOMAKE_OPTIONS = foreign

bin_PROGRAMS = hello

hello_SOURCES = hello.c

5)、
执行 automake --add-missing ,Automake 会根据 Makefile.am 档产生一些档案,包含最重要的 Makefile.in

# automake --add-missing

automake: configure.in: installing `./install-sh'

automake: configure.in: installing `./mkinstalldirs'

automake: configure.in: installing `./missing'

6)、
最後执行 ./configure ,

# ./configure

creating cache ./config.cache
checking for a BSD compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking whether make sets ${MAKE}... yes
checking for working aclocal... found
checking for working autoconf... found
checking for working automake... found
checking for working autoheader... found
checking for working makeinfo... found
checking for gcc... gcc
checking whether the C compiler (gcc ) works... yes
checking whether the C compiler (gcc ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
updating cache ./config.cache
creating ./config.status
creating Makefile

现在你的目录下已经产生了一个 Makefile 档,用 "make" 指令就可以开始编译 hello.c 成执行档,执行 ./hello 和 GNU 打声招呼吧!

# make

gcc -DPACKAGE=\"hello\" -DVERSION=\"1.0\" -I. -I. -g -O2 -c hello.c

gcc -g -O2 -o hello hello.o

# ./hello

Hello! GNU!

你还可以试试 "make clean","make install","make dist" 看看会有什麽结果。
hanchen528 2003-05-15
  • 打赏
  • 举报
回复
上面列出的我不太明白,这是一个文件里面的东西吗?
如何修改makefile文件呀,我已经下载了gnewt的压缩文件,
有人装过吗 ,能说一下具体的步骤吗
wollya 2003-05-13
  • 打赏
  • 举报
回复
相关的库
INCLUDES = @STRIP_BEGIN@ \
-I$(top_srcdir) \
-I$(top_srcdir)/include/newt \
-I$(top_srcdir)/include/gnewt \
@STRIP_END@


noinst_PROGRAMS = test test_ja testtree testgrid

test_SOURCES = test.c
test_LDADD = ../src/gtk/.libs/libgnewt.a #/usr/lib/libefence.a
#test_LDADD = -lnewt

test_ja_SOURCES = test_ja.c
#test_ja_LDADD = ../src/gtk/.libs/libgnewt.a
test_ja_LDADD = -lgnewt

testtree_SOURCES = testtree.c
testtree_LDADD = ../src/gtk/.libs/libgnewt.a

testgrid_SOURCES = testgrid.c
testgrid_LDADD = ../src/gtk/.libs/libgnewt.a
wollya 2003-05-13
  • 打赏
  • 举报
回复
从网上找个gnewt的例子来看看,
在修改down下的Makefile
变成你的就可以了
hanchen528 2003-05-13
  • 打赏
  • 举报
回复
好像和gnewt 编程有关
有人装过并用过这个软件吗
getstar 2003-05-11
  • 打赏
  • 举报
回复
给的信息不够啊,别人没有办法帮你
xjc305 2003-05-11
  • 打赏
  • 举报
回复
你没有关闭啊!
在main涵数加上这个
return 0;
hanchen528 2003-05-07
  • 打赏
  • 举报
回复
不知道是什末库呀
form=newtForm(NULL,NULL,0);
这行有错误

wollya 2003-05-07
  • 打赏
  • 举报
回复
相关库没连接进来?
相关库没连接进来?
相关库没连接进来?
相关库没连接进来?
相关库没连接进来?
相关库没连接进来?
相关库没连接进来?
相关库没连接进来?
相关库没连接进来?
相关库没连接进来?
相关库没连接进来?
用户 昵称 2003-05-06
  • 打赏
  • 举报
回复
贴出相关信息
bnwxf 2003-05-06
  • 打赏
  • 举报
回复
相关库没连接进来?
del77 2003-05-06
  • 打赏
  • 举报
回复
具体是什么错误呀,贴出来

23,120

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧