Invoke cl (Visual Studio 2013) cross-compiler from CMD on 64bit Windows - c

I have downloaded the LiE software
http://wwwmathlabo.univ-poitiers.fr/~maavl/LiE/
Unfortunately, I work on Windows 7 (64 bit) but the code seems to only target 32-bit Linux platforms (i.e. there is only a Makefile that uses the GNU make + gcc).
My idea is to install the GNU make (and some other required tools) for Windows from GnuWin32 and adapt the provided Makefile to the Windows-environment by replacing gcc calls by calls to the VC++ 32-bit cross-compiler. However, when I try to invoke the cross-compiler from the command prompt, I get the error "The dll mspdb120.dll is missing". The question is: How do I invoke the cross-compiler from the command-prompt/GNU make for Windows without copying dlls around? Btw invoking the native 64 bit compiler goes off without a hitch by just calling the cl.exe by its fully specified name!
Thanks a lot!
P.S. I'm using MS Visual Studio Express 2013 and the native-compiler is stored here:
C:\Software\Development\Microsoft Visual Studio 2013\VC\bin\
The cross-compiler is, as expected, stored one level deeper:
C:\Software\Development\Microsoft Visual Studio 2013\VC\bin\x86_amd64
P.P.S.: I have tried to create a MS Visual Studio solution but the Makefile compiles three exe-files, the bison-parser is called externally + multiple source files are merged into a single object file -- the requirements that are extremely hard to implement using the VS-functionality -- so I have abandoned this futile endeavour.

From the Windows command prompt, run the command C:\Software\Development\Microsoft Visual Studio 2013\VC\bin\x86_amd64\vcvarsx86_amd64.bat. That will set up the PATH and other environment variables that need to be set to use the Microsoft compiler normally. You'll need to rerun this command every time you open the Windows command prompt.
You can also use a shortcut included with your Visual Studio 2013 installation that will run this script automatically while opening a command prompt. It's located in the Start menu under Visual Studio 2013 -> Visual Studio Tools -> VS2013 x64 Cross Tools Command Prompt. You can also find it at at C:\Software\Development\Microsoft Visual Studio 2013\Common7\Tools\Shortcuts\VS2013 x64 Cross Tools Command Prompt.lnk.

Related

Programming in C in Visual Studio Community 2017 on Mac

I am taking C course and was required to work on VS community 2017. I've been trying to install it on my mac, and the process seem to go ok but I can't find an option to write in C, or to open a project with "Visual C".
It appears that Visual Studio for Mac does not support C or C++. Your options seem to be either Visual Studio Code or running Windows in a virtual machine on your Mac. You can check this post for details: https://social.msdn.microsoft.com/Forums/en-US/ef99e9f5-2a48-423b-b6c0-fa5617d7c63d/how-do-i-get-c-to-work-on-visual-studio-for-mac?forum=visualstudiogeneral

How to program kernel drivers for windows without visual studio?

Everytime I see a driver tutorial I see they use visual studio, I was just wondering if it is absolutely required to install it in order to develop windows drivers?
Say for example I would like to compile the following driver: (source)
NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
DbgPrint("Hello World\n");
return STATUS_SUCCESS;
}
How would I be able to compile/link it without visual studio? I have searched all over the place.
The linked tutorials are based on older WDK builds. You can get the old WDK and follow the tutorial, but I don't really recommend it.
Recently, the common way to develop Windows drivers is to use Visual Studio, but there is also a similar approach to the tutorial, which is developed from the command line environment.
https://learn.microsoft.com/en-us/windows-hardware/drivers/develop/using-the-enterprise-wdk
Of course, you don't have to install Visual Studio as using EWDK.
If you would like to use a different IDE then you must use the Enterprise Windows Driver Kit (EWDK) https://learn.microsoft.com/en-us/windows-hardware/drivers/develop/using-the-enterprise-wdk
After downloading and unzipping the archive you will need to launch LaunchBuildEnv.cmd and then run MsBuild.
Example:
Msbuild my_driver_project.vcxproj /p:configuration=debug /p:platform=x64
This assumes that you will write your own vcxproj file. Details about the file format here: https://learn.microsoft.com/en-us/cpp/build/reference/vcxproj-file-structure?view=vs-2019 and you could look at some driver samples from Microsoft here: https://github.com/microsoft/Windows-driver-samples
If you are just starting out with Windows Drivers I would say that using Visual Studio and WDK is a good idea because you can concentrate more on core Driver Development concepts and after you have something working you can write your own vcxproj file and use the eWDK. Having some examples of vcxproj files is useful.
If you do go down the Visual Studio route you can use Visual Studio Community edition which is free for non-commercial use.
It is important to install Visual Studio prior to WDK because the WDK is essentially a plugin to Visual Studio.
Additional instructions and download links for Visual Studio and WDK https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk

How to target multiple versions of Windows

I am using visual studio 2017 and Windows 7 (sp1). I compiled a c program on my computer. But, On my friend's computer, it's not running. I don't want to share my source code. My friend uses windows 10. How can I compile my program to run on both computers.
Thank you!
To make a compiled deliverable that works on other machines in Visual Studio, what you need to do is:
Compile in Release mode (it is Debug by default)
Ship the appropriate Visual C++ Redistributable package with your executable
Ensure that the target architecture (x86, x64, ARM, or Itanium) is appropriate for your particular deliverable
Creating a setup wizard makes a lot of this easier.
Also note that Windows SmartScreen will by default not allow computers to run foreign, un-digitally signed programs acquired from the Internet.

Running a C program written in Visual Studio 2013 on other pc

Every time I write a C program using Visual Studio 2013 the .exe file only runs on my PC. When I copy that .exe file to other PC it doesn't run. But if I use Code Blocks IDE instead the .exe file runs in all PCs. Why? and how can I make a 'C program' written in 'Visual Studio 2013' run on every PC?
It's because of the 2013 runtime libraries1, you need to download the redistributable and install it into the target computer.
You can download it from here.
1The file is called msvcr120.dll if you compiled with the VS 2013 ("v120") platform toolset, and otherwise follows the pattern msvcrNNN.dll.
In your project settings, change the Runtime Library support to Multi-threaded (/MT) instead of the default, which is Multi-threaded DLL (/MD). This will cause your .exe to be statically linked, and it won't need to look for the runtime libraries on the target machine. (I think it's under C/C++ Code generation, but I don't have visual studio 2013 installed at that moment to verify that).
The resulting .exe will be bigger (because it has to link in all the parts of the runtime that you use), but it simplifies deployment on other machines - no need to install the redist package.

Can I execute vs2012 compiled binaries on win2k3?

I am compiling C projects with vs2012 ultimate on win2k8r2 machine.
But I want to execute same binaries on win2k3 server.
can I do it with modified setting in vs2012?
As far as i know, if you want to make native app built by vs2012 work on Windows xp and Windows Server 2003, you must have vs2010 installed.
There're some configurations to make vs2012 use vs2010's compiler to build apps.
When you compile your binary, linker will link you executable with runtime library. This runtime library can be different on win2k3 server and win2k8.
But, just try :-)
Also, you can set the compiler to use static linking in the project settings (Project -> Properties -> Config Properties -> C/C++ -> Code Generation -> Change "Runtime Library" to /MT or /MTd instead of the default /MD or /MDd)
As released at RTM, native applications built with Visual C++ 2012 would not run on Windows XP or Windows Server 2003 - they would only run on Vista or later.
However, Microsoft will release an update that supports Windows XP and Windows Server 2003 as targets (they will still be not supported as the development platform):
Targeting Windows XP with C++ in Visual Studio 2012

Resources