I wrote a program which packs my resources into a file, and that should happen before I'm starting my main program. How can I start that program, before my main program starts(e.g. by clicking on "Debug" or "Start" in Visual Studio)?
If you go to the Project Properties -> Configuration Properties -> Debugging, you can edit the Command section and add your program.
Although answer by Luchian Grigore is perfectly fine, there are few alternatives to consider:
If you need to pack your resources only once on build, but not every time debugger starts, you can add "Build Events" or "Custom build steps" (see project options).
You can add another project to solution, and make main project depend on it. It can be Makefile project, so you can do whatever you want on build
You can spawn your resource packer process directly from C++ code (probably only in debug mode, by using conditional compilation)
Related
I have a solution in C:\full path here\VS2010\blender.sln
This solution contains many projects(around 100). When I compile them, they all work fine. I can run them without any problem, and (quite) everything works (there are some bugs).
One of the projects is ALL_BUILD, but it gives the same error if I try to debug INSTALL(another project). I'm compiling with RELWithDebInfo as configuration, and if I execute the program manually it works. It is outputted in C:\full path here\VS2010\bin\RelWithDebInfo
But if I try to run the compiler, it says
"Unable to start program
C:\full path here\VS2010\RelWithDebInfo\ALL_BUILD
Specified file cannot be found"
I tried to copy the compiled program into the path required by VS, but it raised the same error.
What should I do to solve this? Right now I set up cmake to generate also a mingw project and I compile it and debug it with gdb, but this is a really a slow and impractical workflow, and I would like to use the VS debugger.
I must say that if I compile with Debug as configuration, the program doesn't even start.
I'm using VS2010 Express on Win7 64bit
(This is a big open source program, so I don't know exactly whatever it does)
Guessing from the information I have, you're not actually compiling the program, but trying to run it. That is, ALL_BUILD is set as your startup project. (It should be in a bold font, unlike the other projects in your solution) If you then try to run/debug, you will get the error you describe, because there is simply nothing to run.
The project is most likely generated via CMAKE and included in your Visual Studio solution. Set any of the projects that do generate a .exe as the startup project (by right-clicking on the project and selecting "set as startup project") and you will most likely will be able to start those from within Visual Studio.
I had the same problem :)
Verify the "Source code" folder on the "Solution Explorer", if it doesn't contain any "source code" file then :
Right click on "Source code" > Add > Existing Item > Choose the file You want to build and run.
Good luck ;)
I think that what you have to check is:
if the target EXE is correctly configured in the project settings ("command", in the debugging tab). Since all individual projects run when you start debugging it's well possible that only the debugging target for the "ALL" solution is missing, check which project is currently active (you can also select the debugger target by changing the active project).
dependencies (DLLs) are also located at the target debugee directory or can be loaded (you can use the "depends.exe" tool for checking dependencies of an executable or DLL).
I need to run a code generator before starting compilation\execution of my code in Visual Studio 2015.
Is there any way to add a script that will run my .bat.py file when I click "Start Local Debugger"?
I use UnrealEngine 4 and in my project there already are some .cs files that use precompilation scripts, but these scripts are not fired if the project is already up-to-date.
Any solutions?
Open properties of your startup project in VS (should be your game, not UE4). You need Configuration Properties → Debugging.
When you click Local Windows Debugger (this is what it's labeled in my VS) it runs whatever is specified under Command with Command Arguments. UE4 projects usually have $(TargetPath) and "$(SolutionDir)$(ProjectName).uproject" specified but you can change it to run your .bat script and add custom logic.
However, if your project is not up to date, Build Command Line is going to be called before the debugger (Configuration Properties → NMake). For UE4 that would be UnrealEngine\Engine\Build\BatchFiles\Build.bat script. If you need your logic to run before Build.bat you can put it here. Or replace this script with your own.
I try to program some stuff in c++ with eclipse, but I have slight difficulties.
When I create a new Project compiling and making works fine but when I try to run the Application I get the following error message:
"Launch failed. Binary not found"
So what I found out by using google is this workaround:
-right-click on the projekt in the projekt explorer
-select "run as" and then "run configurations"
-expand "c/c++ application" in the navbar on the left
-and in the main tab of the project select "browse"
-navigate to folder "debug" and select the .exe
after I do that, running works fine but I have to do it again every time I create a new Project, is there a way to automate this process?
And what I also noticed: I don't have a "binaries" folder in my projects in the project explorer, maybe its related to that, but I really don't know.
Any help is appreciated
Thanks
Tim
Edit: added a video: http://youtu.be/RKnTOkoHFRU
There will only be a Binaries folder if the build was successful. You will have to manually build to get a binary in order for the Binaries folder to appear. Likewise, if you clean (remove) your build folder then Binaries will disappear.
I would guess that Eclipse cannot find your binary "out-of-the-box" because you are using external tools to manage the build process; that is, if you have a custom makefile project (or another type of project that uses another tool to handle the building) then Eclipse will not be able to provide a default run configuration because it does not "know" where the binary is or even which binary to run if there are multiple. Thus, you have to set up the Run Configuration as you are doing now.
If you create a project and let Eclipse do the building, then Eclipse can find the binaries automatically. For example, simply create an "Empty C++ Project" under "Executable". Write some hello world code. Click build. Then click run. Eclipse launches the binary because it is managing the build process and thus "knows about" where the binary ends up.
Open project properties (Right click on your project, choose Properties on the menu)
C/C++ Build -> Settings
Click on Binary Parsers tab and check PE Windows Parser
as seen here stackoverflow.com/questions/9407430, answer number 3 or 4
In my case
I just save the programme. Press CTRL+B to build it.
Refresh it.
Then run the programme.
Now you can see this will work fine.
I have already answered this for other question see the link Launch Failed Binary not found Eclipse for C in Windows at 10th number.
I started an Eclipse project as an executable. It worked correctly. Then I changed it to a DLL in Project Properties -> C/C++ Build -> Settings -> Build Artifact -> Artifact Type. It still worked. (this was all with basically Hello World functionality)
So I included a bunch of stuff in my project file to actually move toward the app I want to build. I couldn't get it to quite compile, but I've included a lot of paths and libraries that I don't want to have to re-enter (or I'd just start a new project). Just to find out if I could still compile Hello World with all these includes, I changed it back to an executable in the same spot as above. It seems to work, in that it changes it on that screen; and it even changes the file extension that it feeds to the /OUT parameter of the linker. But it's still passing the /DLL parameter to the linker, as well, and I can't find the project property page where I can remove this.
Note that, when I copy-paste the command line that the Eclipse console spits out, to the command prompt and remove the /DLL parameter manually, it links properly and forms an executable that produces the correct functionality. But when I try to run the exe from the IDE, or whenever it tries to rebuild, it gives me a message box error saying my process has encountered a problem.
Error starting process.
Cannot run program "C:\Users\2659\workspace\MoreStuff\Debug\MoreStuff.exe": Launching failed
Cannot run program "C:\Users\2659\workspace\MoreStuff\Debug\MoreStuff.exe": Launching failed
Cannot run program "C:\Users\2659\workspace\MoreStuff\Debug\MoreStuff.exe": Launching failed
How can I remove this /DLL flag so that I can have actual control over what my project is outputting?
I just had a similar problem: I created a new C++ project with shared artifact nature and wanted to test it by adding a main function and a new executable build option.
In order to successfully change the nature you have also to go to Project Properties -> C/C++ Build -> Settings -> G++ Linker -> Shared Library Settings and (in the proper configuration) uncheck the Shared option.
It worked for me.
I am trying to write, compile and execute a "HelloWorld" C++ program using Eclipse. I have managed to install and run Eclipse, create a new project and write the HelloWorld program. Now I would like to compile it and to run.
I did not find "Compile" option in Eclipse, but I found "Build Project" option in the "Project" menu. I assume that Build is what I call "compilation". After I clicked this options, Eclipse generated "Debug" folder, containing "src" sub-folder as well as 3 files: "sources.mk", "objects.mk" and "makefile". First, I do not know what these files mean (and which of them is my "executable"). Second, I still need to execute my program. I tried to click "Run" option in the "Run" menu. As a result I got an error message: "Launch failed. Binary not found".
Can anybody, please, help me to compile and run my code using Eclipse.
Eclipse being an IDE is meant to create projects not restricted to just one file as a result multiple files exists which have to be linked and compiled so as to work in sync as per the methods implemented in the project.To run the project or a particular program a binary of that particular project is required which gets created only if the build is successful .So a successful build is must for binary creation which in turn is responsible for running the project or program.
So first build the project using Ctrl+B after succesfull build then run the project.
This simple question was asked nine years ago, so I don't know if it is still active. Anyway, one thing not mentioned in the responses so far that might be helpful to others is that Eclipse requires a "Run Configuration" to run programs. From the original post, if the "Build Project" command returned successfully, then the "Debug" folder should also contain a file called "HelloWorld" at the same folder level as "makefile" and "objects.mk". That is your executable. To run it, go to Run -> Run Configurations, which should produce a popup containing a field called "C/C++ Application". Click the "Browse" button, find, and select the "HelloWorld" executable in the "Debug" folder. Click "Run" in the lower right and you should see your output.