Xcode 4 external build project and debugging - c++

I've got a makefile based project set up that builds my code on multiple platforms. On my Mac I want to use Xcode for debugging though. I've set up an Xcode as an External Build Project I can run the application from within Xcode. The output is shown in Xcode and if the app crashes it drops in to the debugger, but when running the debugger cannot locate the source files, so I just see assembly output. How can I tell Xcode where to locate the source?
I also cannot set breakpoints, but I think that this is all the same problem.

I was able to fix the issue of not stopping at breakpoints by setting a custom working directory for the executable.
Before this change I was able to build successfully using the external scons system from Xcode 4. My code would run when called from XCode but breakpoints would be ignored.
Then in XCode,
Go to Product -> Edit Scheme...
CHeck 'use custom working directory'
and I set this to the same directory as the executable.
Breakpoints then started working.

Ensure -g is included in the compiler options in the makefile.
Set a custom working directory in the scheme, set the executable if this hasn't already been set.
Ensure that the project isn't pulling in dylibs that haven't been compiled with -g. You might need a build step to run make install if the project builds dylibs as well as the main target.
Make sure that "strip" isn't being called. There are environment vars that xcode set that allow you to keep a working makefile when used outside xcode.
Just had this problem and this worked (Xcode 4.6) (got source debugging and working breakpoints)

In "Project Navigator" (the file-folder icon just below the "Run" button), right click and select "Add Files To your-project". Browse to the top level folder where you would normally run the external build, and click Add.

Related

Visual Studio 2019 Debugger "Unable to start program ... Access is denied" caused by build file [duplicate]

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).

CLION -- How to create and debug a configuration for an application not mentioned in the CMakeLists.txt file

How can I configure CLion to debug an executable not referenced in a CMakelLists.txt file? OR
How can I configure CLion to debug an executable created using the Makefile plugin?
I am working with CLion 18.2.3 without a CMakeLists.txt file.
I created a configuration from the Application template and named the configuration “Execute”. In the Execute configuration, I specify the executable (main) and the target as All targets. The executable exists (having been built earlier using the Makefile Plugin).
When I attempt to debug or run the Execute configuration, Clion reports,
Error running Execute: Cannot run Execute on <default>.
I am not sure how to get CLion to debug an executable that is in the project directory that is not referenced in a CMakeLists.txt file.
I have a large project which uses the Makefile plugin. This compiles the desired executable beautifully. However, I am not able to debug the executable, set breakpoints, or otherwise use debugging with the executable. I have run this on Ubuntu 18.04 and on Mac OSX High Sierra.
So, either
1. How can I configure CLion to debug an executable not referenced in a CMakelLists.txt file? OR
2. How can I configure CLion to debug an executable created using the Makefile plugin?
Thank you,
John
Here is a copy of the configuration that is being run:
The first image shows the output when this configuration is run, "Error running'Execute': Cannot run 'Execute' on ''"
If you open the drop down menu in the top right of clion and click edit configuration you are able to create custom configurations. There you can add the executable and parameters if required. Now you should be able to run and also debug this executable.
Another option is to run the executable and attach the debugger over the menu entry run->attach to local process (Ctrl+Alt+5) and then select you executable.

Eclipse GDB can't find source files

My workspaces are located in my home directory.
I am currently trying to debug python code which loads a shared C++ library, using Eclipse Oxygen and PyDev. I can debug the Python files just fine.
I run the program (pytest unit test if that matters) with a breakpoint somewhere in the test before the shared library is called (but after it is loaded) and then run a C/C++ Attach to Application debug and attach to the paused python thread. I then set a breakpoint in my C++ code and resume python, and get this from the GDB console output:
No source file named /home/myname/.../models/sourcefile.cpp
Doing an ls /home/myname/.../models clearly shows that that file exists.
I'm not sure if this matters but my library was compiled with CMake where the source and build directory are siblings. E.g. workspace is ~/dev and source is in ~/dev/sourceFolder and build files are in ~/dev/buildFolder
Update:
I was able to attach to the running Python debug thread manually in the console using gdb python <thread_number>. This works and finds my source files just fine, allowing me to debug manually in the console. It would still be much faster and less cumbersome if I were able to get it to work in Eclipse.
Things I've tried in the C++ debug config settings:
In preferences, changing C/C++ -> Debug -> Source Lookup to have
absolute file path first, profile first, and relative file path
first
In CppDebug settings debugger tab, manually added build and source directory to shared libraries
In CppDebug settings source tab, manually added source directory in source lookup path
None of these seemed to do much.
For cmake projects:
The launch configuration can default to the wrong executable, so go to launch configuration => main and check the "C/C++ Application"
Change it from this: build/default/
to this: build/cmake.debug.linux.x86_64/
(you can do this with the "Search Project" button.
This will then pick up the correct debug version and all your source will be found when you debug.

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.

QtCreator and "Run CMake"

When running CMake from the project view in QtCreator ("Run CMake" command), CMake wizard pops up. This is becoming really annoying and since I'm QtCreator newbie, I don't know if there is any remedy for this.
Desired effect would be automatic execution of cmake, without the CMake wizard pestilence.
Yes, this GUI annoying me too.
The only option is to add custom build step in your Project configuration
run app: cmake
params CMakeLists.txt
working folder: %{sourceDir}
this step should be added BEFORE make step.
Once you have created a project in Qt Creator, you do not need to use the "Run CMake" command unless for some reason you think the project files are out of date. Just click build, run, debug etc and it will take care of compiling the files that need to be compiled and invoking CMake as and when necessary.
Underneath it uses Unix Makefiles with Codeblocks in order to generate an XML description of the project. Running CMake from the menu explicitly re-runs CMake and reparses the XML description.