I have been following tutorials which have me download and unzip projects which contain .sln files for me to open. Following them this way is pretty easy. However, I want to be able to download a single .cpp file and run it without creating a project. I just want to get straight to into it. In Code::Blocks, setting this up is easy to figure out. For some reason, I can figure it out in Visual Studio.
I want to be able to download a single .cpp file and run it without creating a project.
You cannot. Visual Studio does not support this. A project is always required, even if it only contains a single source code (.cpp) file.
You can, however, run a single .cpp source file through Microsoft's C++ compiler on the command line (cl.exe), and then execute it. But this doesn't involve anything about the Visual Studio IDE.
if you have the source code, you could make a .cpp file by right-clicking and adding one and then ctrl+s then f5 and it might run... Idk.
Related
file browser
Installation details
Main problem:
I have created a new, empty project and I want to populate it with
pre-existing .cpp files and a header file, but the file browser does
not allow the .cpp or .h extensions to show.
Possible cause 1:
I think it might be the installation details
Possible cause 2:
I have some legacy files from visual studio code
Context:
I migrated from using VS code to VS because code somehow wasn't able
to compile the 2 .cpp and 1 .h files my teacher gave me. I got tired
with messing about JSON files and compilers and such and threw in the
towel when my professor recommended the school's preferred IDE.
In Solution Explorer, right-click on your project and select Add → Existing Item... (You have probably clicked on the solution itself rather than on the project.)
As it's described in the title, I would like to make Visual Studio detect a .cpp file which is in a subfolder. (It's a C++ project.)
My program automatically creates new .cpp files and .h files, but when it creates a new .cpp, it doesn't detect the .cpp file in the subfolder of the project. Even if I restart the project/program.
What could I do to make it automatic?
Does an instruction exist to tell Visual Studio/or the program to compile this .cpp file ?
Does every .cpp file have to be in the same folder? I could do it that way, but it would be more organized if the different files are in different folders.
So I didn't find any solutions, but I've ask severals persons, and they told me that I might have to change by hand some files automactly created by Visual studio to tell them to include a specific .cpp file. But to identify which file I've to change and if I can open them as a txt file ect.. It was too much work, then I've decided to change my project.
Thanks for your help ! And I hope this will give you a little taste of what you have to do if you have the same problem
This may have a very simple solution, but being new to Visual Studio and C++ programming, I'm having a hard time with this.
I downloaded an SDK written in C++ which contains an executable file and also the source and header files. The executable file accepts some command line arguments. So far I've been running the executable file from the windows command prompt (like C:\path\filename.exe -argument), but now I want to be able to enter these command line arguments and then place breakpoints in the source code for debugging the source code.
I don't know how I can open the source files in Visual Studio and debug it. If I just open the source file with the main function, the debug button says 'Attach' on it instead of debug.
I see another similar question here, but that question is for a project developed using Visual Studio whereas the source code I have does not have any Visual Studio project/solution files. The only files I have are the executable, the source and header files (.cpp, .h, .hpp), and CMakeLists.txt files.
You can "open" the exe as a project (you can achieve the same if you drag and drop the exe into VS icon). Then you can add command line parameters at Project Properties. You will need to have debug symbol information (usually a .pdb file), if you want source code level debugging (values of variables, etc.). If you don't have that, you can only debug at the disassembly level.
You may want to create a proper project for the source files - it is an easy task, if the project is simple - so you can rebuild the exe.
I'm using Qt4.8 with Visual Studio 2012 with Qt VS add-in 1.1.8. And I have a problem with moc_ files generation. If I add new class (with .h and .cpp files) to my project, where Q_OBJECT is supplied, then moc_ file is not being generated correctly and I get linking errors.
In .h file's custom build tool's command line, moc.exe's commands should be filled automatically. It seems everything is OK in Production configuration, but in Debug and Release configurations custom build tools command lines are empty and every time I have to write them, build and add moc_ file to my project manually, which is quite inconvenient.
So what can be problem for automatic generation? Which solution can be?
Thank you in advance!
When I open a .cpp file separate of any project in MSVC, the debugging tools are greyed out and intellisense doesn't seem to be parsing the text. Is there a way to make it so when I open an individual .cpp file, I can compile it straight away without having to copy paste the code into a new project?
the debugging tools are greyed out and intellisense doesn't seem to be parsing the text. Is there a way to make it so when I open an individual .cpp file
You can't debug it, because there is no program. One file does not make a program. Project "makes" a program.
Is there a way to make it so when I open an individual .cpp file, I can compile it straight away without having to copy paste the code into a new project?
This won't work, because to compile even one file you might need specific compiler settings (include directories), which are specified within project.
However, you can use "Visual Studio command prompt", locate your file and run cl filename.cpp (filename.cpp is your file) command which will attempt to compile/link single file without specifying extra settings. You won't get assistance from ide in this case, but you might be able to compile it (assuming the file contains trivial program that doesn't need extra settings) and read any errors you get from command prompt.
No, there isn't. The minimum unit Visual Studio can build is a project.