Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

visual studio compiler how to specify the include path to build cpp

I am using a batch file to try to build my cpp program using Visual Studio's cl.exe. This is what it contains:

"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cl.exe" /I "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\" "%1" /Fe "%1.exe"

I want to the compiler to include iostream from the include folder and build my .cpp (%1) as %1.exe.

Instead, I get:

Microsoft (R) C/C++ Optimizing Compiler Version 17.00.60610.1 for x86 Copyright (C) Microsoft Corporation. All rights reserved.

cl : Command line error D8003 : missing source filename

What am I doing wrong?

Win8.1 x64

like image 674
a1s2d3f4 Avatar asked Jul 14 '15 00:07

a1s2d3f4


People also ask

How do I add the include path in Visual Studio?

Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio. Select the Configuration Properties > C/C++ > General property page. Modify the Additional Include Directories property.

What is include path in CPP?

includePath An include path is a folder that contains header files (such as #include "myHeaderFile. h" ) that are included in a source file. Specify a list of paths for the IntelliSense engine to use while searching for included header files.

How do I change the compiler path in VS code?

In the Windows search bar, type 'settings' to open your Windows Settings. Search for Edit environment variables for your account. Choose the Path variable in your User variables and then select Edit. Select New and add the Mingw-w64 destination folder path to the system path.


2 Answers

Answer:

  • Get rid of the backslash at the end of the include path (...\...\include")

  • Do not surround %1 with quotes

  • no space between /Fe and ":

    "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cl.exe" /I "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include" %1 /Fe"%1.exe"

like image 111
a1s2d3f4 Avatar answered Oct 26 '22 23:10

a1s2d3f4


Do not run cl.exe from a standard command prompt. Use the "Developer Command Prompt" installed with VS 2015. This sets several environment variables for you, specific to your installation.

To read more: https://msdn.microsoft.com/en-us/library/f35ctcxw.aspx

like image 29
Robert Altena Avatar answered Oct 26 '22 23:10

Robert Altena