How to reference .cpp files without including them into the solution in Visual Studio?

£可爱£侵袭症+ 提交于 2019-12-04 05:17:18

问题


I'm trying to compile this code:

extern "C"
{
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
}

#include <luabind/luabind.hpp>
#include<iostream>
int main(){
   lua_State*pL=lua_open();

   luabind::open(pL);

   lua_close(pL);
   return 0;
}

But I don't have a .lib of luabind, so I use the source with the .h/.cpp files. The way I do it is by adding the directories to include, but I get a link error. The only way I can compile is by adding the .cpp files as existing elements, but the solution tree gets messy with the additional files. Can somebody tell me if there's a way to add the directory of the additional .cpp files in the solution's properties?

Thanks


回答1:


Compile the lua cpp files into a static library. Add the directory where you put those under "linker | input | additional library directories".




回答2:


You need to tell the linker where to find the functions referenced by the .h files (the .lib file, typically).



来源:https://stackoverflow.com/questions/4841449/how-to-reference-cpp-files-without-including-them-into-the-solution-in-visual-s

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