Why is cmake behaving differently in powershell vs command line when generating 'NMake Makefiles'? [duplicate] - powershell

This question already has an answer here:
What does single-quoting do in Windows batch files?
(1 answer)
Closed 3 years ago.
When I load developer tools by:
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.7
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
and I try to generate build files for my C++ hello world app in CMD by:
cmake -G 'NMake Makefiles'
I get:
CMake Error: Could not create named generator 'NMake
Generators
Visual Studio 16 2019 = Generates Visual Studio 2019 project files.
Use -A option to specify architecture.
* Visual Studio 15 2017 [arch] = Generates Visual Studio 2017 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 11 2012 [arch] = Generates Visual Studio 2012 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 10 2010 [arch] = Generates Visual Studio 2010 project files.
Optional [arch] can be "Win64" or "IA64".
Visual Studio 9 2008 [arch] = Generates Visual Studio 2008 project files.
Optional [arch] can be "Win64" or "IA64".
Borland Makefiles = Generates Borland makefiles.
NMake Makefiles = Generates NMake makefiles.
NMake Makefiles JOM = Generates JOM makefiles.
Green Hills MULTI = Generates Green Hills MULTI files
(experimental, work-in-progress).
MSYS Makefiles = Generates MSYS makefiles.
MinGW Makefiles = Generates a make file for use with
mingw32-make.
# etc.
But if I switch to PowerShell by writing powershell in CMD and run the same command:
cmake -G 'NMake Makefiles'
it's working correctly:
-- The C compiler identification is MSVC 19.16.27027.1
-- The CXX compiler identification is MSVC 19.16.27027.1
# etc.
Any idea why cmake is working in PowerShell but not in CMD?

The Windows Command Prompt does not recognize single quotes as quoting characters. You must use double quotes instead.
Change
cmake -G 'NMake Makefiles'
to
cmake -G "NMake Makefiles"
and the problem will disappear.

Related

Problem with Builder Flutter for Windows version

I have trouble running the program in Flutter.
I also program with Visual Studio Code and when I try to debug for Windows it shows me this error:
Launching lib\main.dart on Windows in debug mode...
CMake Error: Could not create named generator Visual Studio 16 2019
Generators
Visual Studio 15 2017 [arch] = Generates Visual Studio 2017 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 11 2012 [arch] = Generates Visual Studio 2012 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 10 2010 [arch] = Generates Visual Studio 2010 project files.
Optional [arch] can be "Win64" or "IA64".
Visual Studio 9 2008 [arch] = Generates Visual Studio 2008 project files.
Optional [arch] can be "Win64" or "IA64".
Borland Makefiles = Generates Borland makefiles.
NMake Makefiles = Generates NMake makefiles.
NMake Makefiles JOM = Generates JOM makefiles.
Green Hills MULTI = Generates Green Hills MULTI files
(experimental, work-in-progress).
MSYS Makefiles = Generates MSYS makefiles.
MinGW Makefiles = Generates a make file for use with
mingw32-make.
Unix Makefiles = Generates standard UNIX makefiles.
Ninja = Generates build.ninja files.
Watcom WMake = Generates Watcom WMake makefiles.
CodeBlocks - MinGW Makefiles = Generates CodeBlocks project files.
CodeBlocks - NMake Makefiles = Generates CodeBlocks project files.
CodeBlocks - NMake Makefiles JOM
= Generates CodeBlocks project files.
CodeBlocks - Ninja = Generates CodeBlocks project files.
CodeBlocks - Unix Makefiles = Generates CodeBlocks project files.
CodeLite - MinGW Makefiles = Generates CodeLite project files.
CodeLite - NMake Makefiles = Generates CodeLite project files.
CodeLite - Ninja = Generates CodeLite project files.
CodeLite - Unix Makefiles = Generates CodeLite project files.
Sublime Text 2 - MinGW Makefiles
= Generates Sublime Text 2 project files.
Sublime Text 2 - NMake Makefiles
= Generates Sublime Text 2 project files.
Sublime Text 2 - Ninja = Generates Sublime Text 2 project files.
Sublime Text 2 - Unix Makefiles
= Generates Sublime Text 2 project files.
Kate - MinGW Makefiles = Generates Kate project files.
Kate - NMake Makefiles = Generates Kate project files.
Kate - Ninja = Generates Kate project files.
Kate - Unix Makefiles = Generates Kate project files.
Eclipse CDT4 - NMake Makefiles
= Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - MinGW Makefiles
= Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Ninja = Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.
Exception: Unable to generate build files
Exited (sigterm)
flutter installed on my computer is the latest version 2.8.1.
There is also no error in installing the flutter. Thank
according to flutter documentation when you run flutter in windows
you need to have
Visual Studio 2022
see https://docs.flutter.dev/desktop
for more information

vscode cmake move from visual studio 17 to 19

I have been using vscode with the cmake integration for visual studio community edition 2017. I'm only using visual studio integration to vscode, not the IDE. I just moved to Vstudio 19. Now cmake is failing because I cannot get it to recognize that it should use the new visual studio. See error output below.
What is really interesting is that it's using the correct cmake.exe from the VS19 folder, but the parameter it uses is "-G "Visual Studio 15 2017" that is causing the problem. I removed the c_cpp_properties.json file (then CMake: Clean/Rebuild) in my .vscode folder which had a reference to VS17 and that didn't help.
I've tried to remove all the extensions (C/C++ Extension Pack), checked every folder/file in my projects for references to that VS 17. Removed the build folder and CMake: Clean/Rebuild after reinstalling the extensions..
[variant] Loaded new set of variants
[kit] Successfully loaded 4 kits from C:\Users\wood\AppData\Local\CMakeTools\cmake-tools-kits.json
[main] Configuring folder: mycode
[proc] Executing command: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -Hc:/Users/wood/mycode/build -G "Visual Studio 15 2017" -T host=x64 -A win32
[proc] Executing command: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -Hc:/Users/wood/mycode -Bc:/Users/wood/OneDrive/mycode/build -G "Visual Studio 15 2017" -T host=x64 -A win32
[cmake] Not searching for unused variables given on the command line.
[cmake] CMake Error at CMakeLists.txt:13 (project):
[cmake] Generator
[cmake]
[cmake] Visual Studio 15 2017
[cmake]
[cmake] could not find any instance of Visual Studio.
[cmake]
[cmake]
[cmake]
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "C:/Users/wood/OneDrive/mycode/build/CMakeFiles/CMakeOutput.log".
Any ideas where else that -G setting might be coming from?
Looked for 24 hours, posted a question, then solved in in the first five minutes.
I removed the file.
C:\Users\wood\AppData\Local\CMakeTools\cmake-tools-kits.json
Well, just renamed it.
Uninstalled the C/C++ extension pack, then re-installed the extension pack. It looked like there was a command to rescan for visual studio, but I missed that as it went by. When rebuilding the cmake I was asked to pick the architecture and everything is working again.
That rescan of visual studio, re-created the cmake-tools-kits.json file with the correct references.

How the lower version MATLAB to use high edition visual studio C compiler [For example: Matlab 2012b use visual studio 2013 compiler ] [duplicate]

This question already has answers here:
matlab compiler installation problems
(2 answers)
Closed 7 years ago.
i try to use SPArse Modeling Software [ Version: 2.5,matlab interface ], it need to compiler first.so i run the compiler.m in MATLAB 2012b .but it goes wrong.
Here is the log
>> compile
Warning: Directory already exists.
> In compile at 144
compilation of: -I./linalg/ -I./decomp/ -I./prox/ -I./dictLearn/ dictLearn/mex/mexArchetypalAnalysis.cpp
Error: Could not find the compiler "g++-4" on the DOS path.
Use mex -setup to configure your environment properly.
D:\PROGRA~2\MATLAB\R2012B\BIN\MEX.PL: Error: Unable to locate compiler.
Error using mex (line 206)
Unable to complete successfully.
Error in compile (line 440)
mex(args{:});
I guess the problem is the MATLAB 2012b mismatching the compiler in PC.
And I try to use visual studio 2013 as my the default C compiler for MATLAB 2012b.
when i using the mex -setup command.
only two choice as follow ,and do not see the visual studio 2013 compiler.
Select a compiler:
[1] Microsoft Software Development Kit (SDK) 7.1 in C:\Program Files (x86)\Microsoft Visual Studio 10.0
[0] None
I know MATLAB 2014b can use visual studio 2013 C compiler.
But how the lower version MATLAB to use high edition visual studio C compiler.
Someone else encountered this problem ?
My OS is windows 7 X64 , visual studio 2013 PRO, MATLAB 2012b.
I reference this ,but seems did't work.
Using Visual Studio 2013's C compiler for MATLAB
The compiler you are trying to use is not supported by your matlab version, you have to use one of the supported compilers.

Matlab r2013a doesn't recognize any compiler in order to protect a model

I have a problem with my r2013a Matlab.
I want to protect a model using Simulink.ModelReference.protect('test') command. For this
I have to configure my compiler. I'm using the mex -setup command, and the xpcsetCC -setup command.
At first, Matlab says that is all ok with the compiler, but when i try to execute the Simulink.ModelReference.protect('model') command it shows an erro saying that there is no compiler avaiable.
Here are the sequences of commands:
PART 1 - 'mex -setup'
INPUT
mex -setup
OUTPUT
Welcome to mex -setup. This utility will help you set up
a default compiler. For a list of supported compilers, see
http://www.mathworks.com/support/compilers/R2013a/win64.html
Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n?
INPUT
y
OUTPUT
Select a compiler:
[1] Intel C++ 12.0 (with Microsoft Software Development Kit (SDK) linker) in C:\Program Files (x86)\Intel\ComposerXE-2011\
[2] Intel C++ 12.0 (with Microsoft Visual C++ 2010 linker) in C:\Program Files (x86)\Intel\ComposerXE-2011
[3] Microsoft Software Development Kit (SDK) 7.1 in C:\Program Files (x86)\Microsoft Visual Studio 10.0
[4] Microsoft Visual C++ 2010 in C:\Program Files (x86)\Microsoft Visual Studio 10.0
[0] None
Compiler:
INPUT
4
OUTPUT
Please verify your choices:
Compiler: Microsoft Visual C++ 2010
Location: C:\Program Files (x86)\Microsoft Visual Studio 10.0
Are these correct [y]/n?
INPUT
y
OUTPUT
***************************************************************************
Warning: MEX-files generated using Microsoft Visual C++ 2010 require
that Microsoft Visual Studio 2010 run-time libraries be
available on the computer they are run on.
If you plan to redistribute your MEX-files to other MATLAB
users, be sure that they have the run-time libraries.
***************************************************************************
Trying to update options file: C:\Users\Guilherme\AppData\Roaming\MathWorks\MATLAB\R2013a\mexopts.bat
From template: C:\PROGRA~1\MATLAB\R2013a\bin\win64\mexopts\msvc100opts.bat
Done . . .
**************************************************************************
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the new
API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html
Building with the -largeArrayDims option enables the new API.
**************************************************************************
PART 2 - 'xpcsetCC -setup'
INPUT
xpcsetCC -setup
OUTPUT
Select your compiler for xPC Target.
[1] Microsoft Visual C++ Compilers 2010 Professional in C:\Program Files (x86)\Microsoft Visual Studio 10.0
[0] None
Compiler:
INPUT
1
OUTPUT
Verify your selection:
Compiler: Microsoft Visual C++ Compilers 2010 Professional
Location: C:\Program Files (x86)\Microsoft Visual Studio 10.0
Are these correct [y]/n?Y
Done...
Until now everthing is ok, but next there is an error:
Part 3 - Simulink.ModelReference.protect('test')
INPUT
Simulink.ModelReference.protect('test')
OUTPUT
### Model reference SIM target (test_msp.mexw64) for model test is out of date because test_msp.mexw64 does not exist.
### Updating model reference SIM target for model: test
Warning: The model 'test' does not have continuous states, hence Simulink is using the solver 'VariableStepDiscrete' instead of solver 'ode45'.
You can disable this diagnostic by explicitly specifying a discrete solver in the solver tab of the Configuration Parameters dialog, or by
setting the 'Automatic solver parameter selection' diagnostic to 'none' in the Diagnostics tab of the Configuration Parameters dialog
Warning: Using a default value of 0.2 for maximum step size. The simulation step size will be equal to or less than this value. You can disable
this diagnostic by setting 'Automatic solver parameter selection' diagnostic to 'none' in the Diagnostics page of the configuration parameters
dialog
### Build procedure for model: 'test' aborted due to an error.
Error using Creator.protect (line 287)
An installed compiler was not detected. Certain simulation modes, as well as host-based coder builds require that a compiler be installed. Please
install one of the supported compilers for this release as listed at:
http://www.mathworks.com/support/compilers/R2013a/win64.html
MATLAB must be restarted after the compiler is installed.
Error in C:\Program Files\MATLAB\R2013a\toolbox\simulink\simulink\+Simulink\+ModelReference\protect.p>protect (line 74)
[harnessHandle, neededVars] = protectedModelCreator.protect(varargin{:});
I've already tried all different choices of available compilers. I also tried to choose no for the fist question of mex -setup ("Would you like mex to locate installed compilers [y]/n?") and choose the compiler manually. None of this worked.

problems with creating an exe file in matlab

this is the session of building exe file in matlab 7.1.
I think I have a problem with the compiler.
mbuild -setup
Please choose your compiler for building standalone MATLAB
applications: Would you like mbuild to locate installed compilers
[y]/n? y
Select a compiler:
[1] Microsoft Visual C++ 2008 Express in C:\Program Files (x86)\Microsoft Visual Studio 9.0
[0] None
Compiler: 1
Please verify your choices:
Compiler: Microsoft Visual C++ 2008 Express
Location: C:\Program Files (x86)\Microsoft Visual Studio 9.0
Are these correct [y]/n? y
*****************************************************************************
Error: Could not find the 64-bit compiler. This may indicate that the
"X64 Compilers and Tools" or the Microsoft Windows Software
Development Kit (SDK) is not installed. To build 64-bit binaries,
Microsoft Visual C++ 2008 Express Edition requires that these two
packages be properly installed.
*****************************************************************************
Trying to update options file: C:\Users\****\AppData\Roaming\MathWorks\MATLAB\R2010a\compopts.bat
From template: C:\PROGRA~1\MATLAB\R2010a\bin\win64\mbuildopts\msvc90freecompp.bat
Done . . .
>> mcc -m mainmain.m -o mainmain
Could not find the compiler "cl" on the DOS path.
Use mbuild -setup to configure your environment properly.
C:\PROGRA~1\MATLAB\R2010A\BIN\MEX.PL: Error: Unable to locate compiler.
Error: An error occurred while shelling out to mbuild (error code = 2).
Unable to build executable (specify the -v option for more information).
??? Error using ==> mcc
Error executing mcc, return status = 1 (0x1).
if the problem is with the compiler, how can I install another compiler?
I have windows 7 (64 bits) and I want that the exe file will work on windows operating system.
This is probably the result of one of two issues.
1) You don't have the Windows SDK installed (as indicated in the error message). According to this MathWorks page regarding supported compilers
Both Microsoft Visual Studio 2008 and Windows Software Development Kit (SDK) 6.1 must be installed. When installing Microsoft Visual Studio, you must choose "X64 Compilers and Tools" when installing Microsoft Visual Studio; this is not selected by default.
Now, keep in mind, this reference is for the most recent release of MATLAB, but I'm betting that this information is still relevant to your issue.
You can download the SDK here.
2) It's also possible that the compiler that you're using simply isn't supported for your release of MATLAB. See here for info on supported compilers for MATLAB 7.1.