0

this will probably a dumb question for you guy's but I have no experience in C++ what so ever. I'm using an open source project osrm (which is awesome). Still to request a route, you have make an http request. To reduce the running time, I would like to build a wrapper around the code and call it using the command line. So I googled a bit and found that osrm already creates a static lib (.a file) when compiling the project. I also found a piece of code that points me in the right directions for building a wrapper. So to begin I build a simple hello world program (see below) that includes some files from that static lib. To compile I followed this tutorial. My directory structure looks like this: ./helloWorld.cpp ./libs/libOSRM.a

And the command to compile is this:

gcc –static helloworld.cpp –L ./libs –l libOSRM.a

The code it selve:

#include "Router.h"
#include "boost/filesystem/path.hpp"
#include "ServerPaths.h"
#include "ProgramOptions.h"
#include <InternalDataFacade.h>
#include <viaroute.hpp>
#include <iostream.h>

main()
{
   cout << "Hello World!";
   return 0;
}

the exact error I got:

fatal error: ServerPaths.h: No such file or directory #include "ServerPaths.h"

jorne
  • 894
  • 2
  • 11
  • 23
  • When you use the `-lNAME` option, the linker will look for alibrary named `libNAME.a`, so change your option to `-lOSRM` and the library will be found. – Some programmer dude Mar 16 '15 at 07:53
  • 2
    My comment above was just an assumption, because you don't say what your problem is, or if you even *have* a problem. What is your question? Please elaborate! – Some programmer dude Mar 16 '15 at 07:55
  • I updated the question. Sorry if it wasn't clear. I updated my command but still got the same error – jorne Mar 16 '15 at 07:58
  • @jorne You should probably add a return type to the `main` ao `int main()` especially since you return 0 – Phorce Mar 16 '15 at 13:25

1 Answers1

2

Add the -IPathToTheHeaderFiles to the compiler options. So it will find the files to be included. Replace PathToTheHeaderFiles with the path where your file ServPaths.h resides.

Edit: Add as many -I as you need for further header files.

Additionally it would be worth to read a book about C++ or/and the GCC manual1

1 Section 3.11 will help.

harper
  • 13,345
  • 8
  • 56
  • 105
  • thanks, this helped. still now the compiler complaines that includes in that header file can't be found. Any sugestions on that? – jorne Mar 16 '15 at 08:24