我有一个关于如何修复以下Linux Makefile代码的问题:
g++ -g -Wall -I"./" -I"../CameraControlLib" -I"./Cameras" -I"../../Utilities/DataServer" -o Server.o CameraControlLib/Server.cpp
在本例中,DataServerLib.h
包括CameraControlDefs.h
,如下所示。Ubuntu Linux g++
编译器解析包含文件DataServerLib.h
,正确使用-I
预处理器指令,如下所示。然而,g++
编译器告诉我,即使我将-I
子目录路径指向../../Utilities/DataServer
,也没有CameraControlDefs.h
这样的文件或目录。
In file included from CameraControlLib/DataServer.h:4:0,
from CameraControlLib/DataServer.cpp:8:
CameraControlLib/DataServerLib.h:9:31: fatal error: CameraControlDefs.h: No such file or directory
#include "CameraControlDefs.h"
^
compilation terminated.
我知道,如果我使用#include "SomeDir/CameraControlDefs.h"
,应该摆脱编译器错误消息。请让我知道是否有其他方法可以使用Linux g++
的全部选项来做到这一点。
下午好!这是一个解决方案,我刚刚测试了一个Makefile使用g++编译器
INCDIRS:= $(addprefix -I,$(shell find ..)/Utilities/DataServer -type d -print))