如何向 .pro 文件添加额外的 dll?
我正在为我的项目使用 Visual Studio,并且我需要在我的应用程序中包含 lib/dll。我已经包含了相同的 lib 并编译得很好,但是当我尝试运行它时,给我一个错误,说它找不到指定的 dll,在环境变量 PATH 中添加此路径可以解决问题,但我不想要每次跨系统执行此操作,我如何在我的 .pro 文件本身中包含此路径或相同的解决方法?
预先感谢,这是一个非常紧急的事情。
am using visual studio for my project, and i need to include a lib/dll in my application. i have included the lib for the same and compiles fine, however when i try to run it, gives me an error saying that it could not find the specified dll, adding this path in the env variable PATH solves the issue, but i do not want to do it everytime and across systems, how can i include this path or a workaround for the same in my .pro file itself?
Thanks in advance, this is a li'l urgent.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您遇到此问题是因为您的可执行文件和 dll 位于不同的文件夹中。您可能使用默认的 Visual Studio 设置,该设置在每个项目文件夹中使用 $(IntDir) 和 $(OutDir)。
将两个项目(exe 和 dll)的 OutDir 设置为同一文件夹(例如 $(SolutionDir)\Build\$(TargetName) )。这样,构建解决方案时生成的二进制文件将放置在同一文件夹中(不同目标的不同输出文件夹 - 调试/发布)。
You have this problem because your executable and your dll are in different folders. You probably used the default visual studio setup, which uses $(IntDir) and $(OutDir) in each project folder.
Setup the OutDir for both projects (exe and dll) to be the same folder (e.g. $(SolutionDir)\Build\$(TargetName) ). This way, the binaries resulted when building the solution will be placed in the same folder (different out folders for different targets - Debug/Release).