使用Cmake编译库

Zek*_*eke 1 c++ linker cmake voxel visual-studio

我正在尝试将一个体素库PolyVox包含到我的项目中.但是,库下载不会为您提供预编译的头文件,而是需要Cmake.这不会是一个大问题,除了他们关于这个主题的教程非常不完整.我之前从未使用过Cmake,并且搜索没有解决问题.

我用Visual Studio 10编译器运行了Cmake,它生成了一堆Visual Studio项目.我将这些项目编译成2个库,并将库目录包含在项目的属性中.我还将所有PolyVox的头文件放在Visual Studio所知的目录中.在尝试编译我的项目时,我得到链接器错误,例如:

1>Gamestate.obj : error LNK2019: unresolved external symbol "public: __thiscall PolyVox::Region::Region(class PolyVox::Vector<3,int> const &,class PolyVox::Vector<3,int> const &)" (??0Region@PolyVox@@QAE@ABV?$Vector@$02H@1@0@Z) referenced in function "public: __thiscall Gamestate::Gamestate(void)" (??0Gamestate@@QAE@XZ)
Run Code Online (Sandbox Code Playgroud)

有人可以向我解释如何使用Cmake将PolyVox正确地包含在我的代码中吗?

arr*_*owd 5

您忘了在游戏项目中添加polyvox库.它位于Linker菜单中,名为"Additional dependencies",IIRC.