Reputation: 39018
I am trying to make a sample binary against a project that I've already compiled.
The compilation fails with
$ 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 can see the missing header file in the project source. I want to include it at compilation time, so that it can be found. I assume simply copying all the source is incorrect & that I should be able to point to this header file. I tried the -I
flag, but no matter what path I give it, it still fails to find this header file.
So I cave in and copy the header file...
$ 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
OK, it's after a new file now and it's just going to want more and more. Let's move the entire project source into the example...
$ 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
Well that looks a bit like progress (though I'm worried I took a wrong turn). It wants protozero. It's included in a subfolder of the project called deps
. Ok, I try to include that.
$ make -I ../../deps/protozero/include/
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
Again, I tried a few variations on the path, but this -I
flag, I think it does not do what I think it does.
So in desperation I copy the dependency.
$ 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"
And this message tells me I shouldn't copy the files, but link to them instead. Clearly I'm on the wrong track. What should I be doing instead?
Upvotes: 2
Views: 519
Reputation: 392
You are almost there. I'll recap the steps in a cleaner way (even if you already got some done).
First you need to download the dependency. Looking at mapnik-vector-tile
project Makefile
we have:
PROTOZERO_REVISION=v1.3.0 git clone https://github.com/mapbox/protozero.git ./deps/protozero && cd ./deps/protozero && git checkout $(PROTOZERO_REVISION)
After running this command from the root folder of your project you'll have a deps
folder with protozero
inside.
Finally, you have to tell the compiler about this new include path by appending
-I./deps/protozero/include
to the CXXFLAGS
of your Makefile
(supposing that you use a structure for your file similar to the one inside the binary link you provided).
Upvotes: 1