动态链接托管C ++类库中的非托管dll

时间:2022-09-01 20:52:08

I figured out through trial n error how to link an unmanaged static library to managed C++ dll, but I have no idea how to dynamically include a DLL. Does anyone know how to do this in Visual studio 2008?

我通过试验n错误想出如何将非托管静态库链接到托管C ++ DLL,但我不知道如何动态包含DLL。有谁知道如何在Visual Studio 2008中这样做?

3 个解决方案

#1


Calling the unmanaged "LoadLibrary" does not work?

调用非托管“LoadLibrary”不起作用?

#2


I'm trying to link CAIR into my managed assembly. CAIR depends on pthreads, a static or dynamic library for accessing posix functions of any OS.

我正在尝试将CAIR链接到我的托管程序集。 CAIR依赖于pthreads,一个用于访问任何OS的posix函数的静态或动态库。

This doesn't make sense to me, but the solution was to include the pthreads.lib file into the managed C++ assembly AND dynamically link pthreads.dll into the managed library as well as all consumer projects.

这对我来说没有意义,但解决方案是将pthreads.lib文件包含到托管C ++程序集中,并将pthreads.dll动态链接到托管库以及所有使用者项目。

I was under the impression I didn't need the dll if I statically compiled the lib into my managed assembly.

如果我将lib静态编译到我的托管程序集中,那么我的印象是我不需要dll。

#3


Hm I'm not sure about the exact details of why this happens, but I use a library called OpenCV and I have to both statically link a lib file and dynamically link a dll file. So I think it's quite normal for it to be this way. I think part of the reason for this is that if the library vendor updates the library, they can just distribute a new dll file and your code will automatically work with it - you don't have to recompile their whole program each time the library is updated.

嗯,我不确定为什么会发生这种情况的确切细节,但我使用一个名为OpenCV的库,我必须静态链接一个lib文件并动态链接一个dll文件。所以我认为这样做是很正常的。我认为部分原因是如果库供应商更新库,他们可以只分发一个新的dll文件,你的代码将自动使用它 - 你不必每次重新编译它们的整个程序库更新。

#1


Calling the unmanaged "LoadLibrary" does not work?

调用非托管“LoadLibrary”不起作用?

#2


I'm trying to link CAIR into my managed assembly. CAIR depends on pthreads, a static or dynamic library for accessing posix functions of any OS.

我正在尝试将CAIR链接到我的托管程序集。 CAIR依赖于pthreads,一个用于访问任何OS的posix函数的静态或动态库。

This doesn't make sense to me, but the solution was to include the pthreads.lib file into the managed C++ assembly AND dynamically link pthreads.dll into the managed library as well as all consumer projects.

这对我来说没有意义,但解决方案是将pthreads.lib文件包含到托管C ++程序集中,并将pthreads.dll动态链接到托管库以及所有使用者项目。

I was under the impression I didn't need the dll if I statically compiled the lib into my managed assembly.

如果我将lib静态编译到我的托管程序集中,那么我的印象是我不需要dll。

#3


Hm I'm not sure about the exact details of why this happens, but I use a library called OpenCV and I have to both statically link a lib file and dynamically link a dll file. So I think it's quite normal for it to be this way. I think part of the reason for this is that if the library vendor updates the library, they can just distribute a new dll file and your code will automatically work with it - you don't have to recompile their whole program each time the library is updated.

嗯,我不确定为什么会发生这种情况的确切细节,但我使用一个名为OpenCV的库,我必须静态链接一个lib文件并动态链接一个dll文件。所以我认为这样做是很正常的。我认为部分原因是如果库供应商更新库,他们可以只分发一个新的dll文件,你的代码将自动使用它 - 你不必每次重新编译它们的整个程序库更新。