打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Makefile 中vpath的问题

Makefile 中vpath的问题


  1. include ../makefile.defs
  2. INCLUDE=-I ../lib/
  3. vpath %.h ../lib

  4. OBJ=condition.o Lock.o Thread.o

  5. static: $(OBJ)
  6.     ar rcs libthread.a *.o

  7. #Lock.o:
  8. #   $(CC) $(INCLUDE) $(CXXFLAGS) -c Lock.cpp

  9. #Thread.o:
  10. #   $(CC) $(INCLUDE) $(CXXFLAGS) -c Thread.cpp

  11. clean:
  12.     rm -rf *.o *.a
复制代码


因为编译Lock.cpp文件中需要的头文件在../lib/下...所以写了vpath %.h ../lib , 但是编译的时候怎么没有从../lib下找这个头文件...

g++ -g -pg   -c -o Lock.o Lock.cpp
In file included from Lock.cpp:7:
Lock.h:10:17: error: def.h: No such file or directory

请问那个地方有问题,谢谢....
2[报告]
发表于 2008-07-30 18:11:45|只看该作者
1. INCLUDE=-I ../lib/ 中间没有空格
2. -I 已经指定了路径. 还用vpath干吗
3. 这些设置只在makefile中起作用. 如果你单独使用g++ 编译某个文件.是不行的.

g++ -g -pg  -I../lib -c -o Lock.o Lock.cpp  试试

3[报告]
发表于 2008-07-30 19:13:29|只看该作者
确实是makefile中能用的,而且linux中好像不只有一个\lib
应该把路径写的更详细点吧

4[报告]
发表于 2008-07-31 10:15:47|只看该作者
-I都有了
VPATH
    Set with a list of directory pathnames separated by a : (colon). This
    is used when searching for a dependency-related file. If this macro is
    defined, then those directories are searched. If this macro is not
    defined or is just defined with a .\ (dot backslash), only the current
    directory is searched. Default is null.  VPATH can be used to search
    for implicit prerequisites, internal include files, description files,
    and description file command line words.

[ 本帖最后由 gawk 于 2008-7-31 10:19 编辑 ]
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Makefile VPATH和vpath的使用
Makefile 实际用例分析(二)
复杂就是简单的多态叠加
Ubuntu9.04下HelloWorld程序例子(makefile)
嵌入式Linux下教你书写一个简单的makefile
在U-boot中添加led步骤
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服