繁体   English   中英

如何将使用boost :: asio的本机C ++静态库导入CLI / C ++混合模式应用程序?

[英]How can I import a native C++ static lib which uses boost::asio into a CLI/C++ mixed mode application?

我有一个C ++ / CLI命令行客户端,并且尝试导入一个本机C ++库,而该库又具有#include <boost/asio.hpp>

当我尝试导入此文件时,出现以下错误:

2>C:\boost_1_54_0\boost/asio/generic/detail/endpoint.hpp(27): error C2059: syntax error : 'generic'
2>C:\boost_1_54_0\boost/asio/generic/detail/endpoint.hpp(27): error C2143: syntax error : missing ';' before '{'
2>C:\boost_1_54_0\boost/asio/generic/detail/endpoint.hpp(27): error C2447: '{' : missing function header (old-style formal list?)
2>C:\boost_1_54_0\boost/asio/generic/detail/impl/endpoint.ipp(32): error C2059: syntax error : 'generic'

包含项必须位于静态库的标头中,因为它们是成员变量。

那么从static / native库中导入和使用这些类的最简单的选择是什么?

这个问题已经出现在助推器上,您可以在这里找到。 目前的解决方案(由Michael Rasmussen提供)是这样做的

#ifdef __cplusplus_cli
#define generic __identifier(generic)
#endif>
#include <boost/filesystem.hpp>
#ifdef __cplusplus_cli
#undef generic
#endif

并包装您的增强包,这些ifdef中的通用符号有问题。

编辑:我想念您的库是静态库的情况,您可能想使用动态Boost库,它可以避免定义多个符号的问题。 使用BOOST_ALL_DYN_LINK预处理程序定义代替使用boost dll。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM