I am using CMake to generate my Visual Studio project files. I wanted to see if I could "trick" Visual Studio into also compiling for Linux using Bash on Ubuntu on Windows from Windows 10, so I created a small dummy project with the following CMakeLists.txt:
cmake_minimum_required (VERSION 3.5)
project(linux)
set(BASH_EXE C:/Windows/System32/bash.exe)
add_custom_target(Linux ALL
COMMAND ${BASH_EXE} -c "make -C ${CMAKE_SOURCE_DIR}/build"
)
To my surprise, this actually got the job done and created a project called Linux which ran the above command. Unfortunately that command crashed with this error:
'C:\Windows\System32\bash.exe' is not recognized as an internal or external command, operable program or batch file.
But I can run this exact command from my cmd prompt and it works fine:
C:\Windows\System32\bash.exe -c "make -C build"
Why can't Visual Studio/CMake find the bash executable?
This was probably the dumbest issue I've encountered... This blog post is what led me to the answer: http://www.samlogic.net/articles/sysnative-folder-64-bit-windows.htm
The problem was with how Windows handles 32-bit vs 64-bit programs: it keeps 64-bit programs in System32 and 32-bit programs in SysWOW64. Only 32-bit programs can see SysWOW64 and only 64-bit programs can see System32. If a 32-bit program needs a program in System32, it has to use the pseudo-folder called sysnative.
Turns out Visual Studio was launching my CMake commands in a 32-bit shell, meaning it couldn't find a program in C:/Windows/System32/
So I had to change my CMakeLists.txt to this:
cmake_minimum_required (VERSION 3.5)
project(linux)
set(BASH_EXE C:/Windows/sysnative/bash.exe)
add_custom_target(Linux ALL
COMMAND ${BASH_EXE} -c "make -C ../../build"
)
Unfortunately because of the nature of the CMAKE_SOURCE_DIR variable, I had to change this to use a relative path instead of an absolute one (CMAKE_SOURCE_DIR expands to the Windows path, not the Linux path).
Related
I'm encountering a very frustrating error while trying to build OpenSSL on Windows 10. The error I get is
"lib" /nologo /out:providers\libdefault_static.lib #C:\Users\jcava\AppData\Local\Temp\nmF1AF.tmp
providers\common\libdefault-lib-bio_prov.obj : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64
The steps I'm doing are running perl Configure VC-WIN64A then nmake both within the openssl directory that I cloned from Github. Im running all of this within a x64 command line prompt for VS 2019.
Cheers,
James
For x64 you have to run your perl Configure and nmake commands from
x64 Native Tools Command Prompt for VS 201x, not the Developer Command Prompt for VS 201x.
You can search for it in your Windows search bar. Make sure to right click it and run it in administrator mode.
If you've already compiled it incorrectly, you probably have to delete openssl and clone it again. Deleting the .obj files didn't solve it for me.
Source
I had similar problem. It means that there are some object files that have been compiled already using x86 (in this case). Perhaps you started off using the x86 compiler.
If you delete all the object files (type del /S *.obj in your openssl directory) then run nmake again it should compile fine.
Alternatively you could re-clone the repository and start again.
I installed the non-commercial intel Fortran 2018 in Windows 10. According to the starting guide, I should run psxevars.bat. But when I typed 'psxevars' in cmd. It showed 'psxevars command not found'. So I used another way, double clicking it in windows. Then I try ifort in cmd. It doesn't work. It showed 'ifort command not found'. How can I make it work? Btw, I used the cmd in the product group from start menu.
First, make sure Visual Studio (e.g. Visual Studio Community 2015 version) is installed before installing Intel Parallel Studio.
After installing Intel Parallel Studio successfully, a "command line prompt" should be listed at the start menu like this:
There is no need to run psxevars.bat because the installing process has already done this for us.
Another situation might be that we try to use Intel tools in Windows command-line prompt through the cmd command. In this case, we need to run psxevars.bat. And do not forget to specify two arguments, arch and vs, as shown in below.
And notice that it only takes effects in this command-line window, i.e. the same running need to be done for every cmd command-line prompt.
an eternal way is to set the environment variable. Add directories containing Intel tool executables to the "PATH" environment variable, and other related things(libs, include).
On Windows, I recommend using Intel Parallel Studio with the Visual Studio IDE.
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
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:
I'm using
cd C:\Program Files (x86)\Microsoft Visual Studio\VB98
vb6.exe /make Project1 /out %1
To basically compile my application, and I'm getting a compatibility issue (Saying doesn't work on my type of windows).
When compiling with the VB6 IDE (Make .exe) that works perfectly on my machine but this isn't, does anybody know how to fix this? Thanks
Error I receive when trying to open executable: "This version of this file is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need a x86 32-bit or a x64 64-bit version of the program, the contact the software publisher".
& It's a standard EXE application also.
I've tried running it as a administrator, trouble shooting / changing the compatibility to windows XP service pack 2 & 3, still didn't work.
Work prefer a good fix to this, like if there's anything I can do via console as a option or something or some option or anything.
Cheers! Please help ASAP
From the discussion in the comments, I believe the answer here is as follows (as identified by GSerg):
The problem is your use of the /make switch on the command line. The documentation says this about /out:
Outputs errors to a file when used with the /make or /makedll switch.
So, if you used vb6.exe /make Project1 /out Project1.exe, then Project1.exe would actually be a text file containing the error output from the compiler and thus would not be an actual executable, even though it had an .exe extension.
You actually don't specify the output binary when you use /make. The help output from running VB6.exe /? is a little more explicit:
Tells Visual Basic to compile projectname and make an executable file
from it, using the existing settings stored in the project file.
VB remembers the last filename and directory you used for compiling your project in the IDE, and it stores that in the .vbp file:
ExeName32="Project1.exe"
Path32="..\output"
I use a batch file to handle this issue. It sets the path to include both the 32-bit and 64-bit versions of the Program Files directories. Then just reference 'vb6.exe' and the correct one will be pulled from your path.
set PATH=c:"\Program Files (x86)\Microsoft Visual Studio\VC98\bin"
set PATH=%PATH%;c:"\Program Files (x86)\Microsoft Visual Studio\VB98"
set PATH=%PATH%;c:"\Program Files\Microsoft Visual Studio\VC98\bin"
set PATH=%PATH%;c:"\Program Files\Microsoft Visual Studio\VB98"
vb6 /m foobar.vpb