FreeRTOSv9.0.0版本WIN32-MSVC工程使用VisualStudio2012编译报错解决
- 前言=废话
对于喜欢FreeRTOS的人来讲,纯碎研究kernel的task机制,如果可以不依赖于硬件,无论从调试手段,还是调试速度,纯软件调试非常方便。FreeRTOSv9.0.0源码基于强大的VisualStudio工具提供了MSVC项目,可以在PC端直接模拟调试。 - 问题描述
最近抽空研究下FreeRTOS,安装好Visual Studio 2012,打开工程文件FreeRTOSv9.0.0\FreeRTOS\Demo\WIN32-MSVC\WIN32.vcxproj,编译,居然有错,如下: - VC下详细错误
1>------ Build started: Project: RTOSDemo, Configuration: Debug Win32 ------
1>Project file contains ToolsVersion="14.0". This toolset may be unknown or missing, in which case you may be able to resolve this by installing the appropriate version of MSBuild, or the build may have been forced to a particular ToolsVersion for policy reasons. Treating the project as if it had ToolsVersion="4.0". For more information, please see http://go.microsoft.com/fwlink/?LinkId=291333.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Platform.targets(44,5): error MSB8020: The builds tools for v140 (Platform Toolset = 'v140') cannot be found. To build using the v140 build tools, either click the Project menu or right-click the solution, and then select "Update VC++ Projects...". Install v140 to build using the v140 build tools.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
- 解决方案
以为自己的VC2012有问题,自己新建个工程编译,success。网上搜索相关错误也没有找到解决方案,最后硬着头皮看完错误信息,大体意思就是没有找到当前solution (project)相对应的的工具版本,当前工具版本不符,根据理解和第一反应,修改配置信息,解决问题。方法如下:
1 - 右击 “RTOSDemo”, 选择 “Properties”;
2- 查看”Configuration Properties” -> “General”,发现”Platform Toolset” 参数是 “v140“,这个v140在编译错误里面出现过(错误信息:The builds tools for v140 (Platform Toolset = ‘v140’) cannot be found.),发现问题点。
3- 点”v140”右边下拉框,发现”Visual Studio 2012(v110)”,即本机安装的VS信息,选中它,确定。
4- 重新编译,成功。
1>------ Build started: Project: RTOSDemo, Configuration: Debug Win32 ------
1>Project file contains ToolsVersion="14.0". This toolset may be unknown or missing, in which case you may be able to resolve this by installing the appropriate version of MSBuild, or the build may have been forced to a particular ToolsVersion for policy reasons. Treating the project as if it had ToolsVersion="4.0". For more information, please see http://go.microsoft.com/fwlink/?LinkId=291333.
1> Run-time-stats-utils.c
1> main_full.c
1> main_blinky.c
1> tasks.c
1> queue.c
1> port.c
1> list.c
1> main.c
1> timerdemo.c
1> TaskNotify.c
1> StaticAllocation.c
1> semtest.c
1> recmutex.c
1> QueueSetPolling.c
1> QueueSet.c
1> QueueOverwrite.c
1> QPeek.c
1> PollQ.c
1> IntSemTest.c
1> integer.c
1> Generating Code...
1> Compiling...
1> GenQTest.c
1> flop.c
1> EventGroupsDemo.c
1> dynamic.c
1> death.c
1> countsem.c
1> blocktim.c
1> BlockQ.c
1> AbortDelay.c
1> timers.c
1> heap_5.c
1>d:\freertos\freertos\freertos\source\portable\memmang\heap_5.c(344): warning C4146: unary minus operator applied to unsigned type, result still unsigned
1> event_groups.c
1> croutine.c
1> trcUser.c
1> trcKernelPort.c
1>d:\freertos\freertos\freertos-plus\source\freertos-plus-trace\trckernelport.c(121): warning C4305: '=' : truncation from 'int' to 'objectHandleType'
1> trcKernel.c
1> trcHardwarePort.c
1> trcBase.c
1> Generating Code...
1> WIN32.vcxproj -> D:\FreeRTOS\freertos\FreeRTOS\Demo\WIN32-MSVC\.\Debug\RTOSDemo.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
- 2016.9.27更新
最近发现,有些工程在第一次打开的时候,会提示更新VC++编译器和库,点击更新”update”,也能自动更新到和当前VS版本匹配的设置。
- 小结
分析,该错误是因为WIN32-MSVC工程文源件不是由VS2012创建,首次使用VS2012打开需要重新配置。
对于一些类似VS这种强大的工具,如果遇到错误,一般情况根据错误提示,就能找到解决方案,Good Good Study English。
本文由VS软件圈(vssoft.net)发布,不代表VS软件圈立场,转载联系作者并注明出处:https://vssoft.net/vsazwt/VS2012anzhuangwenti/2020/0725/5127.html