Sara
Sara

Reputation: 823

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!

Upvotes: 1

Views: 516

Answers (2)

StuartLC
StuartLC

Reputation: 107357

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

Link Library Dependencies

  1. Select the parent / top level project, and in the Project Properties prop list, click Project Depdendencies and ensure Project A references Project B

Project Dependencies

  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.

enter image description here

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

Upvotes: 0

Erik
Erik

Reputation: 91330

Project Properties, Linker, General: Set "Link Library Dependencies" to Yes.

Upvotes: 5

Related Questions