简体   繁体   中英

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. I have checked that ProjectA depends on ProjectB , so that ProjectB will always compile before ProjectA .

When I compile ProjectB everything goes fine. But if I compile ProjectA I get linking errors saying that some method of B does not exist. 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.

  1. As per @Eric's answer, on the top level (Project 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

项目依赖

  1. Somewhat counter intuitively, on ProjectA ensure that you don't have an additional linker library dependency on ProjectB.lib . This seems to encourage to look VS to look for another library called ProjectB.lib , elsewhere.

在此处输入图像描述

  • You do not need to add the output directory of ProjectB to ProjectA's additional Link directories (default is $(SolutionDir)$(Platform)\$(Configuration)\ ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM