No symbols/source for external library in Xcode 4
Asked Answered
P

1

9

My application is not seeing source code for a library:

  • If I "Jump to definition" on a library method, XCode takes me to the .h file but says there is no .cpp counterpart
  • When debugging, I see no source code and most of the call-stack is missing for the library: enter image description here
  • I have made sure "Show disassembly when debugging" is UNchecked

I built the library as DEBUG and then packaged up the headers+.a file into a SDK dir. So I guess I need to either copy the debug files into that SDK dir as well, or tell my application where to look. I'm not sure how to do either.

To clarify, my application project doesn't maintain a reference to the library project, only to the .a files and the header dirs. This is because the library project is created by CMake and I don't want to modify it.

Philander answered 15/10, 2012 at 12:43 Comment(3)
Was the library compiled on the machine you are debugging on? Are the source files in the same place they were when the library was compiled with debug information? What debug flags did you give to the compiler when building the library?Weyermann
Yes it was compiled on the same Mac but independently, I just tell the application project where the .a and headers are. The source .cpp files are not moved, but I have moved the headers and the .a file to create a SDK; are there absolute paths or something? Where and how does Xcode store such information?Philander
Did you ever solve this? I have a similar question over here: #18904282Buzzer
W
10

First of all, you should check the .debug_str section of your static library to verify it contains the appropriate debug information.

Try running this command on the terminal:

xcrun dwarfdump /path/to/library.a | grep "\.m"

You should see a bunch of your source (.m) file paths printed out. Theoretically, this is where Xcode is going to look when you stop in the debugger, so make sure the paths here are correct. If you don't see any paths, you will need to pass an appropriate debug flag (e.g. -g to the compiler when building your library.

If the paths are somehow incorrect, or you want to point them to some other location, you may be able to modify them as part of the build process in CMake, for example to make them relative to your project directory. Try looking at "Make gcc put relative filenames in debug information", which uses CMake to adjust these debug paths.

Weyermann answered 18/10, 2012 at 15:52 Comment(5)
FYI this is a C++ application but I assume I just replace .m for .cpp i your answer?Philander
I get no output at all when I run that with "\.m" or "\.cpp". Can you double-check that's correct? My debug lib is 650Mb compared to the release one at 30Mb so I'm pretty sure it's being built as debug!Philander
Any progress on this question? I am running into a similar problem here: #18904282Buzzer
I was building a small library, added the -g to the compiler, but nothing showed up with the xcrun dwarfdum mylib command ( all sections 'empty'). After doing a "make clean" and then building again it worked. After (full) rebuilding my main project linking with that .a file, I can indeed step into it from the xcode-debugger!Refresh
Thanks for that, very helpful even today. Do you know a way to remap the path after the library was created? Importing a third party library (Qt) from installed binaries, and trying to debug through it.Septavalent

© 2022 - 2024 — McMap. All rights reserved.