Visual Studio can't debug, can only attach [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I cannot press F5 to debug my program, because there is only an Attach... button instead of a Debug button.
I am using a .c source file, and I was able to debug my sources until I changed a .cpp to a .c and now every source file I open, it says "Attach...". What do I do?

Try menu Tools → Customize → Commands → Add command...[button] → Debug (under Categories). Find and add the button you would like to.
Also try setting your project to startup one - in Solution Explorer - right click on the project and choose the Set as Startup project option.

Related

How to use Resources in c++? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 months ago.
Improve this question
I want to put an exe file in my C++ program, but I don't understand how to do it.
I am using Visual Studio 2019. I know that it can be done through project resources, but I don't know how to work with it.
Create an .rc file to refer to the desired embedded .exe as an RCDATA resource, eg:
MYEXE RCDATA "path\to\file.exe"
Add the .rc file to your project.
The referred .exe file will then be compiled into your final executable.
You can then access the MYEXE resource at runtime using the Win32 FindResource()/LoadResource()/LockResource() functions, or higher-level framework equivalent.

How to include audio and picture into .exe ( Visual Studio ) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Does anyone know how can I include a picture and a .wav file into my .exe file? ( C++ )
If i run the build PlaySound(TEXT("Audio.wav"), NULL, SND_FILENAME | SND_ASYNC); it will work well, but if a another person opens the .exe where the .wav file is not in the same direction the sound won`t play, how can i include the audio into the .exe?
Firstly, I suggest you could try to add the files to your project as resources, then you could try to use PlaySound function to use them.
I suggest you could refer to the thread:PlaySound works in Visual Studio but not in standalone exe

How to compile code from other compilers in VS 2017 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have downloaded a source code and can't get my head around to how can I compile it/open it in VS 2017. It should have been straight forward but nothing worked until you create a new project. If I just open a C file in VS, it just show me the file and there's no way to run it. Imagine I wrote a simple Hello World in C and I have its C file. How could I open and run it in VS? The only way I found was to create a new project and copy/paste the code from my C file into the newly generated file by VS. This gets extremely inefficient with large projects having multiple C/h files :/
Yes, you should Create a New project -> Visual C++ -> Empty Project. After that, you will see in the solution explorer (Resource files, Header files, and Source files) folders. Right click on Header files and Then Add -> Add existing items, Then you can select multiple header files. Follow for source files same as header files that you Added

Trouble with Visual Studio [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Ok, so I create a project.
Now I create two c++ classes in that project A and B.
A has some compilation errors. B is just fine and compiles fine.
Now, when I run B, it wouldn't run because A still has compilation errors.
So, I don't like to create a whole new project just because I want to create a new c++ file (scratch to experiment on) and toggle between the two projects.
Is there any way I can just have two c++ files existing independently in a single project?
In the current scenario, how do i build/compile and run only one of the c++ file (A or B) without the other one getting compiled and run as well.
This is why I never made the transition from sublime to VS.
First Question: In Visual Studio, in your Solution Explorer, right click under your project and select "Add>New Item" and then select your code file format in the Window that pops up(C++ in your case). Enter a name for the file and then click the "Add" button.
Second Question: In the solution explorer window, right click the file that you do not wish to be included in the project and select "Exclude from Project". That file will not be compiled, but will still be visible in Visual Studio. When you want to include the file, same procedure: Right click the file, select "Include in project".

How do I get project root directory? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
For example, if my project directory is /media/code/clojure/my-project/ and I have a file /media/code/clojure/my-project/src/foo.clj, how can I get "/media/code/clojure/my-project/" from foo.clj?
This is unfortunately not possible because the idea of a "project root" is not well defined in the Java package model. There is a the idea of "the root of the source for this project" though once/if it's compiled into a jar file this concept no longer applies, the jar file could be loaded form anywhere on the system and that location will almost always (in the case of distributed software) be a system package installation directory. This would be an inappropriate place to download files to.