Pregunta

Possible Duplicate:
visual c++: #include files from other projects in the same solution

I am new to C++ and stuff. In this project I am using Visual C++ 2010 Express. I am trying to use parserlib. Downloaded the files, even opened up the examples. Now I try creating an empty project and am lost at how I can include its files ... I tried putting parserlib into the "Source Files", and include it like:

#include "parserlib/parserlib.hpp"
// OR
#include "parserlib.hpp"

Both didnt work. I think I need to set some include paths or something?

¿Fue útil?

Solución

  1. Right-click on the project, and select Properties.
  2. Select Configuration Properties->C/C++->General.
  3. Set the path under Additional Include Directories.

Then include using:

#include "parselib.hpp"

You can read detailed answer at this stack question: visual c++: #include files from other projects in the same solution

Otros consejos

You need to configure your project properties. Under C++ add additional include directories to point to the location of the header files. E.g. point it to your parserlib folder, then

#include <parserlib.hpp>

should work. You will also need to configure the linker options so that it links against any .lib files. Add the directory holding the .lib files to additional library directories and then add the specific .lib files to the additional library files.

Looking at the github project you specified. You will have to build the .lib files yourself from the source .cpp files. Otherwise you will get unresolved reference errors at link time. i.e. the compiler reads the declarations from the header file but can't find definitions for the functions (which are in the .cpp files).

See the following for help on how to do that: http://msdn.microsoft.com/en-us/library/ms235627.aspx

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top