Makefile 在make期间链接所需的头文件
我正试图对我已经编译过的内容进行一次修改 编译失败Makefile 在make期间链接所需的头文件,makefile,mapnik,Makefile,Mapnik,我正试图对我已经编译过的内容进行一次修改 编译失败 $ make c++ -D_THREAD_SAFE -I/usr/local/Cellar/protobuf/2.6.1/include -L/usr/local/Cellar/protobuf/2.6.1/lib -lprotobuf-lite tileinfo.cpp ../../src/vector_tile.pb.cc -o tileinfo -lprotobuf-lite -lz tileinfo.cpp:7:10: fata
$ make
c++ -D_THREAD_SAFE -I/usr/local/Cellar/protobuf/2.6.1/include -L/usr/local/Cellar/protobuf/2.6.1/lib -lprotobuf-lite tileinfo.cpp ../../src/vector_tile.pb.cc -o tileinfo -lprotobuf-lite -lz
tileinfo.cpp:7:10: fatal error: 'vector_tile_compression.hpp' file not found
#include "vector_tile_compression.hpp"
^
1 error generated.
make: *** [tileinfo] Error 1
我可以在项目源代码中看到丢失的头文件。我希望在编译时包含它,以便可以找到它。我假设简单地复制所有源代码是不正确的&我应该能够指向这个头文件。我尝试了-I
标志,但是无论我给它什么路径,它仍然找不到这个头文件
所以我屈服并复制头文件
$ cp ../../src/vector_tile_compression.hpp .
$ make
c++ -D_THREAD_SAFE -I/usr/local/Cellar/protobuf/2.6.1/include -L/usr/local/Cellar/protobuf/2.6.1/lib -lprotobuf-lite tileinfo.cpp ../../src/vector_tile.pb.cc -o tileinfo -lprotobuf-lite -lz
In file included from tileinfo.cpp:7:
./vector_tile_compression.hpp:5:10: fatal error: 'vector_tile_config.hpp' file not found
#include "vector_tile_config.hpp"
^
1 error generated.
make: *** [tileinfo] Error 1
好的,它现在需要一个新的文件,它只需要越来越多的文件。让我们将整个项目源代码移到示例中
$ cp ../../src/* .
$ make
c++ -D_THREAD_SAFE -I/usr/local/Cellar/protobuf/2.6.1/include -L/usr/local/Cellar/protobuf/2.6.1/lib -lprotobuf-lite tileinfo.cpp ../../src/vector_tile.pb.cc -o tileinfo -lprotobuf-lite -lz
In file included from tileinfo.cpp:7:
In file included from ./vector_tile_compression.hpp:5:
./vector_tile_config.hpp:10:10: fatal error: 'protozero/types.hpp' file not found
#include <protozero/types.hpp>
^
1 error generated.
make: *** [tileinfo] Error 1
再一次,我尝试了路径上的一些变体,但是这个-I
标志,我认为它并没有达到我所认为的效果
所以在绝望中我复制了依赖关系
$ cp -r ../../deps/protozero/include/protozero .
$ make
c++ -D_THREAD_SAFE -I/usr/local/Cellar/protobuf/2.6.1/include -L/usr/local/Cellar/protobuf/2.6.1/lib -lprotobuf-lite tileinfo.cpp ../../src/vector_tile.pb.cc -o tileinfo -lprotobuf-lite -lz
In file included from tileinfo.cpp:7:
In file included from ./vector_tile_compression.hpp:5:
./vector_tile_config.hpp:10:10: error: 'protozero/types.hpp' file not found with <angled> include; use "quotes" instead
#include <protozero/types.hpp>
^~~~~~~~~~~~~~~~~~~~~
"protozero/types.hpp"
$cp-r.././deps/protozero/include/protozero。
$make
C++ + -dxthRead安全- I/Ur/Posial/ToBuff/2.61/2包括-L/Ur/Prase/CyrAR/OrthBuff/2.61/LIB LLoTbFF Lite TILIOF.CP/..…/SRC/VECRTROL TILE。
在tileinfo.cpp中包含的文件中:7:
在./vector\u tile\u compression.hpp:5中包含的文件中:
./vector_tile_config.hpp:10:10:错误:“protozero/types.hpp”文件未与include一起找到;用“引号”代替
#包括
^~~~~~~~~~~~~~~~~~~~~
“protozero/types.hpp”
这条消息告诉我,我不应该复制这些文件,而是应该链接到它们。显然我走错了方向。我该怎么办呢?你就快到了。我将以更清晰的方式重述这些步骤(即使您已经完成了一些) 首先,您需要下载依赖项。我们有: 从项目的根文件夹运行此命令后,将有一个
deps
文件夹,其中包含protozero
最后,您必须通过添加
-I./deps/protozero/include
到您的Makefile
的cxflags
(假设您的文件使用与您提供的内部结构类似的结构)
PROTOZERO_REVISION=v1.3.0 git clone https://github.com/mapbox/protozero.git ./deps/protozero && cd ./deps/protozero && git checkout $(PROTOZERO_REVISION)
-I./deps/protozero/include