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

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.

Related

Eclipse C++ Setup, Path to executable not set

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.

A matching Debug configuration cannot be found in the wxWidgets directory you specified.

I have tried to setup and create wxWidgets project using wxWindgets installer and code::block-mingw installations.
When I am trying to create a wx-widgets smith project, I have below problem
A matching Debug configuration cannot be found in the wxWidgets directory you specified.
This means Debug target of your project will not build
Are you sure you want to continue with these settings ?
does anybody have any idea about this and what is the recommended way to setup wxWidgets and code-block in Windows ?
Did you compile your wxWidgets as a debug build? I got the same error, because I only buitl wxWidgets as a release build. However, I didn't intend to use the debug build anyway, because I didn't want to debug it, just use it. So you can continue with your project and then you have to replace the library names with the correct ones. Mostly this means removing the d at the end of the library name.
If you want to use a debug build, you have to build wxWidgets as a debug as well.
To fix the library names, you'd have to right-click on your project and go to "Build options... -> Linker settings".
Update
To compile it using MingW you have to follow this guide.
You may also have to adjust the include paths in your build options:
D:\src\c\wxWidgets_3.0.0\lib\gcc_lib\msw
D:\src\c\wxWidgets_3.0.0\include
And for the linker:
D:\src\c\wxWidgets_3.0.0\lib\gcc_lib
Problem is solved by following the exact instruction provided in Compiling wxWidgets 3.0.0 to develop Code::Blocks (MSW) section. I couldn't build wxWidgets correctly in windows. After I build wxWidget the same alert message mentioned in the question was popped when creating wxWidgets project using Code::Block but I dismissed and continue to create the project. This time it was worked.

The program file specified in the launch configuration does not exist

I am facing some problems regarding eclipse for c/c++. I am trying to create a new project, I provide the code, and after running the code I get this error:
The program file specified in the launch configuration does not exist
C:\Users\elisabeth\workspace\mm\Debug\mm.exe not found
Please notice that I am working with spice toolkit; I set the path for the "include" files and the libraries, but still I can not have a result.
What causes this error and how can I resolve it?
Right click on your project --> Properties
Run/Debug settings
Delete whatever is set as "launch configuration for '........'
Project --> Clean
Project --> Build Project
You can create a run configuration. Go to Run > Run Configurations. Click New button, fill C/C++ Application field, i.e., insert path to your executable. The new configuration will appear in the list which appears when you click to the arrow next to run button.
Of course this assumes your can build without problems, otherwise you won't see an executable to point to.
You can clean the project, build it again and run it as a local C/C++ application. Simplified steps as follows,
Right click on the project
Clean Project
Again Right click on the project
Build Project
Again Right click on the project
Run As ->
Local C/C++ Application
As the error reads:
C:\Users\elisabeth\workspace\mm\Debug\mm.exe not found
First of all you need to check whether there is an executable "mm.exe" in your Debug folder. (Of course, it is not there and that is why the error)
Go to Project > Clean
and you should see some files being deleted from your Debug folder
Go to Project > Build Project
and you should see some new files being generated e.g. mm.d, mm.o, mm. This "mm" is probably the executable you're looking for
Now that you know what your executable is, you should tell eclipse what file to execute instead of mm.exe. Go to Project properties and in run debug settings create a new configuration (or edit an existing configuration, if there is one already). In this configuration, in main tab, in C/C++ Application specify a full path to "mm". Which, in your case is - "C:\Users\elisabeth\workspace\mm\Debug\mm"
A better way to do this in eclipse is:
${project_loc}/"your folder"/"your executable file"
e.g.${project_loc}/Debug/mm
what worked for me is file->refresh
then do the Debug configuration again by choosing the right c/c++ binary again.
Avoid troubles with configuration by going into Project properties > C/C++ build > Refresh Policy and specify your project folder. The configuration option "Search project" will show a correct folder then and you will see whatever you build there - Debug, Release or both. You don't want to specify the folder using Browse option every time you import project or switch configurations.
As this is the first SO discussion that appears for this topic on Google and none of the answers solved the problem my students were having, I would like to mention the solution we eventually found from this answer:
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
Keep clicking Move Up until it is at the top
This had been set to Elf, even though we were using a freshly downloaded Windows version of Eclipse.
sometime missed closing curly brace can be part of a problem. Make sure prototype your function at the beginning of the file. Then right click your project in the left side bar. click clean project. then click build project and finally run project
I encountered similar issues and their related problems a few days ago. Finally, I found out that, just because I had moved my project folder (workspace folder of Eclipse) to another place so Eclipse could not find what its need as usual.
Solution: I just set the workspace to my new place (Hey Eclipse, my workspace now is here) :
Menu "File" -> "Switch workspace" -> "Other..." -> click "Browse..." button and point to new place then click "Select Folder" button and click "Launch" button.
Nice day.

Visual Studio 2008 says "the specified file is an unrecognized or unsupported binary format" when I try to debug

I have a VS2008 solution containing two C++ projects. One is a Win32/console .dll and the other is a tester program to test that dll, also a Win32 console app.
When I build the solution, even with a clean build and with the Debug Command set to the hardcoded path to the executable, trying to debug presents a messagebox saying,
"the specified file is an unrecognized or unsupported binary format".
The program it is trying to execute is the source of tester.cpp.
Can someone suggest a cure? What information may I provide to help solve this problem?
Please make sure that your test application (it should be an executable: .exe) is the one you're running and not the DLL. Set it as the "startup project" for example.
You can do so from within your Solution Explorer by right-clicking the appropriate project and selecting "Set as startup project".
I have a VS2010 solution containing two C++ projects:
one project generates a .lib file and the another project (which contains"main.cpp") is used to test the functionality provided by the .lib file.
for that, I go to the solution explorer, right click '2nd Project' and go to References. when you click "Add new reference", it already contains references to the First Project. Select it.
Now, I need to set the '2nd Project' (which contains "main.cpp") as start-up project so that I can debug the code. for that, again, go to the solution explorer, right click '2nd Project' and go to Set as StartUp Project
The easiest way to solve this issue, is to delete the .suo file and re-build the project.
First, you have to change your folder options, to show hidden files (as the .suo file is generally hidden). If you are not sure how to do it, refer to http://windows.microsoft.com/en-sg/windows/show-hidden-files#show-hidden-files=windows-7
Secondly, browse to the location where the respective Visual Studio Solution file is saved and delete the .suo file. If you need to know more about the .suo files, please refer to http://msdn.microsoft.com/en-us/library/bb165909.aspx
Finally, re-build your project.
This method, generally has solved most of similar issues which occurred to me.
Hope this helps!

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.