VS2017 Build all solutions when pressing F5 buy only execute one - visual-studio-2017

I'm currently working on a project that has a DLL and a .exe that loads it. Whenever I press F5, it compiles the .exe project(which is set as default) but it does not compile the DLL one(which is the one with the most changes to).
I've tried the "Multiple Startup Projects" feature in the solution's properties, does force the DLL project to compile, but it always pops a message box saying it can't launch a DLL file.
Is there anyway I can tell Visual Studio to build the .exe and the .DLL whenever I press F5(or click the button) but only start the .exe one?

VS should build any projects that it recognizes as out of date. If the DLL project is not referenced by the EXE project, then you can add an explicit build dependency by right-clicking on the solution and picking Project Dependencies from the context menu. This lets you specify build dependencies before a given project build (in addition to relationships implied though project references).

Related

How do I create an executable in Visual Studio 2013 w/ C++?

I can't find the exe file for my Hello World program that succeeded to work, and the program did not open as soon as it said it worked. I tried going to my documents and checking my project's folder. It was completely empty. Thanks for any and all help.
All executable files from Visual Studio should be located in the debug folder of your project, e.g:
Visual Studio Directory: c:\users\me\documents\visual studio
Then the project which was called 'hello world' would be in the directory:
c:\users\me\documents\visual studio\hello world
And your exe would be located in:
c:\users\me\documents\visual studio\hello world\Debug\hello world.exe
Note the exe being named the same as the project.
Otherwise, you could publish it to a specified folder of your choice which comes with an installation, which would be good if you wanted to distribute it quickly
EDIT:
Everytime you build your project in VS, the exe is updated with the new one according to the code (as long as it builds without errors). When you publish it, you can choose the location, aswell as other factors, and the setup exe will be in that location, aswell as some manifest files and other files about the project.
Click BUILD > Configuration Manager...
Under Project contexts > Configuration, select "Release"
BUILD > Build Solution or Rebuild Solution
Just click on "Build" on the top menu and then click on "Publish ".... Then a pop up will open and there u can define the folder which u want to save the .exe file and by clicking "Next" will allow u to set up the advanced settings...
DONE!
Do ctrl+F5 to compile and run your project without debugging. Look at the output pane (defaults to "Show output from Build"). If it compiled successfully, the path to the .exe file should be there after {projectname}.vcxproj ->

Can't debug c++ project because unable to static library start program *.lib

I'm using a library (Astro.lib) which i've built without problems (i guess this is a release build).
I've also built a project which references the library (it runs as a release exe fine) but i can't debug the project because i get the message 'unable to start program 'Astro.lib'.
If i try to debug the lib then i get the same error, so I guess its something to do with not building for debug my lib but not sure how to modify.
I've tried changing the properties pages using MSDN info but not sure i'm addressing the correct problem. What changes should i make to the properties pages of the library of linking project?
Thanks in advance
I've also built a project which references the library
That's the project you want to debug. You probably just have the wrong project selected as the startup project of your solution. It is marked in bold type in the Solution Explorer window.
Right-click the project that uses the library and select "Set as StartUp Project"
your debug settings are wrong - you're trying to debug the lib, not the exe.
Chances are you've set the library project as the one that is started by the debugger (eg the "startup project" that shows in bold in Visual studio). Change your solution explorer so the main executable project is bold and try again, or right click on it and selecty the appropriate "run in the debugger" option.
Another solution is:
Make sure you have the Solution Explorer view (VIEW->SOLUTION EXPLORER).
Then, right click on SOLUTION at the top, and click EXPLORER.
Under COMMON PROPERTIES->STARTUP PROJECT -> SINGLE STARTUP PROJECT, choose the project that you want VS to execute. Note that this project has the property CONFIGURATION TYPE set as APPLICATION(.EXE). This can b found under the project's properties->CONFIGURATION PROPERTIES->GENERAL.
Hope that helps.

How to include required dll to a mvc c++ build

I have a project that relies on some other projects on my solution. For example assume that my main project is m and it produce m.exe
This project depends on some other projects say a.dll, b.dll,c.dll.
My problem is:
when I build m.exe, a.dll,b.dll and c.dll are created and the output is placed in some directory on my pc, but these dlls are not copied to output directory of m.exe and hence when I want to debug m.exe, they are not found.
If I copied them to output directory (debug directory) the application runs, but I am not able to debug into a.dll,b.dll and c.dll.
How can setup my MSVC so I can compile and debug into these dlls?
I am using Visual studio 2012.
In your project settings (Configuration Settings -> General) for each project, you can set the output directory. Change it for every configuration/platform of every project to e.g. $(SolutionDir)$(Platform)\$(Configuration)\ (or anything else that resolves to the same location for each project).
The alternatives are to either add a post-build step to copy files around via command, or to change your DLL resolution mechanism and use delay loading code that resolves referenced DLLs "manually".

Can't get DLL to work on Visual Studio

I've been following the tutorial from msdn and it just doesn't work.
First problem I have is that sometimes the .dll and .lib aren't built. Instead I only get .objs. Whenever I build the .dll project, it gives me a popup asking to "please specify the name of the executable file to be used for the debug session". I was told to change my startup project to one with a main function, but then the .dll doesn't get built. This happens both using the default VS configuration and simply adding some lines or following the step-by-step guide at msdn.
When the .dll and .obj are built - God knows how - I can't get them to be recognized. I've tried putting them and the .h in the project folder, but then I get an error about the .dll function being undefined. Following the msdn link, at one point it says:
To use the math routines that were created in the dynamic link library,
you must reference the library. To do
this, select References… from the
Project menu. On the Property Pages
dialog box, expand the Common
Properties node, select References,
and then select the Add New Reference…
button. For more information about the
References… dialog box, see Framework
and References, Common Properties,
Property Pages Dialog
Box.
The Add Reference dialog box is displayed. This dialog lists all the
libraries that you can reference. The
Project tab lists all the projects in
the current solution and any libraries
they contain. On the Projects tab,
select MathFuncsDll.
If I go Project > Test Properties > Common Properties I can only find the subitem "Framework and References". There is no "References..." There is an "Add new Reference..." button, but that doesn't let me add anything. The other button, "Add Path..." doesn't make any difference even when I set it with the directory with the files. The following steps don't work either.
I've also tried to add the name of the file at the Linker, but then it says it couldn't find the .obj file.
I have no idea where to go from here. I been stuck on this for hours and nowhere has a solution for this.
Is there a step-by-step guide anywhere that actually works for VS2008?
firstly your description is mixing managed (.net) things with normal c++ stuff. I assume you are doing normal c++ stuff.
DO you own (I mean have the source; are the author) both the DLL and the calling program? If so you should have 2 VS projects one for the DLL and one for the program. You should set the program as the startup project. This will make the debugger behave correctly
IN order to get the build right you need to make the c++ program depend on the dll project. There is a Project | Project dependies dialog that will do this for you, set the program project to depend on the dll project
If you only own the DLL then you need to go to the project properties | debug and tell it what binary to run to call your DLL.
If this is managed c++ then its a whole different storty
Try to specify Project Dependencies between your DLL project and project of application that uses the DLL.
The References settings are dedicated to .NET projects.

VC++ project never up-to-date

I'm using Visual Studio 2008.
I have a solution with two projects. One builds a DLL, which is my "production code". The other builds a console app exe, which is my unit test suite.
For my unit test project, I have listed as linker inputs the names of the source modules from the DLL. I.e., I have a DLLMain.cpp in the DLL project, and a linker input "DLLMain" in the exe project. This allows the exe to link with the obj files produced by the DLL project, preventing recompilation of those modules just for the unit tests. (Saves a lot of build time.)
THE PROBLEM IS that because the exe is produced later than the obj's, and by a different project, its timestamp is always newer than the obj's. So when you try to run or debug, it ALWAYS says the exe project is out of date and needs to be rebuilt.
Is there some way I can configure the exe project to ignore the timestamps? Or is there some other, perhaps more general, solution I'm not seeing here?
Seems like you are creating foo.obj in the DLL's project, linking foo.obj in the DLL project to produce the DLL, and then linking foo.obj to your EXE project without first recompiling it.
I have never done this before, but first thing I would check is to make sure the Intermediate Directory settings are the same for both the EXE project and the DLL project.
Go to the project that is not needed for unit testing
Right click on it and press Properties
Click on Configuration manager
Add a new configuration using the first drop down list
Click ok
Select that configuration in the window that is now focused
then in configuration properties set "Excluded From Build" to yes