Compile project for both x86 and x64 from command line - visual-studio

I am making this question in regards to compiling both x64 & x86 builds at the same time. I am using MSVS 2012 ultimate and I have a 64-bit and 32-bit configuration for my EXE. I want to compile them both at the same time via the command line. Can someone give me a pseudo-translation on how I can approach this?

Related

Cross-compiling Rust project for Cortex-M4 in Windows

I'm having a hard time cross-compiling an embedded Rust project for Cortex-M4 in Windows. Going through the Embedded Rust book, I understood that it is needed to install the necessary target and toolchain. I'm trying to do this as follows (in a Windows cmd session):
> rustup target add thumbv7em-none-eabihf
info: component 'rust-std' for target 'thumbv7em-none-eabihf' is up to date
> rustup toolchain install stable-thumbv7em-none-eabihf
info: syncing channel updates for 'stable-thumbv7em-none-eabihf'
info: latest update on 2021-05-10, rust version 1.52.1 (9bc8c42bb 2021-05-09)
error: target 'thumbv7em-none-eabihf' not found in channel. Perhaps check https://doc.rust-
lang.org/nightly/rustc/platform-support.html for available targets
I do not understand the above error message. I have checked the provided link, and it seems that cortex-m4 is a "tier 2" target. I am suspicious that I have used the wrong toolchain prefix, e.g. "stable"?
Of course, if I skip the above and try to build the project with cargo build, it fails while looking for the wrong linker executable, i.e.:
error: linker `link.exe` not found
|
= note: The system cannot find the file specified. (os error 2)
note: the msvc targets depend on the msvc linker but `link.exe` was not found
note: please ensure that VS 2013, VS 2015, VS 2017 or VS 2019 was installed with the Visual C++ option
As a side note, the project builds fine on Linux and Macos.
Could someone shed some light on how to set up the toolchain and target correctly? Unfortunately, the Embedded Rust book does not dive into OS-specific toolchain installation.

GDB-Run Executable Doesn't Work (VS Code)

I am using VS Code for a C++ Project. I am also using CMake Tools to manage the CMake side of things and my compiler toolchains.
I have two separate compiler kits - i686-w64-mingw32 and x86_64-w64-mingw32 (gcc version 10.1.0).
I have set the gdb.exe path in my launch.json to the path of the 64-bit gdb debugger. This works correctly and I can run and debug with breakpoints as expected.
However, when running the 32-bit executable with the 64-bit debugger, I get no output to my console whatsoever, and the breakpoint is not hit.
What could be the problem?
Don't mix platforms. Debug the 32-bit executable with the 32-bit debugger.

mingw32-g++ compile to 16bit instead of 32 or 64

I'm compiling very simple code in windows7 64bit.
(in C:\MinGw\bin) "mingw32-g++.exe -c -Wall filepath\filename.cpp -o filepath\filename.exe"
When the .exe run, it give me 16-bit incompatibility error on the system.
Adding -m32 in the compiling arguments, the result are the same;
I'm using MinGwfrom www.mingw.com actually I don't want use IDE.
What could be the solution?
p.s. This happen since I've installed and try various IDE, it is possible that some of these have installed a different version of mingw, have changed some path or have changed the configuration somewhere. I tried code::blocks, codelite, microsoft visual studio express(didn't go right).
Thanks

cl.exe in cygwin shell

I have a host system and a virtual machine and i am trying to setup similar environment in both.
I installed cygwin and visual studio 10 also.
I faced issues in my build and I finally managed to find one difference between my host and vm.
in my host when in cygwin shell when i enter cl I get the following:
$ cl
Microsoft (R) C/C++ Optimizing Compiler Version 16.00.40219.01 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]
But in my vm I am getting no output.
$ cl
(VM is 32 bit and host is 64 bit)
Can someone tell me what setting I might have missed out on?
First thing you should do is to find out what cl is within the CygWin where it's not working. Execute the commands:
typeset -f cl
which cl
alias cl
and find out what it comes back with. If it's anything other than the MS compiler, that's your problem.
Beyond that, find out what the erroneous environment does when you try to run cl from a cmd window rather than CygWin bash.
Based on your comment:
On my VM, it is: $ which cl /cygdrive/c/Program Files/Microsoft Visual Studio 10.0/VC/bin/x86_amd64/cl
This is definitely wrong for a 32-bit VM. You are attempting to use the 64-bit AMD compiler on a system that doesn't support it.
You should change the path to use a 32-bit compiler. However, I'm not sure you have one since all of amd64, ia64, x86_amd64 and x86_ia64 seem to indicate 64-bit compilers.
The one directly under bin may be okay, you would have to test it to be certain (possibly with dumpbin which should be able to tell you the file format of the executable).

How can I use gcc to compile x86 assembly code on an x64 computer

For a school assignment I have to write x86 assembly code, except I can't use gcc to compile it since my computer is an x64 machine, and gcc is only excpecting x86 code. Is there a command that'll make gcc accept it x86 assembly code? Thanks
P.S. I know my code is valid since it compiles just fine on x86 machines.
Just pass the -m32 option to gcc.

Resources