Visual Studio 2008 Solution - How to specify where to get dependent .lib

Answered Visual Studio 2008 Solution - How to specify where to get dependent .lib

  • Saturday, March 03, 2012 8:30 PM
     
     

    I am modifying my VS 2008 configuration. For each Project I clicked Properties and...

    I set Linker-General-Output File to $(OutDir)\$(ProjectName).dll

    I set Configuration Properties-General-Output Directory to $(SolutionDir)\G\$(ConfigurationName) and Intermediate Directory to $(ConfigurationName)

    Now I am getting xxx.lib not found error because it is being sought under \G\...  What should I do to make it search under "Project"\Debug\xxx.lib - instead of \G\Debug\xxx.lib the linker is doing right now?

    Thank you

    Makoto

All Replies

  • Sunday, March 04, 2012 2:53 AM
     
     Answered
    The usual way to specify an additional library
    for a build is to set the project properties:

    Configuration Properties->Linker->General

    and set the path for the .lib file in
    "Additional Library Directories"

    Also go to:

    Configuration Properties->Linker->Input

    and set the .lib file name in
    "Additional Dependencies"

    - Wayne
  • Sunday, March 04, 2012 3:30 AM
     
     

    Thank you for the instruction.

    If Project G requires two libraries, A.lib & B.lib, am I adding both "..\A\Debug" & "..\B\Debug" in Additional Library Directories?

    That is, I cannot just use a $(macro), but need to specify individual folder names?

    Makoto

       

  • Sunday, March 04, 2012 3:55 PM
     
     

    If Project G requires two libraries, A.lib & B.lib, am I adding both "..\A\Debug" & "..\B\Debug" in Additional Library Directories?

       

    VB folks could add both (or more) paths,  but we VC++ users do something smarter.

    We set all projects in the solution so that the build output (.libs. .dlls) go to one directory: usually $(SolutionDir)$(ConfigurationName) , and specify that in Additional Library Directories.

    -- pa

  • Tuesday, March 06, 2012 7:33 AM
     
     

    Thank you for your help...

    I set Linker-General-Output File to be --> $(OutDir)\$(ProjectName).dll
    So, now I am getting my dll in the folder I want (as above), but my lib is created in the Project folder. I want my lib to be in the same folder as my dll. How do I specify where my lib is created ?

    And once this is done, how do I specify to search this folder for lib?

    I put $(SolutionDir)$(ConfigurationName) in Additional Library Directories, but I got "cannot open..." linker error, looking for a wrong folder.

    Makoto

     

  • Thursday, March 08, 2012 6:42 AM
     
     

    The answer was : Linker-Advanced-Import Librariy.  This is how I specify where my lib goes. I also set Additional Library Directories as above.

    Now, I am getting a "cannot open .......lib" linker error. The reason is the folder the linker is looking for has "..\ProjectName" prefixed on top of my Additional Library Directories specification. Could you tell me why or how to fix it?

    Thank you.

    Makoto

  • Friday, March 09, 2012 3:20 AM
     
     Answered

    Wayne already told you how to do that . But still if you want a lib inside your project you can use additional dependency or

    you can use

    #pragma comment( lib,"your library")

    if path is a problem then specify the path of lib or copy it to your local project directory.

    Thanks


    Rupesh Shukla

  • Monday, March 19, 2012 9:13 AM
    Moderator
     
     

    Hi Makoto,

    I marked these replies as answer, if your issue have not been solved please unmark it and update more information about this issue.

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us