我正在 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/