如何在不将.cpp文件包含到Visual Studio解决方案中的情况下对其进行引用? [英] How to reference .cpp files without including them into the solution in Visual Studio?

查看:167
本文介绍了如何在不将.cpp文件包含到Visual Studio解决方案中的情况下对其进行引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编译以下代码:

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;
}

但是我没有luabind的.lib,因此我将源代码与.h/.cpp文件一起使用. 我这样做的方法是添加要包含的目录,但出现链接错误. 我可以编译的唯一方法是将.cpp文件添加为现有元素,但是解决方案树会使其他文件杂乱无章. 有人可以告诉我是否有办法在解决方案的属性中添加其他.cpp文件的目录吗?

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?

谢谢

推荐答案

将lua cpp文件编译到静态库中.将目录放置在链接器|输入|其他库目录"下.

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

这篇关于如何在不将.cpp文件包含到Visual Studio解决方案中的情况下对其进行引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆