none
Environment variables not delegated to build

    Question

  • Hi we have multiple projects link together.  A project has dependencies on some projects and one of those projects is invoking an ICU tool. This build fails on an error:

    'LIB.exe' is not recognized as an internal or external command

    However if I run visual studio by first opening "Developer Command Prompt for VS2015" and then typing devenv then it works. So I assume that Visual Studio 2015 does not run the vsvars on it's own?  Can I somehow fix this? So that it would work if I would also start visual studio by double-clicking a .sln file and then starting a build.

    Note: I installed visual studio on a non-standard path.  (Not the default C:/Program Files).

    Thanks


    Tuesday, December 15, 2015 8:49 AM

Answers

  • Hello, The problem seems to be fixed.  We had to add:

    <Target Name="Build" DependsOnTargets="SetBuildDefaultEnvironmentVariables

    Then all started to work. We didn't wanted to add Lib.exe to PATH because we have multiple versions of Visual Studio.  (2010, 2013 and 2015).  What was strange though that on 2010 we didn't have this problem, the problem was when we migrated to 2015.

    Thanks


    Tuesday, December 22, 2015 9:56 AM

All replies

  • Hi MartinKosicky,

    >>However if I run visual studio by first opening "Developer Command Prompt for VS2015" and then typing devenv then it works.

    Do you mean when you second opening Developer Command Prompt for VS2015 it doesn't work fine?

    As far as I know, open Visual Studio directly is the same with opening with Developer Command Prompt window. Please make sure you open Visual Studio as administrator first.

    Then please close all third part software, such as antivirus. There are many strange issue is caused by the antivirus.

    If above steps don't work, please try with following steps to troubleshoot this problem.

    1. Create a new project without invoking the ICU tool to check whether this problem is caused by this ICU tool.
    2. Split the project which invoking the ICU tool and run it standalone to check whether it is related to other project which dependencies this project.
    3. Try this project in another computer which install Visual Studio on C:\ to make sure this problem is relate to the installation path or not.

    Best Regards,
    Weiwei

    Wednesday, December 16, 2015 9:56 AM
    Moderator
  • I will clarify the steps to repeat.  Method 1 (that works but I don't like):

    1. Open Developer Command prompt for Visual Studio 2015
    2. Type into command prompt "devenv".  (this will launch visual studio 2015)
    3. In the opened visual studio by the comman prompt open the project that I want and hit build. (This works)

    Method 2 (that doesn't work but is the prefered way):

    1.   Open Visual Studio 2015 from Start menu
    2.  Open my project from this Visual Studio and hit build (this doesn't work)

    Now, since the problem is that 'LIB.exe' is not recognized as an internal or external command . which is a standard command prompt error when an application cannot be found (because I am not in the directory that contains the executable or it is not in the PATH ), I assume that by performing Method 2 some variables are not transfered. Therefor the bug is that as you say "As far as I know, open Visual Studio directly is the same with opening with Developer Command Prompt window." this is probabbly not true and that is the problem (why am I even posting this). 

    By the way the MSBuild Command Prompt for VS2015 (not the Developer Command Prompt for VS2015 ) also doesn't know about lib.exe

         


    Wednesday, December 16, 2015 10:56 AM
  • By the way I am uploading a sample project to demonstrate the problem here: https://drive.google.com/open?id=0B9D-uPFAMSznY2VfdHhCUTZYOUU . If you open the Lol.vcxproj there is an initial target LibTest just to show you if it is possible to issue Lib.exe from a build.

    By following method 1 in my previous post you get the followingresult: https://drive.google.com/file/d/0B9D-uPFAMSzneG9ZNEctMWdRcWs/view

    By following the method 2 in my previous post you get the following result:

    https://drive.google.com/file/d/0B9D-uPFAMSznWElJeXpJYmkyRkE/view

    Both builds failed but what is important that in first method Lib.exe was found and in second was not. I have 2 collegues with the same issue and we both have Visual Studio installed in a different path than C:\Program Files(x86).  I have another collegue that has it in the default location and it works for him. So I assumed maybe the path was hardcoded so I tryied to create a directory junction to make it look like the visual studio is also in the default location. That didn't help neither.

    Wednesday, December 16, 2015 11:35 AM
  • Hi MartinKosicky,

    >>Now, since the problem is that 'LIB.exe' is not recognized as an internal or external command

    I often get this message when the exe doesn't exist in that path and I run it without administrator. You have confirmed it exist, so please make sure you are running your project as administrator and current user has full permission to access all your project files including this Lib.exe.

    Besides, in C++ project, if you want to invoke a exe file, this file should be stored in the project path. If it stored in another path, please assign the absolute path. Please check the path of Lib.exe file.

    In addition, I have tested your sample project with Visual Studio 2015 installed on C:\, I get an error of "The command Lib.exe exited with code 9009". But I don't have a computer, I need to build a environment to try another situation that run it with Visual Studio 2015 installed on D:\ and I will report the test result after testing.

    According to the situations of your colleagues and yours, I think it should be caused by the installation path of Visual Studio.

    Best Regards,
    Weiwei

    Thursday, December 17, 2015 6:57 AM
    Moderator
  • Hi MartinKosicky,

    I have tested your project on my new build computer which installed Visual Studio on D:\. And I get the same error of "The command Lib.exe exited with code 9009", not the "'LIB.exe' is not recognized as an internal or external command".

    So I think it should not related to Visual Studio installation path. As my previous reply said, please check the path of Lib.exe file whether it stored in correct path.

    Best Regards,
    Weiwei

    Tuesday, December 22, 2015 3:25 AM
    Moderator
  • Hello, The problem seems to be fixed.  We had to add:

    <Target Name="Build" DependsOnTargets="SetBuildDefaultEnvironmentVariables

    Then all started to work. We didn't wanted to add Lib.exe to PATH because we have multiple versions of Visual Studio.  (2010, 2013 and 2015).  What was strange though that on 2010 we didn't have this problem, the problem was when we migrated to 2015.

    Thanks


    Tuesday, December 22, 2015 9:56 AM
  • @Weiwei, @MartinKosicky - Please do not close any Antivirus, just add an exception to the antivirus software. This will stop any interruptions. 

    Regards.  

    Wednesday, December 23, 2015 12:31 AM
  • Hi MartinKosicky,

    I'm glad that you have resolve your problem and thanks for sharing your solution here. Please mark your reply as answer. It is benefit to other communities who has the same problem.

    If any questions about Visual Studio IDE, please feel free to come back to our forum.

    Best Regards,
    Weiwei

    Wednesday, December 23, 2015 1:14 AM
    Moderator
  • Hi Antivirustalk,

    Thanks for your suggestion.

    We close Antivirus just used to make sure whether this problem occurs with Antivirus. If yes, we can add an exception to the antivirus software as you suggested. Thank you again.

    Best Regards,
    Weiwei

    Wednesday, December 23, 2015 1:16 AM
    Moderator