none
MSBUILD only error

    Question

  • I have some old projects that still using something like auto_ptr. After I upgrade the solution to VS2017. The project can compile in VS2017 IDE without any errors. But it will fail with error " 'auto_ptr': is not a member of 'std'" when I use the MSBUILD command line to build the solution. I tried to set to use the C++14 in project settings. But the MSBUILD still have the same error.

    It seems the MSBUILD always use the C++17 to build the solution. Is there a way I can set the MSBUILD to use the C++14 to build the solution?


    Thanks.

    Thursday, November 16, 2017 7:11 PM

Answers

  • @YaoZhang, Glad to know that you have resolved this issue. Please mark your answer which is benefit to other communities who has the same problem. Thanks.

    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by YaoZhang Friday, November 24, 2017 4:17 PM
    Friday, November 24, 2017 5:59 AM

All replies

  • Hi YaoZhang,

    Thanks for posting here.

    >>>Is there a way I can set the MSBUILD to use the C++14 to build the solution?

    Where did you call MSBuild.exe? Is it calling from the path:C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin? And are you used C ++ 14 when you compile in VS2017 IDE without any errors?

    To my knowledge, if you have changed use C++14 in project settings in the IDE, MSBuild will use C++14 by default. You can unload the project and check if the ClCompile of  LanguageStandard  is stdcpp14 in the project file .vcxproj:

    Besides, we could not easily set use C++14 in the MSBuild Command line directly, because the “LanguageStandard ” is a ClCompile not PropertyGroup in the project file. You can add a target invoke MSBuild to pass an external parameter into the project file by MSBuild command line. You can refer to the similar question below:https://stackoverflow.com/questions/42091647/how-to-override-project-properties-on-the-command-line-using-msbuild/42153010#42153010

    hope this helps.


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, November 17, 2017 8:41 AM
  • Thanks, I will try that.

    Friday, November 17, 2017 11:51 PM
  • @Yao Zhang, Any update for this issue? Have you resolved your issue? If not, Please let me know the latest information about this issue.

    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 20, 2017 7:30 AM
  • Unfortunately, it's not working. I tried to add a target in the project file, but it still use the C++17 to build the project. Is there other way I can try? Otherwise, we will just have to use the C++17 and try to fix all the build errors.

    Monday, November 20, 2017 4:27 PM
  • @YaoZhang, You said "The project can compile in VS2017 IDE without any errors". Have you tried use C ++ 14 when you compile in VS2017 IDE? BTW, how did build the project with MSBuild?

    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, November 21, 2017 9:50 AM
  • In the IDE, if I leave the "C++ Language Standard" in the project options to be blank or select "ISO C++14 Standard", the build can finish without any error. If I select "ISO C++17 Standard", the build will fail with the same error I have when I use the MSBUILD.

    We use a command like this to run the MSBUILD, the solution is a mix of C++ and C# projects.

    "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild" "SOLUTION_NAME" /property:Configuration=Release /property:Platform="Mixed Platforms" /verbosity:minimal /p:CPPStandardSettings=stdcpp14

    I added the following in the .vcxproj file

    <ClCompile>
       ........
       <LanguageStandard>$(CPPStandardSettings)</LanguageStandard>
    </ClCompile>

    <Target Name="CPPBuild" Returns="@(ManagedTargetPath)">
       <MSBuild Projects="containr.vcxproj" Targets="Build" Properties="CPPStandardSettings=true"/>
    </Target>

    But it seems the MSBUILD still using the C++17 standard.

    Thanks,
    Yao

    Tuesday, November 21, 2017 4:57 PM
  • @YaoZhang, Thanks for your detail reply.

    Have you set the C++ Language Standard to "ISO C++14 Standard" with Configuration=Release on the properties options? I have noticed that you set your Configuration=Release in your MSBuild command line and the default configuration on the properties is Debug. If you set this argument under the default configuration Debug, when you build the project with configuration=Release, Visual Studio will still use C++17 standard.

    Hope this helps.


    MSDN Community Support Please remember to click Mark as Answer. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    Wednesday, November 22, 2017 10:44 AM
  • I just double checked. Both debug and release has the same settings. I tried to use "ISO C++14 Standard" in the project settings. Still the same.

    Thanks.

    Yao

    Wednesday, November 22, 2017 7:03 PM
  • Sorry, that not help you. I have no any other idea to troubleshoot this issue. Would mind share me the build error and a simple test sample so that I could reproduce this issue? Thanks. 

    MSDN Community Support Please remember to click &quot;Mark as Answer&quot; the responses that resolved your issue, and to click &quot;Unmark as Answer&quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 23, 2017 9:43 AM
  • I was able to update the code to compile using the C++17 standard in the IDE.

    Now I got another issue, the code was using 'auto_ptr' before. I replaced the 'auto_ptr' with 'unique_ptr'. The solution can build in IDE without errors. But when I build it with MSBUILD, I got an error "'unique_ptr' is not a member of 'std'".

    Could you please give me some idea what could cause this error?

    Thanks,

    Yao

    Thursday, November 23, 2017 5:36 PM
  • Never mind, I fixed it. It's missing a #include <memory> in one file.

    It's interesting the build in IDE can pass without that #include <memory>.

    Friday, November 24, 2017 5:31 AM
  • @YaoZhang, Glad to know that you have resolved this issue. Please mark your answer which is benefit to other communities who has the same problem. Thanks.

    MSDN Community Support Please remember to click &quot;Mark as Answer&quot; the responses that resolved your issue, and to click &quot;Unmark as Answer&quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by YaoZhang Friday, November 24, 2017 4:17 PM
    Friday, November 24, 2017 5:59 AM