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

C#WPF and C++/CLI and C++ add external library error in C++/CLI

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

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

解决方案是正确的并且可以 w/o 添加库。

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

conanfile.txt:

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

c++ test_app 构建 w/o 错误:

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 ==========

可能是配置项目或链接有问题,但我不知道哪里不好。 我在包装器中使用 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

我的 Wrapper 主要文件:

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

如果还有什么问题可以问我

谢谢。

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

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

现在它在 GNU GPL v3 下测试并发布到我的 public github repository

尽情享受吧:)