0

I'm trying to build a program in c++ using mysql.h

So i read that compiling with cmake is necessary. But as it seems cmake cant find visual's studio compilers even though I opened it through Developers command prompt.
This is the error that occurs:

The C compiler identification is unknown

The CXX compiler identification is unknown

CMake Error in CMakeLists.txt: No CMAKE_C_COMPILER could be found.

CMake Error in CMakeLists.txt: No CMAKE_CXX_COMPILER could be found.

Also, at cmake error list, it says :

Build started 22/12/2016 00:28:42.

The target "_ConvertPdbFiles" listed in a BeforeTargets attribute at "C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets (34,37)" does not exist in the project, and will be ignored.

The target "_CollectPdbFiles" listed in an AfterTargets attribute at "C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets (34,70)" does not exist in the project, and will be ignored.

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform‌​.targets(57,5): error MSB8020: The build tools for v141 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install v141 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution".

Theo.Fanis
  • 444
  • 6
  • 15
  • ***The target "_ConvertPdbFiles" listed in a BeforeTargets attribute at "C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets (34,37)" does not exist in the project, and will be ignored.*** I see this in some of my CMake builds. It does not seem to cause any issue. – drescherjm Dec 21 '16 at 22:55
  • ***Build started 22/12/2016 00:28:42*** It seems like it is building. ***CMake Error in CMakeLists.txt: No CMAKE_C_COMPILER could be found.*** errors usually prevent generation from working. – drescherjm Dec 21 '16 at 22:58
  • it is not building unfortunately... – Theo.Fanis Dec 21 '16 at 23:02
  • Done Building Project "~\target\CMakeFiles\3.7.1\CompilerIdC\CompilerIdC.vcxproj" (default targets) -- FAILED. Build FAILED. – Theo.Fanis Dec 21 '16 at 23:04
  • Maybe there is an error in the build output after the warnings that you listed. – drescherjm Dec 21 '16 at 23:07
  • you are right, after build failure it says that build tools cannot be found C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(57,5): error MSB8020: The build tools for v141 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install v141 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [~\target\CMakeFiles\3.7.1\CompilerIdC\CompilerIdC.vcxproj] – Theo.Fanis Dec 21 '16 at 23:11
  • I am not sure what the correct platform toolset is for Visual Studio 14 2015 however the V140 / V141 seems like it is part of the problem. – drescherjm Dec 21 '16 at 23:13
  • I think you picked the wrong generator for Visual Studio 14 2015. It looks like the platform toolset 141 is for the Visual Studio 15 2017 RC. – drescherjm Dec 21 '16 at 23:26
  • my visual studio says that its 15 2017. But if I use in cmake visual studio 14 2015 as a compiler, the configuration is done, and BUILD SUCCESS – Theo.Fanis Dec 21 '16 at 23:34
  • That is what I expected. This would be the reason for the compiler detection failure. Because of the wrong generator it was looking for the 2017 RC version of Visual Studio. – drescherjm Dec 21 '16 at 23:36
  • Thank you so much!!! I was so desperate... – Theo.Fanis Dec 21 '16 at 23:38

1 Answers1

0

From the comments. The problem was caused by using the wrong generator for Visual Studio 2015.

The correct generator for 32 bit code in Visual Studio 2015 is Visual Studio 14 2015 and for 64 bit code it is Visual Studio 14 2015 Win64.

drescherjm
  • 10,365
  • 5
  • 44
  • 64