Why can Visual Studio 2017 Developer Command Promt only open "stdio.h" in Administrator mode? - c

I am trying to do simulation using Delmia. This requires a functioning C compiler. When i test my C compiler in Delmia, which tries to compile a very simple source file that includes stdio.h, I get the error "Cannot open include file: 'stdio.h': No such file or directory":
Compiling and linking the model (Visual C++).
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.6.2
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x86'
Guessed compiler version: 1913
"Testing 32-bit compilation"
dsmodel.c
dsmodel.c(1): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory
Error generating Dymosim.
It seems to be entirely the same issue as:
Visual Studio 2017 for Dymola cannot open stdio.h
His solution is not descriptive enough for me to solve my issue, as his "IT dept" apparently solved it for him, but he mentions allowing access to regedit which I do not understand the reason for in this context.
I have tried to recreate the error that Delmia generates by compiling dsmodel.c with VS2017 Developer Command Promt. If I run the command prompt in Administrator it compiles fine, if I do not, I get the samme error as Delmia outputs. Why is this?
If I find a solution such that I can compile it with command prompt without being in Administrator mode, then should Delmia not also be able to? How can i achieve this?
Some additional information: I have installed Visual Studio not on my main drive, and the Windows SDK is in program files on my main drive. Does this have any relevance?
Edit: For anyone else with this issue in Delmia, I would suggest simply installing another compatible compiler as a work-around. I installed MinGW which works well, even though this additional compiler takes up 500 MB. Remember that it has to be 64-bit. I used the "MingW-W64-builds" from http://mingw-w64.org/doku.php/download

Related

How to use VC++ compiler in command line(Windows)?

I tried to use VC++ commandline, instead of MinGW compiler for windows system programming. I wrote a simple hello world program and tried to compile it, then i got this error message.
test2.c(1): fatal error C1083:'stdio.h': No such file or directory
I also added "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\Hostx86\x86" directory (where c1.dll lives) to the System Envionment Variable(PATH).
How can I fix this issue? Other tutorials don't give much information about VC++. (A lot of MinGW compiler tutorial out there btw)
You should use visual studio command line if you want to compile or run program with the help of vc++ compiler.
Else all information related to setting environment variables ETC. resides in this MSDN document.

Compiling C code in cmd prompt

I use sublime text as my text editor and the cmd prompt to compile and run the code. The cmd prompt out of no where will no longer update the exe with the new code added to the program. Has anyone had this problem? It was working the other night and I have not changed any settings on the computer that would make this not work. Also the program has no errors
If you have installed Visual Studio 2015 (or other edition) on Windows 10 and create source code file with .c extension, you can use cl.exe.
It is better to use Visual C++ developer command prompt (can be started from Start button).
C:\Program Files (x86)\Microsoft Visual Studio 14.0>cl prog.c
Visual C++ developer command prompt provides environment settings like Path.
If you just run cl.exe without parameters you should see something like
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23918 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
This way is not for Mingw. But, perhaps, compiler is not limiting... so Visual Studio can work at the same PC. Just as an option

Setting up GNSDK development environment - nmake doesn't work

I'm following GNSDK: The Barebones C Intro and have a problem while setting up the development environment.
The instructions say:
The first thing you need to do is set up your development environment. I coded and ran this application on Windows System 7. The SDK comes with a number of C samples. Each sample has its own folder. For this application, I cloned one of the folders and named it "/Samples/gnsdk_barebones". I used the "makefile" in the cloned directory and the Visual Studio 2008 C/C++ compiler to run the makefile from the command line (Visual Studio 2008 > Tools > Visual Studio 2008 Command Prompt). It's important that you create your folder under /Samples as the makefile uses relative path names to do its build.
I'm running MSVS 2015 on MS-Windows10 laptop.
I opened the 'Developer Command Prompt for VS2015' and type the following command
C:\Users\Dell\Documents\Play\GNSDK\samples\gnsdk_barebones>nmake -f makefile
Microsoft (R) Program Maintenance Utility Version 14.00.23918.0
Copyright (C) Microsoft Corporation. All rights reserved.
makefile(8) : fatal error U1000: syntax error : ')' missing in macro invocation
Stop.
The gnsdk_barebones folder contains two files that were downloaded as part of the SDK.
main.c
makefile
I couldn't find any record makefile(8) error type and would appreciate your advice.
Please let me know if further info is required.
Thanks a lot for your help!
In the light of your comments, the explanation of your problem is that your makefile is
a makefile for GNU make - which is the make-
tool almost always used - and you are trying to run it with Microsoft's
make-tool, nmake, which is almost forgotten and cannot parse a GNU makefile.
You can get GNU make for Windows
as a standalone package, or install it as part of a complete GNU GCC toolchain
for Windows such as TDM GCC.
Your comments pose additional questions. It's one question at a time on
Stackoverflow :) See How to ask.

ifort: error #10037: could not find 'link'

I downloaded and installed evaluation software of:
Intel Parallel Studio XE Professional Edition for Fortran Windows. My system is a 64 bit, Windows 7 OS. During its installation I was asked to download and install also: Microsoft Visual C++ 2013 Redistributable(x64)- 12.0.21005 .
I am trying to compile my source files using the command line.
In order for the command ifort to be recognized, I added the directory:
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.0.110\windows\bin\intel64
to the PATH environment variable . (This folder contains the file ifort.exe).
However, when I try to compile a simple 'Hello World' program by the command:
ifort hello.for
I get the error:
ifort: error #10037: could not find 'link'
The file 'hello.obj' , however, was created.
The steps I tried in order to fix this error (but that made no difference):
1) I tried to add to the PATH environment variable the directory:
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.0.110\windows\bin\intel64_gfx
This folder contains the file: gfx_linker.exe, which I thought is the needed linker.
2) I tried to change the configuration of Visual Studio to add 64-bit support, according to the 4 steps Steve Lionel (Intel) sugested in (https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/300121), but the window that appeared (after pressing the change option in the 'Uninstall or change a program utility' of the control panel) showed no 'x64 compiler&tools' checkbox option, only a repair button option, which made no difference.
3) I tried to update the ifort installation, as Tim Prince suggested in (https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/280266). I tried to do it through the 'Uninstall or change a program utility' in the control panel. But selecting the 'Repair' option in the window that appeared blocked the completion of the process by stating that 'repair cannot be done because no available sources were found', and selecting the 'Modify' option, blocked me in the step of 'selecting components to modify' (nothing I chose enabled the 'next' button).
4) Before calling ifort I tried to execute the cammand:
"C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.0.110\windows\bincompilervars.bat" intel64 vs2013
as Steve Lionel (Intel) suggested in the previous link, but got the error:
ERROR: Visual Studio 2013 is not found in the system.
Right now I'm out of options, and beg for help to show me how to fix this error of ifort not being able to find the 'link'.
You can simply compile your Fortran files from command line using ifort, to do that:
Start menu > programs > Intel parallel studio XE 2O16 > Intel 64 visual studio mode or search for Intel 64 in the start menu
open Intel 64 visual studio mode . Now you can start to use ifort and it will work fine.
If you want to know how to invoke it (the parameters used) then right click over Intel 64 visual mode, from the menu choose open file location.
I uploaded these screenshots, just take a look:
From the second screenshot notice the parameters passed to the batch file.
Note: according to Intel documentation the second argument (vs2013) is optional.
My friend got the same problem. Here was what I advise him to do and it worked. The reason why this happened is that you missed link.exe located in C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\ and other related folders too. So, you can use a small software called everything to search your computer to find out whether the link.exe is missing in your Microsoft Visual Studio folder. If it is the case, you can copy these files from someone else or just reinstall your visual studio and make sure everything is right in place.
I had the same issue.
First of all add "C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.0.110\windows\bin" to path.
Now, from windows command line run: compilervars.bat intel64
It sets up the environment on the windows command line.
now you can access the "ifort" commands without getting the linking errors.
I'm going to start by pointing out the required steps needed for code to metamorphose into executables: [SO]: LNK2005 Error in CLR Windows Form (#CristiFati's answer). That's for C, for Fortran it's the same thing, except:
Step #1. does not exist (at least, I don't think so)
Step #2. will be performed (obviously) by the Fortran compiler
Ran into the same issue when working on [SO]: What is numpy.ctypeslib.as_ctypes exacty doing (#CristiFati's answer). Environment:
Intel's oneAPI HPC Toolkit (also Base - which is a direct dependency) for ifort.exe
Microsoft's Visual Studio (I have many versions installed, chosen v2019 as it was the newest at the time) for link.exe
As seen (one has to look in both Output snippets) I built it manually in 2 steps.
But ifort.exe can automatically invoke link.exe, if the latter's dir is in the PATH variable. For more details on invoking VStudio commands, check [MS.Learn]: Building on the Command Line.

Can ARM desktop programs be built using visual studio 2012?

I was working with visual studio 2012 beta and my desktop (win32) program compiled fine in ARM architecture.
After upgrading to visual studio 2012 RC, the compiler would not work and spews out the following error:
"Compiling Desktop applications for the ARM platform is not supported"
I found a forum post on this
http://connect.microsoft.com/VisualStudio/feedback/details/745580/arm-configuration-doesnt-work
Is it correct that Microsoft is really cutting off win32 development on ARM?
And that compiling in VS2012 beta was just a fluke?
You can edit the file:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\ARM\Microsoft.Cpp.ARM.Common.props
In the <PropertyGroup> section add the line:
<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
before </PropertyGroup>
And that's all, you can build ARM desktop apps with VS2012.
I was able to get around that error and compile a little "hello world" cpp file for ARM by adding the "/D _ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE" command-line argument to the ARM version of cl at C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_arm. I found that #define from sn0w's answer on this question in the crtdefs.h file, without having to modify that file. Now, I can't guarantee that anything more complex will actually work, or that Microsoft hasn't instituted some sort of whitelisting or digital signature verification for Windows RT desktop apps, so even though it may compile, it may not be allowed to run when Windows RT is finally available.
Note that before you can run the ARM version of cl.exe from the command line, you must set the environment variables using this batch file: "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_arm\vcvarsx86_arm.bat"
Even if you compile the app, you won't be able to run it on Windows 8 RT as unsigned apps will not start.
I just tested this, and unfortunately it is the case.
You receive the following message:
Windows cannot verify the digital signature of this file
I imagine there is probably a work around for this, but it will never be officially supported.
yes of course. i practised with VS2012 RC.
now i'll explain how to avoid "Compiling Desktop applications for the ARM platform is not supported" and build win32 application.
1st way: fix build tools - the goal is to patch (or try to substitute it with beta's one) MSBuild's lib: Microsoft.Build.CPPTasks.Common.v110.dll
2nd way: run the "VS2012 ARM Cross Tools Command Prompt" from Visual Studio Tools start menu, then execute cl [cl params] myfile1.cpp myfile2.cpp myres.res ... /link [linkparams]
for both this cases you also need to commentout an #error directive in crtdefs.h on line 332. (Microsoft Visual Studio 11.0\VC\include)

Resources