What does build with cl mean for a c++ program? - c++

the file comclient.cpp here
http://msdn.microsoft.com/en-us/library/aa645738(v=vs.71).aspx
says build with cl. what does that mean?
and also what type of project should I create n vc++? win32, console?

its the commandline compiler for visual studio for visualc++. Visual studio itself is just a mere IDE to help you code easier. Just like Devcpp has gcc and g++ as its compilers.

Related

Eclipse doesn't recognize printf with visual studio build tools 2022 headers

I'm trying to setup local Windows eclipse for remote Linux development. I have encountered problem with eclipse not recognizing simple 'printf()' statement from <stdio.h>. I didn't find any helpful resources ATM to solve this problem, so wondering if you could help me with this.
Header files used from: Visual Studio Build Tools 2022, specifically I'm including this folder for stdio.h file: 'C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041\ucrt'
GCC C++ Compiler as: "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\bin\clang.exe"
Eclipse IDE still highlights this as 'Function cannot be resolved':
I am not sure, but looks like 'printf' function is available at 'stdio.h':
Update:
Eclipse version used:
Using command line build is working as expected:
Program runs as expected:
So the questions are:
What needs to be done so eclipse would recognize 'printf'? e.g. Change MS Win Kits for another compiler header files? Or my eclipse configs are wrong?
If it is not possible for eclipse to recognize 'printf', is there an option to ignore all warnings on 'printf' (not highlight them)?
Let me know would you need anymore details from my side.
After some investigation I think 'clang' is not compatible with eclipse & it's way easier to install & use 'cygwin' for such purposes.
Some references:
https://www.eclipse.org/forums/index.php/t/1092409/
https://www.eclipse.org/forums/index.php/t/1102938/

about GCC compiler to compile code blocks and visual studio

I used GCC compiler to compile the code blocks editor files. I installed the visual studio editor for a purpose.
Do I need to install GCC compiler again for the visual studio code? Can I use the previous compiler for both code blocks and visual studio editor in same PC?
Yes, you can use the same compiler for two different IDEs.

Visual Studio Code and MSVC++2017 (tasks.json and c_cpp_properties.json)

I am relatively new to Visual Studio Code. I want to use VSC to create executables using C++ with the following compilers:
clang (on windows from cygwin)
gcc (on windows from cygwin)
msvc++2017 (native on windows, obviously)
As I was reading about VSC with C++ I thought that the gcc and clang (from cygwin) settings in tasks.json and c_cpp_properties.json would prove the most difficult. In fact, they were the easiest..once I got bash properly configured. Now I am struggling with getting the C++ compiler from Microsoft Visual Studio 2017 to work.
The only solution I have found uses a batch file that looks like this:
#echo off
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
set compilerflags=/Od /Zi /EHsc
set linkerflags=/OUT:hello.exe
cl.exe %compilerflags% helloworld.cpp /link %linkerflags%
but I'm thinking that this is not correct or perhaps not optimal. Why do I think this? Because if this were the case, why would the VSC developers provide an includePath entry in the example c_cpp_properties.json file that contains the actual include paths to my MSVC++2017 compiler? And then not rely on them...
So, I'm hoping that someone can show me example tasks.json and c_cpp_properties.json entries and the shell configuration to use with the Microsoft C++ compiler. Or better yet, if there are examples out there, please point me at them. I've looked high and low and can't find them...
Thanks in advance for your help.

I need to change compiler on VS

I have made a sudoku solver using SDL (for GUI) on VCpp 2010 IDE.
The program compiles without errors and runs fine. However, i cannot pass the compiled executable on to some people because they don't have msvc dll on their pc.
I thought i could use devc++ that compiles with GCC but this IDE is kinda buggy and just won't let me include some header files.I also have some problems setting up SDL expansions.
So, is there a way to change VisualStudio compiler to GCC?
I really need to stay with VS because it is easy to use and there is a lot of online support.
Short answer: no, you cannot change cl.exe (MS cc compiler) with gcc. Or mingw. (You can with a compatible compiler, like Intel C compiler)
Long answer: you don't need to to that. Use the static linked runtime library, and you don't have a dependency ms dlls anymore (see this answer: How do I make a fully statically linked .exe with Visual Studio Express 2005?)
Or redistribute the VC++ runtime with your app. It's free (http://www.microsoft.com/en-us/download/details.aspx?id=26999)
You don't need to change compiler - they need to download the Visual Studio 2010 redistributable:
http://www.microsoft.com/en-gb/download/details.aspx?id=5555
In short: no. You can't simply use the GCC compiler in Visual Studio.
The long version: you can use a Makefile project to run GCC, but then you lose some of the benefits of using Visual Studio.
I'm not sure when this became a feature in Visual Studio (probably wasn't one in 2013), but it is now possible to change the "Platform Toolset" - and thus the compiler - used by Visual Studio to other compilers like Clang/LLVM and GCC. I have been happily using Clang with VS2017 ever since the MSVC++ compiler bugged up with some 3rd party libraries.
Microsoft made a blog post on the installation instructions and how to switch.

How can I debug a MinGW EXE with the Microsoft Visual C++ debugger?

How can I debug a MinGW EXE with the Microsoft Visual C++ debugger?
You can attach the Visual C++ debugger to any process running on the system (from the Visual C++ menu). But for being able to step through your source code Visual C++ would have to load the symbol file (.pdb if I remember correctly) and I don't think GCC generates those files.
Exists many Visual studio extensions such us: WinGDB, VisualGDB you can find it on the web. It allows you to debug as regular Visual Studio project. These projects are not free but it has full functional 30 days trial. It has some restrictions but it's good enough.
The Problem:
GCC compiler (ie MinGW's gcc) generates debug info with "-g" flag. The debug info is embedded into the generated executable. Windows' compiler, on the other hand, uses a peculiar ".pdb" format to store the debug info. For example, Microsoft Visual Studio's debugger needs not only the executable (.exe), but also its debug info (.pdb) to be available.
The Solution:
There is a small program that can extract .pdb files from executables compiled with gcc.
It is called cv2pdb, available at https://github.com/rainers/cv2pdb.
Download cv2pdb https://github.com/rainers/cv2pdb
Put the cv2pdb.exe somewhere in your path, maybe a custom bin folder, so that it will be accessible through the command line.
Compile your file as usual using MinGW's gcc compiler, with the "-g" flag, so that the debug info is included.
Simply run cv2pdb.exe on your executable.
cv2pdb out.exe
This will generate a out.pdb file in the same directory.
(If you have Microsoft Visual Studio installed) Open the executable directly in Microsoft Visual Studio
devenv out.exe
Note: This command simply opens the executable in Microsoft Visual Studio, without creating a project for it. In effect, you can use whatever text editor + build system you want to build your executable, and then use Visual studio only as a standalone debugger.