Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting output path for cl.exe

Tags:

c++

c

visual-c++

I'm using command line param Fo, command line is like this:

file1.c  /ZI /nologo /W3 /WX- /Od /Oy- /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /analyze- /errorReport:queue /bigobj /FdDebug\vc100.pdb /FoDebug\ /FaDebug\

But some files still are produced outside of Debug folder (exe, ilk, pdb)
What I'm doing wrong?

like image 975
fithu Avatar asked May 01 '12 03:05

fithu


People also ask

Where is Cl exe stored?

cl.exe is usually located at %VCINSTALLDIR%\bin\ . VCINSTALLDIR environment variable is not set by default, but it is being set when you open Visual Studio's Native Tools Command Prompt.

How do I change the build directory output?

Right-click on the project node in Solution Explorer and select Properties. Expand the Build section, and select the Output subsection. Find the Base output path for C#, and type in the path to generate output to (absolute or relative to the root project directory), or choose Browse to browse to that folder instead.

What is file cl exe?

cl.exe is a tool that controls the Microsoft C++ (MSVC) C and C++ compilers and linker. cl.exe can be run only on operating systems that support Microsoft Visual Studio for Windows. Note. You can start this tool only from a Visual Studio developer command prompt.

What is CL CMD?

Function and Use. The CL command is used to terminate a user session. It is recommended that all user programs issue a CL command when database processing is complete.


2 Answers

Those are files produced by the linker. You'll need to run it separately or use the /link compiler option so you can control its output. Use the /OUT option to set the .exe and .ilk locations, the /PDB option to set the .pdb location.

like image 60
Hans Passant Avatar answered Sep 23 '22 12:09

Hans Passant


Because (like DCoder said) cl.exe passes any command line options after /link to the linker, you can do it in one line:

cl.exe <all your cl arguments here> /link user32.lib <and other lib here> /libpath:"C:\Program Files\Microsoft SDKs\windows\v7.0A\Lib\" /out:files\newfilename.exe

You can change files\newfilename.exe to be whatever you want. If you run from a batch file, you can do something like files\%1.exe and etc...

like image 31
oak Avatar answered Sep 21 '22 12:09

oak