[英]Referencing x86 and x64 DLL in C++/CLI wrapper based on project configuration?
I do still have an outstanding question that I am not sure of the answer. 我仍然有一个突出的问题,我不确定答案。
When I followed the tutorials to create a C++/CLI wrapper for my DLL I had to add a reference to the DLL to the project: 当我按照教程为我的DLL创建C ++ / CLI包装器时,我不得不向项目添加对DLL的引用:
No problem with that, as such. 没问题,就这样。 But here is the thing, the reference path is:
但事情就是这样,参考路径是:
D:\\My Programs\\2017\\MSAToolsLibrary\\MSAToolsLibrary\\bin\\x86\\Release\\MSAToolsLibrary.dll
D:\\ My Programs \\ 2017 \\ MSAToolsLibrary \\ MSAToolsLibrary \\ bin \\ x86 \\ Release \\ MSAToolsLibrary.dll
I actually have two DLL files. 我实际上有两个DLL文件。 One for x86 and one for x64.
一个用于x86,另一个用于x64。 Can I set up the wrapper project files in such a way that it references the x64 file and x86 file respectively based on the build configuration?
我可以设置包装器项目文件,使其分别根据构建配置引用x64文件和x86文件吗?
This is my VCXPROJ file: 这是我的VCXPROJ文件:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
[snip]
<ItemGroup>
<Reference Include="MSAToolsLibrary">
<HintPath>..\..\MSAToolsLibrary\MSAToolsLibrary\bin\x86\Release\MSAToolsLibrary.dll</HintPath>
</Reference>
[snip]
</Project>
I can see a reference to the DLL but I can't see a specific reference for x64 and x86 respectively. 我可以看到对DLL的引用,但我分别看不到x64和x86的特定引用。
OK, I added the wrapper project into I real solution. 好的,我将包装器项目添加到了我真正的解决方案中。 x64 is building OK:
x64构建正常:
But when I set the configuration to x86 I have some problems. 但是当我将配置设置为x86时,我遇到了一些问题。 There is a small triangle on the references and the errors in the properties:
引用上有一个小三角形,属性中有错误:
As you will see from my comment on the existing answer, I am using $(PlatformTarget)
in the hint. 正如您将从我对现有答案的评论中看到的那样,我在提示中使用了
$(PlatformTarget)
。 But it seems there is somewhere else we need to adjust references that I can't work out. 但似乎还有其他地方我们需要调整我无法解决的参考资料。
OK, If I open the project on it's own in Visual Studio then I can toggle the platforms fine. 好的,如果我在Visual Studio中自己打开项目,那么我可以切换平台。 But when the project is part of my larger project, it does not like it.
但是当项目是我的大项目的一部分时,它不喜欢它。 That is when it fails.
那是它失败的时候。
Interestingly, if I am in my master project, and set to the x86 platform, and then in this added project I remove the reference to the DLL and go to add it again (the x86 flavour): 有趣的是,如果我在我的主项目中,并设置为x86平台,然后在这个添加的项目中我删除了对DLL的引用并再次添加它(x86风格):
I do not have this problem in the local solution. 我在本地解决方案中没有这个问题。 It seems like I have to do my development in the local solution and compile there, outside of my master project solution.
在我的主项目解决方案之外,似乎我必须在本地解决方案中进行开发并在那里进行编译。 :(
:(
编辑<HintPath>
<HintPath>..\..\MSAToolsLibrary\MSAToolsLibrary\bin\$(Platform)\$(Configuration)\MSAToolsLibrary.dll</HintPath>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.