适用于header-only的库。
由于ProxyLODPlugin中已经包含了大部分的Boost库,因此只需要把相关路径加进去就行了。如果所需要的库没有,那么手动加入到项目路径中也可以。
Include Path
在项目的Build.cs中添加如下内容
PublicIncludePaths.AddRange( new string[] { System.IO.Path.Combine(EngineDirectory, "Plugins/Experimental/ProxyLODPlugin/Source/ThirdParty") // ... add public include paths required here ... } );
如果上面文件夹中的库缺失,将缺失的库拷贝到项目文件夹中,比如Source文件夹下面建个ThirdParty,然后这个目录添加到IncludePath中。
System.IO.Path.Combine(ModuleDirectory,"../ThirdParty")
头文件
THIRD_PARTY_INCLUDES_START #define BOOST_DISABLE_ABI_HEADERS #include "boost/graph/graph_traits.hpp" #include "boost/graph/adjacency_list.hpp" #include "boost/graph/dijkstra_shortest_paths.hpp" #include "boost/property_map/property_map.hpp" THIRD_PARTY_INCLUDES_END
THIRD_PARTY_INCLUDES_START和END宏解决下面的错误
Source\ThirdParty\boost/type_traits/detail/config.hpp(85): error C4668: ‘__clang_major___WORKAROUND_GUARD‘ is not defined as a preprocessor macro, replacing with ‘0‘ for ‘#if/#elif‘ Source\ThirdParty\boost/type_traits/detail/config.hpp(85): error C4668: ‘__clang_major__‘ is not defined as a preprocessor macro, replacing with ‘0‘ for ‘#if/#elif‘ 1>C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared\ntverp.h(119): error C4668: ‘DBG‘ is not defined as a preprocessor macro, replacing with ‘0‘ for ‘#if/#elif‘ 1>C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared\ntverp.h(126): error C4668: ‘BETA‘ is not defined as a preprocessor macro, replacing with ‘0‘ for ‘#if/#elif‘ Source\ThirdParty\boost/smart_ptr/shared_ptr.hpp(833): error C4668: ‘__GNUC__‘ is not defined as a preprocessor macro, replacing with ‘0‘ for ‘#if/#elif‘ Source\ThirdParty\boost/mpl/aux_/config/operators.hpp(27): error C4668: ‘__NVCC___WORKAROUND_GUARD‘ is not defined as a preprocessor macro, replacing with ‘0‘ for ‘#if/#elif‘ Source\ThirdParty\boost/mpl/aux_/config/operators.hpp(27): error C4668: ‘__NVCC__‘ is not defined as a preprocessor macro, replacing with ‘0‘ for ‘#if/#elif‘
BOOST_DISABLE_ABI_HEADERS解决下面的错误
Source\ThirdParty\boost/config/abi_prefix.hpp(19): error C4103: alignment changed after including header, may be due to missing #pragma pack(pop) Source\ThirdParty\boost/archive/detail/abi_prefix.hpp(11): error C4103: alignment changed after including header, may be due to missing #pragma pack(pop) Source\ThirdParty\boost/archive/archive_exception.hpp(34): error C4103: alignment changed after including header, may be due to missing #pragma pack(pop) Source\ThirdParty\boost/config/abi_suffix.hpp(20): error C4103: alignment changed after including header, may be due to missing #pragma pack(pop) Source\ThirdParty\boost/archive/detail/abi_suffix.hpp(14): error C4103: alignment changed after including header, may be due to missing #pragma pack(pop) Source\ThirdParty\boost/archive/archive_exception.hpp(98): error C4103: alignment changed after including header, may be due to missing #pragma pack(pop)
由于UE4默认禁用C++ exception,所以可能需要加上下面的代码
namespace boost { #ifdef BOOST_NO_EXCEPTIONS void throw_exception(std::exception const& e) {} // user defined #else #endif } // namespace boost
否则可能会得到下面的错误
error LNK2019: unresolved external symbol "void __cdecl boost::throw_exception(class stdext::exception const &)" (?throw_exception@boost@@YAXAEBVexception@stdext@@@Z)
注
原文:https://www.cnblogs.com/haisong1991/p/11496406.html