Debugging C in Eclipse - "Can't find source file" - c++

I've installed Eclipse for C/C++ Developer and cygwin, following this guide. Also, in Preferences > C/C++ > Enviroment, I added all variables. I mounted /c to c: in cygwin, and now when I type mount in the terminal I get the following:
$ mount
C:/cygwin64/bin on /usr/bin type ntfs (binary,auto)
C:/cygwin64/lib on /usr/lib type ntfs (binary,auto)
C:/cygwin64 on / type ntfs (binary,auto)
C: on /c type ntfs (binary,user)
My program builds and runs successfully in Eclipse, but when I try to debug (adding a breakpoint on the first line), I get the error:
Can't find a source file at "/cygdrive/c/Users/steve/eclipse-workspace/myProgram/myProgram.c"
Locate the file or edit the source lookup path to include its location.
I then found this guide to deal with this error, so that my Path Mapping was /cygdrive/c C:\
However, I now get the following error when trying to debug:
Can't find a source file at "/usr/src/debug/gcc-7.4.0-1/libgcc/config/i386/cygwin.S"
Locate the file or edit the source lookup path to include its location.
I don't know where to go from here, could anyone help me out?

Related

Different FS roots (docker vs. host env) and navigation from compilation error paths in Terminal

I am using vscode for my development with C++ and docker (Linux) and I have an issue with my compilation-to-code-editing work cycles.
Namely, I get errors with paths like this from the compiler:
In file included from **/rootsrc/myproj/test.cpp:33**:
<here is some error description>
And now if I hold Ctrl and left mouse-click on the file reference, vscode has no idea where that file is and gives me an error "No matching result".
Is there some way to set vscode up such that this plugin (or whatever it is) that is responsible for navigating from path links in the Terminal "knows" that it should first cut off the docker base dir and then prepend my host dir before resolving the path link?
Thanks in advance :)

How to configure source lookup path for Debug in C++ in eclipse?

I have a project which im working in with C++20 in Eclise IDE, I'm using CygWin 3.4.0-1 compiler. I edited my source lookup path for my main file as gdb had the wrong route, now i can see the main file while debugging, but it won't find the source file for any other included file that is not the main.
This is one of the errors i get:
Can't find a source file at "/usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/x86_64-pc-cygwin/bits/Pin.hpp"
If I locate the file with the actual Pin.hpp, the debugger will show it to me but the instructions it's running make no sense when going step by step.
This is my source lookup path configuration:

Why my "Reso"(resources) file is not recognized in Clion while trying to run OpenCV?

I'm trying to run a single program that opens a image file in Clion C++:
See image:
As you can see here, i have a file named "Reso" and a image named "test.png", but this code always will promt "Error reading image"
NOTE: I have proven that this does work in Visual Studio perfectly, but for some reason the file is not recognized in Clion
When you run a binary in CLion, your application will have by default the current working directory set to where your binary is located, which is probably somewhere in your cmake-build-debug directory.
In your case you expect a certain directory, because your resource file is somehwere else. You can either change your code to allow passing the path by argument, or you can set the working directory in CLion for your binary.
In the top you have this bar, where you can choose your build target. There is an option Edit configurations and when you open this and select your target, you can see a field Working directory. Set this field appropriate for your project.

LLDB - setting source code path

According to the official guideline of lldb, the ability to view source code during debug session (using the command source list) is done by setting new pathname for source files.
i.e. if i compiled my project in /tmp on one computer and deployed it on another computer where the source code reside in /Users/Src/ , i should type settings set target.source-map /tmp /Users/Src from running lldb in the deployment machine.
However, what happens if i got the executable from someone else, and don't know the build directory. and maybe the source-code is organized differently from where is was built (but the file contents is the same).
my questions are :
Does lldb know how to search for matching source file recursively in the supplied path ?
How can I get the original pathname form the mach-o executable ?
here's the formal description of the command :
Remap source file pathnames for the debug session. If your source files are no longer located in the same location as when the program was built --- maybe the program was built on a different computer --- you need to tell the debugger how to find the sources at their local file path instead of the build system's file path.
If you know a function name in the code in question, do:
(lldb) image lookup -vn <FunctionName> <BinaryImageNameContainingFunction>
and look for the CompileUnit entry. The path given there is the path lldb got from the debug information.

Where should i save codeblocks projects?

so i downloaded codeblocks codeblocks-13.12mingw-setup-TDM-GCC-481.exe
when i try to run main.cpp i get this error message:
Failed to open 'C:\Users\$imba\Documents\Codeblocks projects\test\main.cpp'.
this is a detailed summary of what i did prior to opening main.cpp
i selected the defaults all the way through the end. I created a seperate folder (called Codeblocks projects) in my documents to save the projects in.
now when i went to create a new folder, i selected console application, C++ and then i named my project test. i decided to create the project in the Codeblocks projects folder that i created. the resulting filename comes out to be C:\Users\$imba\Documents\Codeblocks projects\test\test.cbd
i then selected
GNU GCC Compiler,
'Create Debug Configuration: Debug'
output dir: bin\Debug\
object dir.: obj\Debug\
i selected create Release configuration,: 'Release'
output dir.: bin\release\
objects output dir.: obj\ Release
Finish
when i double click on main.cpp is when i get the error message
Failed to open 'C:\Users\$imba\Documents\Codeblocks projects\test\main.cpp'.
please help, i need this program for my course.
Try saving it in a folder in C:\, like C:\Cpp\. Code::Blocks may be having problems with the space or the $ in the file path.
I just created a new folder CB-Project under my D: drive where I have codeblocks installed.
You may want to look in the directory that you have CB installed in first, you may also find this in program file (x86) or the codeblocks sub directory. Look for a file named that may have proj or project in it's name. If you don't find it you can just create a new folder. You will have to put the new folder name in the CB path so it will find it.