Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add shared C# NuGet dependencies to a C++/Cli project?

Tags:

Context: A Visual Studio solution with 2 assemblies, Cs and Cpp.

  • Cs is a C# / .net45 dll
  • Cpp is a C++/Cli dll, a C++ dll compiled with /clr.

I have some dependencies that are pure C# projects from nuget.org. I use the original packages provided by the authors. Adding them to the Cs project works fine, but not to Cpp.

How can I add the C# package to the C++ project?

Since it's C++/Cli, I can easily use .net objects, and I use e.g. in the C++ library stuff from the C# library. But somehow nuget only allows me to select C# projects to add a C# dependency to, not C++ /clr ones.

like image 324
Wilbert Avatar asked Sep 13 '13 12:09

Wilbert


People also ask

What is a shared library in C?

Shared libraries (also called dynamic libraries) are linked into the program in two stages. First, during compile time, the linker verifies that all the symbols (again, functions, variables and the like) required by the program, are either linked into the program, or in one of its shared libraries.

How do I install a shared library?

Once you've created a shared library, you'll want to install it. The simple approach is simply to copy the library into one of the standard directories (e.g., /usr/lib) and run ldconfig(8). Finally, when you compile your programs, you'll need to tell the linker about any static and shared libraries that you're using.

How do I include a .so file in makefile?

In addition, if you want to dynamically link libraries, you need to tell the linker where they are. -L/dir/containing -lc . If you don't want to set a LD_LIBRARY_PATH when executing, you'll need to set rpath , -Wl,--rpath=/path/containing . Points for pointing out what --rpath does.


1 Answers

In your C++/CLI project, just add a reference (Menu->References->Add New Reference->Browse->Browse...) to the nlog.dll that nuget downloads to your [solutionfolder]/packages/nlog... folder. That seems to work for me.

like image 69
alias5000 Avatar answered Nov 04 '22 15:11

alias5000