- 论坛徽章:
- 0
|
我的问题是:
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 |
|