I can't believe I'm having such a hard time figuring out how to do something so simple. I have an external library (including a .lib and .h file) that I want to add to my project. From what I've read I need to go Project>P开发者_开发百科roperties>Framework and references>Add new References and add it there.
However, this window is blank. There is a Project name and Project Directory column but there is nothing there and no 'browse' button to find my library. I tried going to VC++ directory and adding the path to the .lib file to the libraries path but it didn't help.
What am I missing?
If you have external files you cannot use the reference tab because it just references project in the current solution, so you have to to it manually.
To reach your goal you just need to follow the following step
- Left clik on your Project and select Properties
- In the Properties Dialog go to Configuration Properties (in the next step we will always assumet to be under Configuration Properties)
- In C/C++ -> General edit the Additional Include Directories property adding the path to your header file (.h file)
- In Linker -> General edit the Additional Library Directories property adding the path to your static library (.lib file)
- In Linker -> Input edit the Additional Dependencies property adding the name of your Library (name of your .lib file)
Now you can easily use the function in your static library just including the .h header in your code file ( #include "myLib.h"
)
Project->Properties->Configuration Properties->Linker->Command Line. Spell your_lib_name.lib there to link with it. Alternatively - use Linker->Input->Additional dependencies option (it does the same as directly specifying libs in command line).
As for .h - just #include
it. You might want to add include path for it, though.
精彩评论