c++ - C#WPF和C++/CLI和C++在C++/CLI中添加外部库错误

标签 c++ visual-studio c++-cli conan

我正在 VS 2017 中设置 [C# WPF] 和 [C++/CLI] 以及 [带有外部库的 C++ 代码] 解决方案。

我有一个包含 3 个项目的 VS 解决方案:test_app(c++)、Wrapper(C++/CLI) 和 Sandbox(C# WPF)。

解决方案是正确的,无需添加库即可工作。

我正在使用 conan作为包管理器(添加 VS conan 扩展并将 conanfile.txt 包含到我的 test_app 项目中。

conan文件.txt:

 [requires]
 boost/1.69.0@conan/stable
 websocketpp/0.8.1@bincrafters/stable
 [generators]
 visual_studio

c++ test_app 构建无错误:

1>Done building project "test_2_aaa.vcxproj".
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

但是如果我添加到我的 test_app/Entity.h header 并编译灵魂,我的 C++/CLI Wrapper 就会出错(柯南安装 deps 和 test_app 正常重建):

2>------ Rebuild All started: Project: Wrapper, Configuration: Debug Win32 ------
2>stdafx.cpp
2>AssemblyInfo.cpp
2>Entity.cpp
2>c:\users\taipoxin\source\repos\test_2_aaa\test_2_aaa\entity.h(3): fatal error C1083: Cannot open include file: 'websocketpp/client.hpp': No such file or directory
2>Generating Code...
2>Done building project "Wrapper.vcxproj" -- FAILED.
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========

可能是配置项目或链接方面的问题,但我无法理解哪里出了问题。 我在 Wrapper 中使用 test_app,在 Wrapper/Entity.h 中使用 header #include "../test_2_aaa/Core.h"

我的 test_app 配置为静态库 (.lib),Wrapper 配置为动态库 (.dll)

test_app在Wrapper的项目依赖中被勾选

屏幕整体结构: solution

我的 test_app 主要文件:

https://gist.github.com/taipoxin/0a2e908c7e7c2ca621361a3a656830a2

My Wrapper 主要文件:

https://gist.github.com/taipoxin/6771b9372af6c00f7eee3896638b39d8

如果您还有其他问题,可以问我。

谢谢。

UPD:我也尝试将 conanfile 添加到 Wrapper 并在那里安装 deps,但是当我尝试它时出现了很多错误。

最佳答案

我通过修改 WPF-C++/CLI 层,使用 WPF C++/CLI 和 C++ 库制作了另一个 VS 解决方案。

现在测试并发布到我的公共(public)github repository根据 GNU GPL v3

享受 :)

关于c++ - C#WPF和C++/CLI和C++在C++/CLI中添加外部库错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58799763/

相关文章:

c++ pow(2,1000) 通常对于 double 来说很大,但它正在工作。为什么?

c++ - boost hash 为不同的输入返回相同的值

c# - 如何安装扩展的 WPF 工具包?

c# - Linq-to-Sql 设计器中的自定义表达式

c# - VS2010 C++/CLI 项目总是认为 VS2012 C# 项目已过时

class - 非托管 var 作为托管类 c++ 的成员

c++ - 如何从 rabbitmq - amqpcpp 库中的消息中读取 reply_to?

c++ - 在一行中定义多个变量,这是否为构建过程提供了任何优化?

visual-studio - Visual Studio 2010 有 64 位版本吗?

c++ - 32 位系统上的 UInt64,需要从 UInt32 或字节数组生成,如何?