Search code examples
c++visual-studioc++-cliconan

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


I'm setting up [C# WPF] and [C++/CLI] and [C++ code with external library ] solution in VS 2017.

I have one VS solution with 3 projects: test_app(c++), Wrapper(C++/CLI) and Sandbox(C# WPF).

Solution is correct and work w/o adding libraries.

I am use conan as package manager (added VS conan extension and include conanfile.txt to my test_app project.

conanfile.txt:

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

c++ test_app builds w/o errors:

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

But if I add to my test_app/Entity.h header and compile soultion, I have error in my C++/CLI Wrapper (conan install deps and test_app rebuilds normally):

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

Maybe problems with configuring projects or linking, but I cannot get what is bad. I use test_app in Wrapper using header #include "../test_2_aaa/Core.h" in Wrapper/Entity.h

My test_app configured as Static library (.lib) and Wrapper configured as Dynamic library (.dll)

test_app is checked in Wrapper's project dependencies.

Screen with whole structure: solution

My test_app main files:

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

My Wrapper main files:

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

If you have additional questions, you can ask me.

Thank you.

UPD: Also I tried add conanfile to Wrapper and install deps there, but many errors accured when I tried it.


Solution

  • I made another VS solution with WPF C++/CLI and C++ libraries, by modifying WPF-C++/CLI layers.

    Now it tested and published to my public github repository under GNU GPL v3.

    Enjoy :)