Showing posts with label batch. Show all posts
Showing posts with label batch. Show all posts
Wednesday, October 09, 2019
Get SVN revision and write to header file
I am creating a C++ dll file from a MATLAB Simulink model. The simulink model repository is hosted on subversion. I needed a way to embed simulink model subversion revision to dll so that the dll could return that revision via an interface method to interested clients. I wrote the following batch file to fetch revision from SVN and write to a header file:
Thursday, August 01, 2019
Processing directory list in a Windows batch file
Handle a specific directory in current folder differently from other folders:
Note that if you only wanted to check if a directory existed, a simple EXIST would suffice.
Bonus: If you want to set the result of a command to a variable, you can use this. Note that you have to enclose the command with ` `, not ' '. This reminds me of my double quote problem in Visual Studio...
Note that if you only wanted to check if a directory existed, a simple EXIST would suffice.
Bonus: If you want to set the result of a command to a variable, you can use this. Note that you have to enclose the command with ` `, not ' '. This reminds me of my double quote problem in Visual Studio...
Friday, May 31, 2019
Build Visual C++ Project from Command Line
Previously I showed how to build a couple of files from command line. To build a whole Visual C++ project from command line, I tried msbuild. However, I had no luck with it because I got "error TRK0002: Failed to execute command...". Then I used devenv and it worked perfectly. The following batch script did the job from a normal command line:
@DevEnvDir="c:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\"
@set PATH=%DevEnvDir%;%PATH%
@cd c:\temp\DeleteMe
@call devenv DeleteMe.sln /build "Release|x86"
@DevEnvDir="c:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\"
@set PATH=%DevEnvDir%;%PATH%
@cd c:\temp\DeleteMe
@call devenv DeleteMe.sln /build "Release|x86"
Wednesday, April 10, 2019
Windows: Build C++ from command line
If you have Visual Studio 2017, to build a C++ project from a "normal" - not developer - command line:
- Add the following to system path:
- To use cl.exe: c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\bin\Hostx64\x64\
- To use vcvars64.bat: c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\
- Open a command window and issue the following commands
- vcvars64
- If you are in a drive other than C:, let's say D:, you have to issue the command D: because after vcvars64, the drive reverts to C:
- cl a.cpp b.cpp
set PATH=%PATH%;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\bin\Hostx64\x64\;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\
call vcvars64
d:
call cl API.cpp Main.cpp
Note that there should be no whitespace after "PATH=" and the additional two paths should not be enclosed with quotation marks.
Subscribe to:
Posts (Atom)
