0
votes

I have a solution with two projects on VS2010.

The main project references and depends on the second one, which is built as a static library. The second one uses a static third-party library that is not build within the solution, but is only referenced in the second project's linker settings.

If I try to generate the solution, VS fails and indicates that he didn't find the third-party library. I do not understand why, since the second project's compiled static lib is big enough and seems to "contain" the 3rd-party library.

So far, I see only two solutions to my problem, which I would rather avoid:

  1. Add the 3rd-party library to the main project's linker settings
  2. Include the whole 3rd-party library in my solution and compile it with

Is there any other way to resolve this problem?

EDIT : The problem occurs when compiling the main project, the compiler outputs : LINK : fatal error LNK1104: cannot open file 'wxbase29u.lib' (I'm using wxWidget in my second project)

EDIT2 : I put the -verbose option for linking on, and it seems like the references to the 3rd-party library actually still exists in Project2.lib :

         Searching ..\MyAppConfig\Bin\Win32\Release\MyAppConfig.libĀ :
           "public: static void __cdecl ConfigWindow::Open(void)" (?Open@ConfigWindow@@SAXXZ) found
             Referenced in main.obj
             Loaded MyAppConfig.lib(configWindow.obj)
     /DEFAULTLIB:wxbase29u processed
     /DEFAULTLIB:wxbase29u_net processed
     /DEFAULTLIB:wxbase29u_xml processed
     /DEFAULTLIB:wxregexu processed
     /DEFAULTLIB:wxexpat processed
     /DEFAULTLIB:wxjpeg processed
     /DEFAULTLIB:wxpng processed
     /DEFAULTLIB:wxtiff processed
     /DEFAULTLIB:wxzlib processed
     ...
     ...
     LINK : fatal error LNK1104: cannot open file 'wxbase29u.lib'

Funny thing is that I don't even use the other wxWidgets libraries in Project2, but visual studio seems to be searching for all of them though :/

1
You might want to put some compiler and linker output in here along with the names of the 3 components you're linking - it'd probably help elicit a better solution :) - John Humphreys
VS fails when building the main project or the second one? - Lanaru
@Lanaru : sorry, I forgot that - Jack
@w00te I don't know if the names will help, but I will try to be more explicit :) - Jack
If wxbase29u.lib is not used by your main project, remove it from your Additional dependencies in your main project. If it is used by your main project, make sure you are pointing to the right directory in "additional include directories" - Lanaru

1 Answers

2
votes

Here's how you should setup your project:

Project 1 (main)

Additional dependencies: Project2.lib

Project 2

Additional dependencies: ThirdParty.lib

Build order: Project 2 -> Project 1

If your project is setup like that and it does not link, then it just means the path to your libraries isn't correctly set (under "Additional include directories"). So just make sure that your project additional dependencies are correctly set and that the include directories point to the place where the libraries you need are located.