开发者

How to add an external static library to a Visual C++ 2010 Express project

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

  1. Left clik on your Project and select Properties
  2. In the Properties Dialog go to Configuration Properties (in the next step we will always assumet to be under Configuration Properties)
  3. In C/C++ -> General edit the Additional Include Directories property adding the path to your header file (.h file)
  4. In Linker -> General edit the Additional Library Directories property adding the path to your static library (.lib file)
  5. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜