免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2195 | 回复: 2
打印 上一主题 下一主题

linux下,多目录project的autoconf问题,怎样做才正确? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-06-27 13:47 |只看该作者 |倒序浏览
我的问题是:
  1) 如何才能在各自的目录产生.o文件
  2) 在这种多目录的项目中该如何使用autoconf等工具自动生成Makefile
--
我的测试目录如下,有三个目录
=============================================
-- maketest/
         |-- hello/
                 |-- hello.cpp
         |-- include/
                 |-- funcs.h
         |-- funcs/   
                 |-- funcs.cpp

---funcs.h----
#include <stdio.h>;
void p(char* s);  
---funcs.cpp------
#include "../include/funcs.h"
void p(char* s)
{
        printf(s);
}
------hello.cpp------
#include "../include/hello.h"
int main()
{
        p("hello";
        return 0;
}
=============================================

1。我用autoscanf产生了configure.scan, 然后改名为configure.in,对其进行编辑
去掉dnl注释后为
AC_INIT(world/funcs.cpp)
AM_INIT_AUTOMAKE(maketest, 1.0)  <-----我加的

AC_PROG_CXX
AC_PROG_CC

AC_OUTPUT(Makefile)             <------我加的

2 调用aclocal,autoconf
3 新建一个Makefile.am, 如下:
CFLAGS = -Wall -g
bin_PROGRAMS=maketest
maketest_SOURCES=hello/hello.cpp funcs/funcs.cpp
4 调用automake -a
5 运行./configure 运行正确,产生文件maketest/Makefile
6 运行make时候,出现了不是我想要的结果,并且有错误发生:
  1).o文件没有在各自目录产生,而是在maketest/目录产生(Makefile所在目录)
  2)导致出现以下错误:
include/hello.h:3:16: warning: no newline at end of file  
c++  -g -O2  -o maketest  hello/hello.o funcs/funcs.o         
c++: hello/hello.o: No such file or directory            
c++: funcs/funcs.o: No such file or directory                 
c++: No input files                                       
make: *** [maketest] Error 1
  3)我在shell中输入         
     c++  -g -O2  -o maketest  hello.o funcs.o                       
      编译才通过,产生正确的执行文件maketest

论坛徽章:
0
2 [报告]
发表于 2003-06-27 14:00 |只看该作者

linux下,多目录project的autoconf问题,怎样做才正确?

一个configure,每个目录下有自己的Makefile.in, 用:
AC_OUTPUT(Makefile hello/Makefile ...)
子目录下有独立的configure(如第三方代码),用:
AC_CONFIG_SUBDIRS(subdir)

论坛徽章:
0
3 [报告]
发表于 2003-06-27 17:19 |只看该作者

linux下,多目录project的autoconf问题,怎样做才正确?

炎黄角马那有autoconf的完整说明资料
你可以去看看
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP