I am trying to port a fairly large project in C ++ to g ++ 4.0 on Mac OS X. My project compiles without errors, but I cannot get GDB to work correctly. When I look at the stack by typing "bt" on the GDB command line, all file names and line numbers are displayed incorrectly.
For example, according to the GDB stack trace, my main() function should be in stdexcept from the Mac OS X SDK, which makes no sense.
What can cause GDB to fail? I already checked the instructions for #line and #file in my code and made sure that the code only has UNIX line endings. I also cleaned and rebuilt the project. I also tried debugging the Hello World project, and it did not have the same problem.
Could the problem be related to one of the third-party libraries that I am linking, and how are they compiled? Or is it completely different?
The following are two examples of gcc and ld calls made by Xcode . AFAIK all cpp files in my project are compiled and linked with the same parameters.
/Developer/usr/bin/gcc-4.0 -x C ++ -arch i386 -fmessage-length = 0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -fpermissive -Wreturn-type -Wunused-variable -DNO_BASS_SOUND -D_DEBUG -DXCODE -D__WXMAC__ -isysroot / Developer / SDK / MacOSX10.5.sdk -mfix-and-continue -fvisibility-inlines-hidden -mmacosx-version-min = 10.4 -gdwarf-2 -D_FILE_OFFSET_FIT_BIT_LIT_LIT -D__WXDEBUG__ -D__WXMAC__ -c "/ Users / adriangrigore / Documents / Gemsweeper Mac / TSDLGameBase.cpp" -o "/ Users / adriangrigore / Documents / Gemsweeper Mac / assemblies / Gemsweeper Mac.build/Debug/Gemsweeper Mac.build/Obss normal / i386 / TSDLGameBase.o "
/ Developer / usr / bin / g ++ - 4.0 -arch i386 -isysroot / Developer / SDKs / MacOSX10.5.sdk "-L / Users / adriangrigore / Documents / Gemsweeper Mac / assemblies / debugs" -L / Developer / SDKs / MacOSX10 .5.sdk / USR / local / Library -L / opt / local / lib "-F / Users / adriangrigore / Documents / Gemsweeper Mac / builds / debugging" -F / Users / adriangrigore / Library / Frameworks -F / Developer / SDKs / MacOSX10.5.sdk / Library / Frameworks-filelist "/ Users / adriangrigore / Documents / Gemsweeper Mac / assemblies / Gemsweeper Mac.build/Debug/Gemsweeper Mac.build/Objects-normal/i386/Gemsweeper Mac.LinkFileList" - mmacosx-version-min = 10.4 / opt / local / lib / libboost_program_options-mt.a / opt / local / lib / libboost _filesystem-mt.a / opt / local / lib / libboost _serialization-mt.a / opt / local / lib / libboost _system-mt.a / opt / local / lib / libboost _thread-mt.a "/ Users / adriangrigore / Documents / Gemsweeper Ma c / third batch /FreeImage/Dist/libfreeimage.a "" / Users / adriangrigore / Documents / Gemsweeper Mac / third batch / CPUInfo -1.0 / libcpuinfo.a "-L / usr / local / lib -framework IOKit -framework Carbon -framework Cocoa -framework System -framework QuickTime -framework OpenGL -framework AGL -lwx_macd_richtext-2.8 -lwx_macd_aui-2.8 -lwx_macd_xrc-2.8 -lwx_macd_qa-2.8 -lwx_macd_html- 2.8 -lwx_macd_adv-2.8 -lwx_macd_core-2.8 -lwx_base_carbond_xml-2.8 -lwx_base_carbond_net -2.8 -lwx_base_carbond-2.8 -framework SDL -framework Cocoa -o "/ Users / adriangrigore / Documents / Gemsweeper Mac / assemblies / Debug / Gemsweeper Mac.app/Contents/MacOS/Gemsweeper Mac"
Please note that I already asked a similar question about the Xcode debugger here , but I am posting a message since I just found out that this is not really an Xcode error, but a problem with GCC / ld / GDB.
Edit: My project uses the following third-party libraries: SDL , Boost , wxWidgets . I'm not sure if this matters for this problem, but I just wanted to mention this just in case.
I tried compiling the Xcode SDL project template and did not experience the same problem, so this should be due to something special in my project.
Second Edit . As I just found out, I was mistaken when searching for files with the string "This is automatically generated." I just found dozens of files with one line, all of which belong to FreeImage , one of the third-party libraries that I use. So the problem seems to be related to FreeImage, but I'm still not sure how to do this.