C++/CLI Wrapper with C#

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

C++/CLI Wrapper with C#

J. Caleb Wherry

I recently upgraded to CMake 3.8 to get support for C# as a first class language and it works nicely. However, I am seeking clarification on something:

I currently compile my C++/CLI wrapper as a SHARED lib. This produces a linking lib which I didn't expect and don't want (using the lib works fine in my build with no issues). After reading the docs (https://cmake.org/cmake/help/v3.8/command/add_library.html), it seems like I should be compiling the lib as a MODULE since I do not want unmanaged symbols exported.

However, when I change to MODULE and try to link that to a C# console app, it doesn't work anymore, I get the "MODULE_LIBRARY may not be linked into another target".

My question: am I doing something wrong here? What is the standard way to build a C++/CLI lib and link it to a C# app?

Some things to note:
  • When I link to the C# app, I use target_link_libraries, I don't put it as a reference. I was hoping I could just use this macro and not have to explicitly place it as a reference.
  • My C++/CLI wrapper lib does have some public C symbols which I believe is causing the linking lib to be created so I will investigate that. However, that doesn't answer the question of how to correctly compile a C++/CLI lib.
If there isn't a simple answer, I can create a SSCCE (http://sscce.org/) to replicate the issue I am having.



Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe: