2

I was looking at the source code for ncmpcpp, and I saw this.

#include <mpd/client.h>

Inside that file are functions which are used by ncmpcpp. But those are just the headers. Don't the cpp files have to exist somewhere as well? I couldn't find them in the same directory. Where are they?

Also, when something that's included is surrounded by < and >, how do I know where to look?

node ninja
  • 31,796
  • 59
  • 166
  • 254

2 Answers2

5

If it's a third-party library, most likely the source code won't be included. Nor is it needed. All symbols declared in the headers (which are meant to be used) should be exported in the .lib file which was probably shipped with the headers.

Unless you have templates, which could be inline.

You only need the cpp files, or, more generally, the implementation files, if you want to compile the code yourself. Which you don't. You can use the module having just headers and binaries.

Of course, the example of open-source projects comes to mind, where all files are generally included, but if it's a commercial product, why release the source code? What's keeping any competitors from just copying it and resell it under a new name?

There's no standard rule that tells where to look for headers that are delimited by <> or "", but the general consensus is that <> are to be used for system headers (like string or iostream) and "" for own headers (myclass.h). It just tells the compiler where to look first.

Luchian Grigore
  • 253,575
  • 64
  • 457
  • 625
2

The source files aren't needed if there is a library (static or dynamically linked) with it that the compiler can link to, these are generally .a or .lib files (though very rarely you might need a .def file).

For search paths, see this for MSVC and this for GCC.

Necrolis
  • 25,836
  • 3
  • 63
  • 101