简体   繁体   English

同一解决方案中项目之间的链接问题(Exe依赖于Lib)

[英]Link problem between projects in same solution (Exe depends on Lib)

I have one solution with several projects.我有几个项目的一个解决方案。 Say ProjectA is the one that will produce the exe file, and ProjectB simply produces a .lib file.假设ProjectA将生成 exe 文件,而ProjectB只生成一个.lib文件。 I have checked that ProjectA depends on ProjectB , so that ProjectB will always compile before ProjectA .我已经检查过ProjectA依赖于ProjectB ,因此ProjectB将始终在ProjectA之前编译。

When I compile ProjectB everything goes fine.当我编译ProjectB时,一切正常。 But if I compile ProjectA I get linking errors saying that some method of B does not exist.但是,如果我编译ProjectA ,我会收到链接错误,指出 B 的某些方法不存在。 I have checked, and it does exist.我查过了,确实存在。

¿What is going on?到底是怎么回事?

Thanks for your help!谢谢你的帮助!

项目属性,链接器,常规:将“链接库依赖项”设置为“是”。

I found there were several things I needed to check to fix the vexing link error:我发现我需要检查几件事情来修复令人烦恼的链接错误:

"link.exe" exited with code 1104. “link.exe”以代码 1104 退出。

  1. As per @Eric's answer, on the top level (Project A): Project -> Linker -> General -> Link Library Dependencies: Yes根据@Eric 的回答,在顶层(项目 A): Project -> Linker -> General -> Link Library Dependencies: Yes

链接库依赖

  1. Select the parent / top level project, and in the Project Properties prop list, click Project Depdendencies and ensure Project A references Project B Select 父/顶层项目,并在项目属性道具列表中,单击Project Depdendencies并确保Project A引用Project B

项目依赖

  1. Somewhat counter intuitively, on ProjectA ensure that you don't have an additional linker library dependency on ProjectB.lib .有点反直觉,在ProjectA上确保您没有对ProjectB.lib的额外 linker 库依赖。 This seems to encourage to look VS to look for another library called ProjectB.lib , elsewhere.这似乎鼓励查看 VS 在其他地方寻找另一个名为ProjectB.lib的库。

在此处输入图像描述

  • You do not need to add the output directory of ProjectB to ProjectA's additional Link directories (default is $(SolutionDir)$(Platform)\$(Configuration)\ ).您不需要将 ProjectB 的 output 目录添加到 ProjectA 的附加链接目录(默认为$(SolutionDir)$(Platform)\$(Configuration)\ )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在同一解决方案中的 2 个项目之间链接,并且我没有用于其他依赖项的 .Lib 文件 - Cannot Link between 2 projects in the same solution, and i dont have a .Lib File for additional dependencies 如何在同一解决方案中的项目之间共享变量? - How to share variable between projects in the same solution? 在同一解决方案中的项目之间传递CString - Passing CStrings between projects in same solution 如何链接到同一VC ++ 2010解决方案中项目产生的.lib - How to link to .lib produced by project in same VC++ 2010 solution 同一解决方案中不同项目之间的引用(Visual Studio 2012) - Reference between different projects in the same solution (Visual Studio 2012) 许多项目的解决方案上的C ++链接错误 - C++ link errors on solution with many projects Visual Studio:解决方案中的某些项目不会生成.exe文件 - Visual Studio: some projects in solution don't generate .exe files 用.depends指定SUBDIRS项目之间的依赖项不起作用 - Specifying dependencies between SUBDIRS projects with .depends doesn't work GoogleTest在同一解决方案中几个C ++项目 - GoogleTest several C++ projects in the same solution 处理解决方案中多个项目中的相同头文件 - handling same header files in multiple projects in a solution
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM