简体   繁体   中英

Including a library won't work

Here is the setup right now in VS2013:

  • pll.lib project - not written by me, part of a big solution, It is pure C

  • testlib.lib project - made by me, pretty much a copy/paste job from a .exe tool, includes pll.lib , and it is pure C

  • testapp.exe project - written by me, just a console application to test, c++ testapp includes testlib.h , no problem there.

  • testlib includes pll.h , also C/C++->additional include directories has $(SolutionDir)\\pll\\include , no linker libraries specified (just like the .exe tool and other projects that use the pll library in this solution). I also put a tick in the appropriate place in solution dependency manager.

When I start writing #include , it offers an autocomplete for pll.h as expected, however when I try and compile the testapp , it says

Cannot include file "pll.h" no such file or directory

I don't get it, why won't this work?

Also on additional note: testapp also includes another library libgen which also includes pll.h and I can use the functions from there no problem so I know that library cant be broken.

You need to fix your C include path in the testapp.that will fix your include issue. Note that include paths are relative to project root (.vcxproj file) not to cpp files.

After that you also need to link testapp with testlib - easiest way of doing so is adding anoroject reference to testlib. Go to testapp properties, expand first option in the left tree and add a reference there. If you need to link to pll.lib and it sounds like u do, add that in the testapp linker input.

You should also know whether the pll.lib memory management is hermetical or not. If you need to delete mem allocated in pll.lib, you should generate your code dynamically linked to same CRT version pll.lib was compiled against.

place all the files you are talking about in the same folder as your project file and try using;

#include "pll.h"

instead of;

#include <pll.h>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM