How do I reference one VC++ project from another in the same project?

二次信任 提交于 2019-12-02 01:15:29

If I remember correctly (haven't used C++ for a while), there were two different kinds of C++ libraries - a static library (a .lib file) and a dynamic library (a .dll file).

In the case of a static library you had to configure p2 so that it links to p1.lib (in project properties); add p1 to dependancies of p2, so that it is always built first; and then include the .h files from p1 as necessary.

The .dll file was a bit more tricky - the .h files had to have __declspec(dllimport) and __declspec(dllexport) I think. And there was some more magic. Not sure really. But these are the keywords that might get you up and running.

Note that this is a MS specific keyword and will not work on other compilers.

All you need to do to use these functions is to change the projects dependencies.

Right click on p2(or p1), select "Project Dependencies" Select p1(or p2) and include what you want to use. It's that simple.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!