What is the -D define to tell CMake where to find nmake? - windows

I have Visual C++ Build Tools 2015 | Standalone compiler, libraries and scripts installed on a low-end netbook. It's necessary, because the machine has a small eMMC soldered to the board with no real space available.
nmake is installed at %PROGRAM FILES%\Microsoft Visual Studio 14.0\VC\bin. However, CMake cannot find it when attempting to generate the Makefile. I'd like to use a -D to tell CMake what the makefile program is, but I am having trouble locating the list of -D defines for CMake.
For completeness, I'm trying to avoid other Microsoft tools. I have LLVM build tools at C:\LLVM\bin, so I'm setting CMAKE_C_COMPILER and CMAKE_CXX_COMPILER. But I needed nmake, because I can't find a stand-alone Make program for Windows already built.
What is the -D define to specify nmake for CMake?

The variable you are looking for is CMAKE_MAKE_PROGRAM.
If you try to set this variable plus CMAKE_C_COMPILER, CMAKE_LINKER_EXE, etc., this will still fail, because cl.exe and link.exe need some environment variables to be set. Those can be set by using a "Visual Studio * Command Prompt" (this uses vcvars.bat from the Visual Studio install directory).
To use Clang you can install a Clang toolset from http://llvm.org/builds/. Then you can specify CMAKE_GENERATOR_TOOLSET in a toolchain file.
Let me know how this works out for you.

CMAKE_MAKE_PROGRAM. See the documentation:

Related

CMake + MSVC build tools 2015 - what to do after invoking cmake?

I've never used CMake on Windows, or with MSVC, before; so this is a newbie question.
I've installed CMake and some minimal freely-downloadable "Microsoft Visual C++ build tools 2015" (from here) on a Windows 10 machine. I have my CMake-based project (which builds fine on Linux) checked out, and I'm ready to go.
So, in a shell window, I do:
PS C:\Users\joeuser\the_project> mkdir build
... etc. etc. ...
PS C:\Users\joeuser\the_project> cd build
PS C:\Users\joeuser\the_project\build> cmake ../
-- Building for: Visual Studio 14 2015
-- Selecting Windows SDK version to target Windows 10.0.15063.
-- lots of checks here
-- etc. etc.
and that's done. So far so good. But - what now? On a Unix'ish system, I would execute make, and perhaps make install; and maybe make clean later on. My questions are:
Do the MSVC tools I'm using have an equivalent of make? I've head about nmake and msys but I'm not sure those are relevant here.
What do I do now in order to build, install or clean the build directory?
Is it better/easier/more common practice to use a different CMake generator in my scenario?
Making my previous comments an answer:
You would then call the underlying build tool directly via CMake:
cmake --build . --target ALL_BUILD --config Debug -- /nologo /verbosity:minimal
This gives you an almost quiet build process as you are used to from make.
Why the hell do I have to provide so much arguments to CMake?
Because CMake is a build system generator and directs those arguments to the underlying build tool (make, MSBuild, nmake, ...). The underlying build tool may have different naming conventions for targets etc., e.g. make users provide almost always the targets all, clean, and install. But the Visual Studio solution generated by CMake uses by default ALL_BUILD, INSTALL, RUN_TESTS. There is no CLEAN target. Using MSBuild,
To install your solution you would select --target INSTALL.
For running tests, you would select --target RUN_TESTS.
For cleaning you have to use --target ALL_BUILD --config Debug -- /nologo /verbosity:minimal /t:Clean because the Visual Studio solution does not contain a clean target but MSBuild provides one.
Further important arguments of MSBuild are:
/maxcpucount:<numberOfCpus> (to limit the number of CPUs the build process is using) and
"/l:FileLogger,Microsoft.Build.Engine;logfile=<YOUR_LOGFILE_NAME>" to save MSBuild output to file.

Installing and using IPopt with Cygwin - or even better alternative?

I am new to the optimization field. Did some projects with fmincon though, and am now looking for an alternative usable in OpenSource, preferrably somehow usable in Python. Therefore I found IPopt. Any other suggestions which are equally good as fmincon?
I tried to install IPopt by compiling it. And I must say, it seems like a mess. I tried all version and ended up with the most promising one "Installation with Cygwin using the MSVC++ compiler " from the Manual. Therefore I have to install CYGwin and change the make.exe. Done.
Add the cl.exe from Visual Studio (Visual Studio 1 in my case) to the Apth environment. Done.
add "call "call "C:\Program Files (x86)\Microsoft Visual Studio 14\VC\vcvarsall.bat" " to the cygwin.bat. Done.
Now two things. When I do "./configure" with the downloaded IPopt sources I get: "configure: error: /bin/sh './configure' failed for Ipopt"
Also like suggested in the manual calling "./configure -enable-doscompile=msvc" to tell cygwin to use the windows compiler gives me "configure: error: --enable-doscompile=mscv not supported anymore."
So. Basically I am not able to install Ipopt. Using it seem like impossible, as all other methods to build it also failed on my Win10 64bit. It seems that the manual is outdated or I am not finding the corect way to do it, hope some of u guys probably can help. Compiling is something rather new and I am happy to learn.
Tahnks in advance.
Ensure that you have the following packages installed in Cygwin.
Devel: gcc
Devel: gfortran
Devel: pkg-config
Devel: subversion
Archive: unzip
Utils: patch
Web: wget
Utils: dos2unix
Assuming you are building for 64-bit, add path to cl.exe in Cygwin.bat (located in root directory of location where Cygwin was installed) so that msvc can be used from Cygwin –
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\vcvars64.bat" (vcvarsall needs you to specify architecture version)
You will need the Intel Fortran Compiler. It comes along with Parallel Studio. Free for students, faculty, open source contributors.
In .bash_profile (located in pathto/cygwin64/home/username/) add this line so that ifort recognizes msvc linker (path given above should be to link.exe of msvc) –
alias ifort='ifort -Qlocation,link,"C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64"'
Intel Fortran gets integrated to a visual studio shell. Run this shell. Execute cygwin.bat from this shell. Check the version of link (link --version). If it is not the microsoft linker, you may have to remove the Cygwin link.exe file from Cygwin folder.
Note that any other bash terminals (e.g. Git Bash) might interfere. You will come to know only while running the configure script. It tries to access packages from those bash terminals. You may have to place them elsewhere temporarily, so cygwin does not find them.
I understand you have read the manual, so you must have downloaded the required third-party tools for Ipopt (asl, lapck, blas and one linear solver) .
You can now run (in Ipopt root folder):
mkdir build
cd build
../configure --enable-msvc=MD
make
make install

CMake and Visual Studio with not default installation folder

I am trying to build something using CMake and VS 2012. The problem is I have my VS installation on D:\Pliki programów (x86)\Microsoft Visual Studio 11.0. I have no free space on my C drive.
CMake have problem with finding my VS. I tried to specify VS compiler cl.exe but it was asking for dll in the same folder anyway. I also tried to use specified toolchaing with vcvarsall.bat. But I am not sure if I am doing those things right.
I guess that I need to add VS location to CMake, but how? I tried setting PATH but it did not work.
And searching about that problem is difficult, all search engines think that I want to change installation path for my program that I want to build.
UPDATE
I've added variable_watch(CMAKE_MAKE_PROGRAM).
CMake Debug Log at CMakeLists.txt:3 (project):
Variable "CMAKE_MAKE_PROGRAM" was accessed using UNKNOWN_READ_ACCESS with
value .
CMake Debug Log at CMakeLists.txt:3 (project):
Variable "CMAKE_MAKE_PROGRAM" was accessed using MODIFIED_ACCESS with value
C:/Windows/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe.
The C compiler identification is unknown
The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:3 (project):
No CMAKE_C_COMPILER could be found.
In output file:
LINK : fatal error LNK1104: cannot open file 'MSVCRTD.lib'
Is CMake looking for libs in VS 11 installation folder? The thing is that VS installer put libs in C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64.
For cases like this (and similar), I keep a VCEnvCmd.bat in my source trees:
call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat" amd64 & %*
Executing that .bat without parameters will find and run vcvarsall.bat, setting up the environment for the amd64 target in the current shell (which you could change or parameterize according to your needs, like the version number embedded in that environment variable).
The nice trick is, for those Nightly / Continuous builds, you can use the .bat as a "prefix" for setting up the environment, e.g. in the task manager:
VCEnvCmd.bat ctest -S CTestScript.cmake,Nightly
The advantage is that you use what MSVC already gives you (the VS...COMNTOOLS variable), without having to clutter your environment further with persistent changes to PATH etc.

Compile CUDA without Visual Studio - "Cannot find compiler cl.exe in path"

I've just begun a small project in CUDA.
I need to know the following:
Is it possible to compile CUDA code without using/buying Microsoft Visual Studio?
Using Nvcc.exe I get the error "Cannot find compiler cl.exe in path".
I've tried to install a CUDA plugin for NetBeans, but it doesn't work. (with current version of NetBeans)
Platform: Windows 7
Thanks in advance.
Update
As noted in the comments, versions of the SDK after Windows 7's do not include the build tools. If you want to use Microsoft's most recent tools you have to install Visual Studio. Once installed, you can use the tools from the command-line.
At the moment the free versions are the "Community" versions, e.g. Microsoft Visual Studio Community 2015.
You can continue to develop apps for Windows 7 and earlier (and they will run on later versions of Windows) using the old SDK tools as I described before:
Original Answer
If you desperately want to avoid Visual Studio, download and install the Windows SDK. This contains (more or less) the same build tools as Visual Studio.
Then run the Windows SDK Command Prompt (which you'll find on the start menu under Microsoft Windows SDK) to set the path to point to the tools, and you are set.
Or just use Visual C++ Express.
Following the previous comments I've installed Studio Express & VS2010.
This did not solve the "cl.exe not in path" problem.
I solved the problem with the error Cannot find compiler cl.exe in path, by including
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64 in PATH,
before installing Windows SDK.
This question also contains valuable information.
For some reason VS2010 & Studio Express failed to set the proper variables in path even after the execution of vsvars32.bat.
Thank you all for your valuable help.
add this options to nvcc
nvcc x.cu <other options> -ccbin "D:\Program Files\Microsoft Visual Studio 11.0\VC\bin"
i use VS2012 and my cl.exe dir is here.
You have to figure out where NVIDIA GPU Computing Toolkit is installed.
In my system it's in "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe" Then
"Edit Environment Variables" on Windows.
Click on New...
Variable name: NVCC
Variable Value: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe
Click on OK.
Use windows subsystem for linux and install ubuntu and nvcc along with gcc and g++ using the ubuntu terminal in windows (gui does not works for linux subsystem for windows). Then configure .bashrc using bash and vim/nano with a 'cd' command to your desired location as it is done in usual linux terminal (makes it easy as bash opens in system32 folder everytime). And then you can compile .cu files using nvcc over bash. As nvcc supports gcc and g++ under linux so it solves the problem. No need to sacrifice peace for switching over to linux or dealing with crappy visual studio. It worked for me.

Using boost 1_47 with Visual C++ Express 2010

I have installed and built (successfully as far as I can tell), boost 1_47_0. I am now trying to get the sample program (the regex one) with their install guide to run and it is giving me the following link error:
LNK2019: unresolved external symbol "private: class boost::basic_regex ....
I suspect that the problem is that the libraries were built as vc100 using b2 and the Platform Toolset is Windows7.1SDK. I cannot change the Platform Toolset to v100 or it generates a kernel32.lib missing error. And I cannot seem to figure out how to build boost so that it is sdk7. I am using Visual C++ Express 2010 and have also tried building from the Windows7.1SDK command line prompt.
Any ideas?
I meet the same issue when I install boost with installer from "BoostPro Computing". And I solve it by compiling boost lib from source code.
Here is the steps:
enter Visual Studio 2010 Express Command Prompt
cd to the unzipped boost dir
bootstrap.bat
.\b2
Done.
Here is my environment:
Win7 64bit
Visual Studio 2010 Express
boost 1_52_0
I build boost using a batch file that calls bjam, and I have not had any problems using the regex library in my projects. I am using VS2010 Pro. Here are the lines from my batch file, the extra library locations might not be important to you, I'm just putting them here for completeness:
call "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
SET ZLIB_SOURCE=%LIBS%\zlib
SET ZLIB_INCLUDE=%LIBS%\zlib
SET BZIP2_SOURCE=%LIBS%\bzip2-1.0.5
SET BZIP2_INCLUDE=%LIBS%\bzip2-1.0.5
SET BZIP2_BINARY=libbz2
SET ZLIB_BINARY=zdll
SET EXPAT_INCLUDE=%LIBS%\Expat\Source\lib
SET EXPAT_LIBPATH=%LIBS%\Expat\Bin
SET EXPAT_BIN=%LIBS%\Expat\Bin
bjam.exe --disable-filesystem2 --build-type=complete --user-config=%UTILS%\user-config.jam
Of course the path to your libraries and your user-config.jam will be different, and the only one line in user-config.jam that is really important is:
using msvc : 10.0 ;
After a successful build you will want to add the path to the stage/lib directory to you additional libraries settings for the project so the linker is satisfied. Also since this is an express build you may have to fiddle with the include path to pick up the platform SDK. I run this batch file from the top level Boost directory.

Resources