I have a python script which runs and generates a version-file. I use the following as a pre-build event for my project:
call python version.py
this works fine given that I have python installed and the file can be found. However, for users that don't, it throws an error and cancels the build.
Is there a way to make it so the visual studio just silently ignores the build event if the python-command is not found or the python-file is not found?
One option would be to wrap the call to python in a .bat file which will exit with 0 if python is not found, and replace the pre-build step with calling this .bat file.
An example of such a test could be:
python --version >nul
if errorlevel 1 exit 0
Related
I need to link GDAL library to a c++ project.
I use the instruction from here:
http://trac.osgeo.org/gdal/wiki/GeneratingVisualStudioProject
Download gdal231.zip from official web site. Unpack.
(this step may be omitted — result will be the same) Edit nmake.opt by adding this in the very top of the file:
MSVC_VER=1910
WIN64=1
(don't know if it's right; there is no thorough guide)
Run win cmd, type "generate_vcxproj.bat 15.0 64 gdal_vs2017", wait for finish.
Open gdal_vs2017.vcxproj with MSVS Community 15.8.4. Build solution.
Build failed with "fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory".
Project settings look strange:
1
"VC++ Directories" seem normal, except $(VC_SourcePath) in "Library Directories":
2
What's wrong with it?
In order to build GDAL one doesn't need a Visual Studio project. Don't know what's wrong with "generate_vcxproj" script — it just does'nt work. But there is another way.
Unpack gdal231.zip.
Launch "x64 Native Tools Command Prompt for VS 2017" (or whatever version of VS command prompt that suits your needs). cd to "gdal-2.3.1\" dir.
Open nmake.opt file. In it's beginning there are some hints for usage of makefile.vc. Pick some arguments from there. I opt for x64 release build, so my call to nmake was like that: "nmake -f makefile.vc MSVC_VER=1910 WIN64=1". (1910 is a version of Visual Studio 2017).
Switch to "Native tools command prompt" and type "nmake -f makefile.vc MSVC_VER=1910 WIN64=1" there. Enter.
When it's finished, type "nmake -f makefile.vc MSVC_VER=1910 WIN64=1 install" and press Enter.
When that's finished too, type "nmake -f makefile.vc MSVC_VER=1910 WIN64=1 devinstall" and press Enter.
Done. The library is in C:\warmerda\bld\ folder.
I got the same problem when building with VS2017 Community Edition. I was able to build fine using VS2015 Community Edition.
Bottom line: when running the .bat, use the 2015 option.
Modify the generate_vcxproj.bat file using the information from here:
https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B#Internal_version_numbering
I modified mine to work with Visual Studio Community 2019 by modifying lines 55-70 to be this:
if "%_vcver_%"=="16.2" (
set _clver_=1922
set _vstoolset_=v1422
) else if "%_vcver_%"=="15.0" (
set _clver_=1910
set _vstoolset_=v141
) else if "%_vcver_%"=="14.0" (
set _clver_=1900
set _vstoolset_=v140
) else ( if "%_vcver_%"=="12.0" (
set _clver_=1800
set _vstoolset_=v120
) else (
echo Wrong value for parameter 1. See usage:
goto :usage
))
I'm trying to build a cross platform project for Ubuntu. In my makefile I have the line
"PSPSDK=$(shell psp-config --pspsdk-path)"
which gives the error "psp-config: Command not found."
psp-config is in my path and running make from the Ubuntu system on the files that get copied over from Visual Studio works fine. It also works if I manually ssh into the Ubuntu system from windows and run the command from there.
Why can't it find the command when run through Visual Studio?
You should update PATH at the beginning of "~/.bashrc" file (and not at the end) because it starts with somethign like:
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
Also, if you add code before these lines, it will be invoked for every subshell execution, so it is better to add a guard for it as well so it is invoked only once per session:
if [ -z $HOME_OPT_PATH_SET ]; then
export PATH=$PATH:$HOME/opt
export HOME_OPT_PATH_SET=1
fi
# If not running interactively, don't do anything
...
I'm using VS2010 on Windows 7 Ultimate x64.
I want to build multi-project in one solution automatically.
For example : )
Solution StormSolution contains 4 projects.
1 : Storm_Module1 (output file extension : dll)
2 : Storm_Module2 (output file extension : dll)
3 : CombineModule12 (output file extension : dat)
4 : ConvertModule2CFGFile (output file extension : cfg)
Step 1,2 : A result of Storm_Module1 and Storm_Module2 are Standard Windows DLL.
Step 3 : A result of CombineModule12 is open Storm_Module1.dll and Storm_Module2.dll to make "combined.dat" file, like cmd.exe /c copy /b storm_module1.dll + storm_module2.dll combined.dat command.
Step 3-1 : Then, make combined.dat file into encrypted_combined.dat file with encryption_tool.
Step 4 : Open "encrypted_combined.dat" file and make it into own specified cfg file.
The problem occurs on Step 4. I can't build solution storm automatically.
Because I've to make "combined.dat" result of Step3 into "encrypted_combined.dat" with encryption_tool.
So, if I build Storm solution without any action, ConvertModule2CFGFile project can not open latest updated encrypted_combined.dat.
How can I execute encryption tool before on Step4.
Encryption tool can be executed with parameters.
ex:) cmd.exe /c "encryption tool.exe -mode_crypt combined.dat -output encrypted_combined.dat.
Is it impossible to execute process before build project?
In Visual Studio you can create Post-Build Events which can execute a batch file. Use that to combine your two DLLs.
To make your projects build in the correct order, adjust Build Dependencies and Build Order in your Solution/Projects.
Consider writing a batch file for Visual Studio Command Prompt - it will enable you to build solutions 1 & 2 first, then you can perform any operation on files you like and call your encryption tool easily, and then build the last solution.
This thread should get you started:
How to create a Batch File for Visual Studio Command Prompt
everyone. I am compiling DCMTK 3.6.1 in Visual Studio 2013. My OS is Windows 8. I also used CMake 3.2.3. I have already successfully compiled both x64 versions of debug and release for the ALL_BUILD project. However, for the INSTALL project, I can't compile it because the following error occurs:
Error 1 error MSB3073: The command "setlocal
"C:\Program Files (x86)\CMake\bin\cmake.exe" -DBUILD_TYPE=Release -P cmake_install.cmake
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
:VCEnd" exited with code 1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets 132
According to this link, I need admin rights. But I am already running Visual Studio in Admin mode. Can someone please enlighten me on what I might be doing wrong? Thank you very much!
What about specifying another value for CMAKE_INSTALL_PREFIX in the CMake GUI? That means, a directory where you definitely have write access.
This is an old post, but I encountered the same problem when I attempted to install OpenCV for Windows 10 using VS 16 2019 in a folder close to the root of C:.
Solution: Open cmd as administrator, open the SLN-project (In my case <OpenCV.sln>), and run Build on INSTALL. That worked like a charm.
This is a simple 2 step fix.
First step is to remove the Read Only folder property. To do this, just go wherever you cloned the software you want to build, right click on the containing folder and uncheck the Read Only checkmark.
Second step is to exit visual studio and start terminal as administrator/with sudo privileges if on linux/mac. Navigate to the build folder and type the solution name. This will open up VC with admin privileges.
This fixed the problem for me.
Just open a prompt and run "C:\Program Files (x86)\CMake\bin\cmake.exe" -DBUILD_TYPE=Release -P cmake_install.cmake (or similar showed in VS error list) and see where is the problem
in my case the problem was samples were not compiled, so i entered in modules directory and compile manually each module necessary.
After compile the module i run the command again and see what happen, repeat until solve the problem
the best solution;
CMAKE_INSTALL_PREFIX
if you choose realease/debug then after CMake configure by CMake on the same mood.
just try
I had a similar error, if you can check that there are no spaces or character symbols in your path. FOr example I had a directory with the file name 'ABC&D' and by removing & the error was fixed.
This coupled with allowing admin rights should be an attempt to fix the problem.
Its kinda an odd story. I'm trying to build the openssl library. Well, it is not the first time I'm doing it and until now it was fine. however, I've desided to add a build configuration to TeamCity (actually the problem has nothing to do with TeamCity)to build all my third parties libraries on-demand. So, I created a step with common set of openssl build commands:
perl Configure VC-WIN64A
ms\do_win64a.bat
nmake /d /f ms\ntdll.mak
... and the build failed while assembling the very first asm file. So I ran same commands in VS2012 x64 command prompt and the build succedeed, as expected. It took a while untill I figured out that the problem is in output redirection. Teamcity redirects output from build step to the teamcity build log, so did I by adding ">1.txt" to "nmake /d /f ms\ntdll.mak" command, and the build failed. I would say it is somewhat unexpected reason for build to fail.
So far, I've tried:
Building the same from VS2010 command prompt with redirection,
failed.
Building the same from VS2010 command prompt without
redirection, succeded.
Building the same from VS2010/VS2012 command
prompt with redirection to file and forcing redirection to CON (nmake
/d /f ms\ntdll.mak >CON >1.txt) failed.
Googling for "nmake problems
when console output is redirected" - nothing
Googling for "openssl
build problems when console output is redirected" - nothing
My setup
- Win2008R2, virtual machine.
- VS2010, latest updates
- VS2012, Update 1
Actual error:
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\amd64\ml64.EXE"' : return code '0x1'
ml64.exe complains about the asm file stating it should end with "END" statement. It does, but...
Any ideas?
Ok, since the problem is in perl and writing files to stdout and then redirecting it you have to change following files to build x64 version:
crypto\aes\asm\aes-x86_64.pl
crypto\bn\asm\modexp512-x86_64.pl
crypto\bn\asm\x86_64-gf2m.pl
crypto\bn\asm\x86_64-mont.pl
crypto\bn\asm\x86_64-mont5.pl
crypto\md5\asm\md5-x86_64.pl
crypto\modes\asm\ghash-x86_64.pl
crypto\rc4\asm\rc4-md5-x86_64.pl
crypto\rc4\asm\rc4-x86_64.pl
crypto\sha\asm\sha1-x86_64.pl
crypto\sha\asm\sha512-x86_64.pl
crypto\whrlpool\asm\wp-x86_64.pl
crypto\x86_64cpuid.pl
engines\asm\e_padlock-x86_64.pl
you have to open these files and change all "open STDOUT "whateverfile"" to something like "open my $asmfile "whaeverfile"", then take care of string concatenation (only in x86_64cpuid.pl) and then print it to the file instead of STDOUT, something like "print $code" to "print $asm $code"
and of course, dont forget to close the file, in another words change the "close STDOUT" to "close $asmfile"
Obviously when building target other than x64 one will have to change another set of files.
Will try to communicate it to openssl maintainer.