Windows console 'cl' compiling : execute vcvars64.bat every time? - windows

I am trying to compile a C file in Windows console with 'cl'.
When I first tried this, It send a message like this :
fatal error C1083 : ... 'stdio.h' : No such file or Directory.
So I searched web and found some article execute vcvars64.bat and try again.
I followed that advise and it works nice.
But whenever I reopen terminal it prints same error message what I had in very first time.
Should I execute vcvars64.bat every time, whenever I try to compile in Windows console?
PS.
My command was
cl Helloworld.c -Fehello.dll -MD -LD

You can configure a shortcut to invoke cmd.exe with a list of startup commands. Create a shortcut to cmd.exe, then edit its "Shortcut->Target" in "Command Prompt Properties" to be cmd.exe /K C:\path\to\file.cmd. Within C:\path\to\file.cmd you can put the call to invoke vcvars and any other setup you want to do every time.
Then you can invoke the shortcut instead of cmd.exe whenever you need to do command-line VS stuff.

Related

execute some script after compile

i wanna to copy some file after lazarus compiled my project, like Build event in visual studio, I found the similar option in Lazarus:
but when I press ctrl+f9 to compie, will thrown error:
Executing command after missing executable ""
As I read the documentation, you are expected to provide an executable command. A .bat file is not executable which would explain why your command fails.
Prepend your command with cmd.exe /c to provide the executable which processes the .bat file.
cmd.exe /c "G:\Lazarus project\dll test\copy.bat"
change the command to cmd.exe /c "G:\Lazarus project\dll test\copy.bat" will works:

Configuring cl CMD compiling Windows

I have already read on MSDN.com that to enable command line compilation through the cl command you have to run the vcvarsall.bat file. I have run this file in CMD and compiled code using the cl command. The issue is that after I leave the CMD and reopen it, I no longer have the ability to use cl and have to rerun vcvarsall.bat every time I reopen CMD. Is there any way to avoid having to do this? Thanks.
Just create a shortcut on your desktop that calls
cmd /k "%VS140COMNTOOLS%\vsvars32.bat"
Adapt the environment variable and batch file name to fit your installed VS version number. In the example above, this will work with Visual Studio 2015.

How do you run programs in Windows terminal?

What is the windows equivalent to "./filename"
So for example I would usually compile by doing something like:
gcc -c homework1.c
gcc -o homework1 homework1.o
This would give me the executable names homework1
And for me to run the program, I would type: ( ./homework1 ) <-- ignore the parenthesis.
Usually I was write all my code in my schools Unix Shell thingy and I also compile it and run it there, but recently I think I took up all the disc space (because it says "disc quota exceeded").
Run cmd.exe
Go to where the program is example : cd C:\foder1\
Then type the program name with extension, for example : test1.exe or "test1.exe"
In windows (as in Linux) you can either run a program though a GUI interface or from a shell environment.
The GUI option is a program called Explorer, you navigate through the file system and double click executable files to run then. Executable typically have the extension '.exe' or '.bat', but there are others.
The shell environment in windows is called the 'command prompt', you can run it by going to the start menu and selecting 'run' or simply press the windows key and 'r' simultaneously. A box will popup, type 'cmd' (without the quotes) and hit enter - the command prompt should open. From there you can navigate the file system using commands like 'cd'. To run your executable type the name of the file (it should work with or without the '.exe').
A nice shortcut to open the command prompt already at a particular path, is to browse to the folder in Explorer, hold shift and then right-click the folder - the resulting context menu that pops up should have an option like 'open in command prompt'.

how to start executable from command line in windows

I have a program when I click it, it opens fine.But when I run it command prompt it gives an error that is related to a dll that my program uses.I do in cmd
"Path_to_program\program.exe"
And a note:my program is installed my D: drive
But it gives an error related to dll.the dll is in the same directory with program.I guess it is related to dll.is there an option to give the dll as dependency to my command?
You need to change to the same folder that the program is in so that your working directory matches.
Try
cd Path_to_program
program.exe

Running Bat file on Win 7 machine

I have an executeable (Command line which requires arguments/parameters) i need to run on a Win 7 machine. I can run the executeable if i right click and choose run as administrator. Of course, it returns an error code that the required command line parameters were not found. In addition, the executable will create an error log if it has a problem, errors out, throws an exception, etc. I then created a batch file and added MyProgram.exe param to it, and right clicked that and chose run as administrator. I get nothing.....no return code, no error log. I created a shortcut on the desktop to the batch file and changed its advanced properties to run as administrator and still nothing. Anyone have any ideas? I need to run this executable with params from a batch file on a Win 7 machine. Thanx
Edited:
I guess maybe it could be a problem with my Batch file, since i am a novice at those as well. I simply had one line:
MyProgram.exe MyImportFile.txt 1 1
Try creating a shortcut on Desktop to cmd.exe
There you have your commandline. Right click your new shortcut, run as administrator.
Then run your bat file or your exe directly with your parameters.

Resources