Discussion:
[CMake] No debugging symbols found when using -DCMAKE_BUILD_TYPE=Debug
Esch Nigma
2016-06-01 12:10:41 UTC
Permalink
Hello all,

I just registered to this mailing list, my apologies if this was already discussed.

I'm experiencing an issue where I'm unable to debug my code when the project is
configured with CMake. When running gdb on the final binary, it mentions that no
debugging symbols are found. I tried this via the command line, and through QT Creator.

After asking on StackOverflow, I was given a workaround - Cmake fails to figure out the
compiler identification automatically. Adding -DCMAKE_CXX_COMPILER_ID:STRING=GNU
makes it all work just fine. However, it should still detect it automatically.

I've built an empty Hello world to display this:

[***@manjaro quicktest]$ cat main.cpp #include<iostream> using namespace
std;

int main(){ cout << "Hello there"; }


When I build into a subdirectory and try to debug, this is the output:

[***@manjaro build]$ cmake .. -DCMAKE_BUILD_TYPE:STRING="Debug"

*Scanning dependencies of target qtest*
[100%] Building CXX object CMakeFiles/qtest.dir/main.cpp.o
*Linking CXX executable qtest*
[100%] Built target qtest


[***@manjaro build]$ gdb qtest GNU gdb (GDB) 7.11 Copyright (C) 2016 Free
Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/
licenses/gpl.html> This is free software: you are free to change and redistribute it. There is
NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty"
for details. This
GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details. For bug reporting instructions, please
see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other
documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>.
For help, type "help". Type "apropos word" to search for commands related to "word"...
Reading symbols from qtest...(no debugging symbols found)...done. (gdb)

However - when I compile manually, it works fine:

[***@manjaro quicktest]$ c++ -g main.cpp [***@manjaro quicktest]$
gdb a.out GNU gdb (GDB) 7.11 Copyright (C) 2016 Free Software Foundation, Inc. License
GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free
software: you are free to change and redistribute it. There is NO WARRANTY, to the extent
permitted by law. Type "show copying" and "show warranty" for details. This GDB was
configured as "x86_64-pc-linux-gnu". Type "show configuration" for configuration details.
For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at: <http://www.gnu.org/
software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for
commands related to "word"... Reading symbols from a.out...done. (gdb) quit


I have tested this on cmake version 2.8.11.2 and 3.5.2.
This problem started happening a few days ago, on two different machines, both running
Manjaro Linux.

I'll be able to continue coding for now, but I wanted to report on this anyway - as far as I
know, it should all be automatic.

Thanks,
Esch
Chuck Atkins
2016-06-01 14:05:21 UTC
Permalink
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
This is definitely the reason for no debug symbols. If the compiler is
unknown then CMake won't know the right flags to pass to generate debug
info. The more important question though is why the compiler can't be
identified. What compiler is being used? Can check with /usr/bin/c++
--version ?
Esch Nigma
2016-06-01 14:49:54 UTC
Permalink
The standard choice is c++

[***@manjaro ~]$ c++ --version c++ (GCC) 6.1.1 20160501 Copyright (C) 2016
Free Software Foundation, Inc. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.


But I've tried enforcing g++ as such:

-DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc -DCMAKE_CXX_COMPILER:STRING=/usr/
bin/g++

And that has the same results.

Version:

[***@manjaro ~]$ g++ --version g++ (GCC) 6.1.1 20160501 Copyright (C) 2016
Free Software Foundation, Inc. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.



On Wednesday, June 1, 2016 10:05:21 AM EEST Chuck Atkins wrote:


[***@manjaro build]$ cmake .. -DCMAKE_BUILD_TYPE:STRING="Debug"



This is definitely the reason for no debug symbols. If the compiler is unknown then
CMake won't know the right flags to pass to generate debug info. The more important
question though is why the compiler can't be identified. What compiler is being used?
Can check with /usr/bin/c++ --version ?
Chuck Atkins
2016-06-01 15:46:40 UTC
Permalink
Interesting. It seems CMake is having trouble identifying GCC in 6.1.1.
Do you have a 5.x compiler available? If so does it work with that? That
would help narrow it down to a gcc6 issue vs something about how Manjaro
packages compilers.

- Chuck
Post by Esch Nigma
The standard choice is c++
c++ (GCC) 6.1.1 20160501
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc
-DCMAKE_CXX_COMPILER:STRING=/usr/bin/g++
And that has the same results.
g++ (GCC) 6.1.1 20160501
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
This is definitely the reason for no debug symbols. If the compiler is
unknown then CMake won't know the right flags to pass to generate debug
info. The more important question though is why the compiler can't be
identified. What compiler is being used? Can check with /usr/bin/c++
--version ?
Esch Nigma
2016-06-01 17:59:45 UTC
Permalink
I tried it out just now.

I pulled and installed a couple 5.x packages from the Arch archive:
https://archive.archlinux.org/packages/l/

The packages:
gcc-libs-multilib-5.3.0-4-x86_64.pkg.tar.xz
gcc-multilib-5.3.0-4-x86_64.pkg.tar.xz
lib32-gcc-libs-5.3.0-4-x86_64.p

The downgrade didn't change anything for my Hello World program.

For the project I'm actively working on, it broke everything, since C++11 is no longer
recognized.


On my system I had to pull the 'multilib' versions, as this is what my system seems to be
using. If requested, I can try to switch to normal gcc to test that out.


Interesting. It seems CMake is having trouble identifying GCC in 6.1.1. Do you have a 5.x
compiler available? If so does it work with that? That would help narrow it down to a gcc6
issue vs something about how Manjaro packages compilers.




- Chuck




On Wed, Jun 1, 2016 at 10:49 AM, Esch Nigma <***@openmailbox.org[1]> wrote:


The standard choice is c++

[***@manjaro ~]$ c++ --version c++ (GCC) 6.1.1 20160501 Copyright (C) 2016 Free
Software Foundation, Inc. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.


But I've tried enforcing g++ as such:

-DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc -DCMAKE_CXX_COMPILER:STRING=/usr/
bin/g++

And that has the same results.

Version:

[***@manjaro ~]$ g++ --version g++ (GCC) 6.1.1 20160501 Copyright (C) 2016 Free
Software Foundation, Inc. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.



On Wednesday, June 1, 2016 10:05:21 AM EEST Chuck Atkins wrote:


[***@manjaro build]$ cmake .. -DCMAKE_BUILD_TYPE:STRING="Debug"



This is definitely the reason for no debug symbols. If the compiler is unknown then
CMake won't know the right flags to pass to generate debug info. The more important
question though is why the compiler can't be identified. What compiler is being used?
Can check with /usr/bin/c++ --version ?









--------
[1] mailto:***@openmailbox.org
Chuck Atkins
2016-06-01 20:54:02 UTC
Permalink
Wow, so this is actually a pretty obscure find. You've definitely stumbled
across a bug. It has nothing to do with debug symbols and everything to do
with compiler identification. It seems that our binary strings parsing is
broken when "[anything]" is in the file path. Without looking at the code
too deeply, i imagine something is not getting properly escaped somewhere.
As a workaround for now, rename your "[Code]" folder to "Code" and then it
should work (lame I know). I would ask you to please file a bug report but
new user registration is currently disabled due to some spam issues we were
having. I'll put it in the queue for issues to address in future releases
but I doubt it will make it into the 3.6 release since it seems to have
been there for a long time without affecting too many users but it should
be able to get fixed in a future release.

Once we open the bug tracker up again then please definitely report the
issue (unless you already have an account then go ahead and report it now).

Thanks for the find!



- Chuck
Post by Esch Nigma
I tried it out just now.
https://archive.archlinux.org/packages/l/
gcc-libs-multilib-5.3.0-4-x86_64.pkg.tar.xz
gcc-multilib-5.3.0-4-x86_64.pkg.tar.xz
lib32-gcc-libs-5.3.0-4-x86_64.p
The downgrade didn't change anything for my Hello World program.
For the project I'm actively working on, it broke everything, since C++11
is no longer recognized.
On my system I had to pull the 'multilib' versions, as this is what my
system seems to be using. If requested, I can try to switch to normal gcc
to test that out.
Interesting. It seems CMake is having trouble identifying GCC in 6.1.1.
Do you have a 5.x compiler available? If so does it work with that? That
would help narrow it down to a gcc6 issue vs something about how Manjaro
packages compilers.
- Chuck
The standard choice is c++
c++ (GCC) 6.1.1 20160501
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc
-DCMAKE_CXX_COMPILER:STRING=/usr/bin/g++
And that has the same results.
g++ (GCC) 6.1.1 20160501
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
This is definitely the reason for no debug symbols. If the compiler is
unknown then CMake won't know the right flags to pass to generate debug
info. The more important question though is why the compiler can't be
identified. What compiler is being used? Can check with /usr/bin/c++
--version ?
e***@openmailbox.org
2016-06-02 10:06:50 UTC
Permalink
Renaming the folder did indeed fix it here. I tested with g++ and Clang,
both work fine.
This is on a different machine than I was posting from before, but it's
also running Manjaro.
I will test this on my main machine once I'm home, which will be be in
six hours or so, and I'll let you know the results.
Wow, so this is actually a pretty obscure find. You've definitely stumbled across a bug. It has nothing to do with debug symbols and everything to do with compiler identification. It seems that our binary strings parsing is broken when "[anything]" is in the file path. Without looking at the code too deeply, i imagine something is not getting properly escaped somewhere. As a workaround for now, rename your "[Code]" folder to "Code" and then it should work (lame I know). I would ask you to please file a bug report but new user registration is currently disabled due to some spam issues we were having. I'll put it in the queue for issues to address in future releases but I doubt it will make it into the 3.6 release since it seems to have been there for a long time without affecting too many users but it should be able to get fixed in a future release.
Once we open the bug tracker up again then please definitely report the issue (unless you already have an account then go ahead and report it now).
Thanks for the find!
- Chuck
Post by Esch Nigma
I tried it out just now.
https://archive.archlinux.org/packages/l/ [1]
gcc-libs-multilib-5.3.0-4-x86_64.pkg.tar.xz
gcc-multilib-5.3.0-4-x86_64.pkg.tar.xz
lib32-gcc-libs-5.3.0-4-x86_64.p
The downgrade didn't change anything for my Hello World program.
For the project I'm actively working on, it broke everything, since C++11 is no longer recognized.
On my system I had to pull the 'multilib' versions, as this is what my system seems to be using. If requested, I can try to switch to normal gcc to test that out.
Interesting. It seems CMake is having trouble identifying GCC in 6.1.1. Do you have a 5.x compiler available? If so does it work with that? That would help narrow it down to a gcc6 issue vs something about how Manjaro packages compilers.
- Chuck
The standard choice is c++
c++ (GCC) 6.1.1 20160501
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc -DCMAKE_CXX_COMPILER:STRING=/usr/bin/g++
And that has the same results.
g++ (GCC) 6.1.1 20160501
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
This is definitely the reason for no debug symbols. If the compiler is unknown then CMake won't know the right flags to pass to generate debug info. The more important question though is why the compiler can't be identified. What compiler is being used? Can check with /usr/bin/c++ --version ?
Links:
------
[1] https://archive.archlinux.org/packages/l/
Brad King
2016-06-02 18:36:53 UTC
Permalink
Post by Chuck Atkins
Wow, so this is actually a pretty obscure find. You've definitely stumbled
across a bug. It has nothing to do with debug symbols and everything to do
with compiler identification. It seems that our binary strings parsing is
broken when "[anything]" is in the file path.
This should fix it:

CMakeDetermineCompilerId: Fix compiler id with square brackets in the path
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a7d1c4ec

-Brad
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Loading...