View previous topic :: View next topic |
Author |
Message |
ekigwana n00b
Joined: 09 Jan 2018 Posts: 2
|
Posted: Tue Jan 09, 2018 9:15 pm Post subject: How do I install libbacktrace which comes with GCC |
|
|
I have tried all the flags but can't seem to end up with a libbacktrace. Does the library archive get combined into another one?
I am trying to integrate boost stacktrace into my code but can't get it to print like in the examples.
The example in question is here: terminate_handler.cpp
I am compiling the example as such:
Code: | g++ -ggdb3 -DBOOST_STACKTRACE_DYN_LINK -DBOOST_STACKTRACE_USE_BACKTRACE -o terminate_handler terminate_handler.cpp -ldl -lboost_stacktrace_backtrace -lbacktrace |
It seems libboost_stacktrace_backtrace is also missing because libbacktrace is missing. |
|
Back to top |
|
|
ekigwana n00b
Joined: 09 Jan 2018 Posts: 2
|
Posted: Tue Jan 09, 2018 10:00 pm Post subject: How can Boost stacktrace libbacktrace support be added? |
|
|
Boost has support for libbacktrace but getting them both installed in a bit tricky.
For libbacktrace:
Code: |
git clone https://github.com/ianlancetaylor/libbacktrace.git
cd libbacktrace && ./configure --prefix=/usr --libdir=/usr/lib64 --includedir=/usr/include/backtrace && make install
|
Note that if libdir for backtrace is /usr/include, compiling boost after the fact fails.
For boost: Usual portage method.
Test code: test.cpp
Code: |
#include <iostream>
#include <boost/stacktrace.hpp>
void bar(int)
{
// ... somewhere inside the `bar(int)` function that is called recursively:
std::cout << boost::stacktrace::stacktrace();
}
int main()
{
bar(1);
return 0;
}
|
To build and run test:
Code: |
g++ -ggdb3 -o test test.cpp -I /usr/include/backtrace -ldl -lbacktrace -DBOOST_STACKTRACE_USE_BACKTRACE && ./test
|
For more examples see boost stacktrace getting started and https://github.com/boostorg/stacktrace/tree/develop/example
Sample output is:
Code: |
0# bar(int) at /home/user/test/test.cpp:7
1# main at /home/user/test/test.cpp:14
2# 0x00007FB1A9CF2F0A in /lib64/libc.so.6
3# 0x00005565733C123A in ./test
|
This allows a developer to save stack traces for exceptions and signals etc without the user having to run gdb. So you can save the core and stack trace for issues that never show up under GDB. |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21633
|
Posted: Wed Jan 10, 2018 12:05 am Post subject: Re: How can Boost stacktrace libbacktrace support be added? |
|
|
ekigwana wrote: | Code: | git clone https://github.com/ianlancetaylor/libbacktrace.git
cd libbacktrace && ./configure --prefix=/usr --libdir=/usr/lib64 --includedir=/usr/include/backtrace && make install |
| Are you sure about those instructions? That make install will fail if the user is not root. If the user is root, he should not run make install at all, as that would copy files into /usr, which will likely cause file collisions later. |
|
Back to top |
|
|
ekigwana n00b
Joined: 09 Jan 2018 Posts: 2
|
Posted: Wed Jan 10, 2018 2:56 pm Post subject: Re: How can Boost stacktrace libbacktrace support be added? |
|
|
Hu wrote: | ekigwana wrote: | Code: | git clone https://github.com/ianlancetaylor/libbacktrace.git
cd libbacktrace && ./configure --prefix=/usr --libdir=/usr/lib64 --includedir=/usr/include/backtrace && make install |
| Are you sure about those instructions? That make install will fail if the user is not root. If the user is root, he should not run make install at all, as that would copy files into /usr, which will likely cause file collisions later. |
As the title states I am asking how support can be added. I have never contributed an ebuild to Gentoo and it'd be convenient to also add a use flag to boost to pull in the libbacktrace package as well. When building boost, the configuration clearly shows that support for libbacktrace is included but ultimately I think it should be disabled since no package provides that capability. Now adding a libbacktrace ebuild that could get pulled in solves that issue. |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21633
|
Posted: Thu Jan 11, 2018 3:31 am Post subject: |
|
|
Sorry. You posted a line that, if run, goes exactly against the advice we give people over and over and over again, yet new users continue to post that advice. Installing packages system-wide, and especially installing them into /usr, without the package manager is a major cause of later problems. Eliminating that habit early is good for everyone.
To your immediate problem: ekigwana wrote: | It seems libboost_stacktrace_backtrace is also missing because libbacktrace is missing. | Please explain this statement. ekigwana wrote: | Note that if libdir for backtrace is /usr/include, compiling boost after the fact fails. | Shouldn't libdir point to a library directory (as shown in your instructions), not an include directory (as stated in your quoted fragment)? In what way does Boost fail?
ekigwana wrote: | When building boost, the configuration clearly shows that support for libbacktrace is included but ultimately I think it should be disabled since no package provides that capability. | A USE flag could be useful, but if Boost can be built with this support, there is no reason to disable it just because no Gentoo packages require it. Gentoo users may wish to build an unpackaged or out-of-tree package program that can use this functionality. |
|
Back to top |
|
|
moodboom n00b
Joined: 06 Aug 2007 Posts: 24
|
Posted: Thu Jan 18, 2018 4:15 am Post subject: So what is the solution to missing libbacktrace? |
|
|
All pedantic philosophizing aside how can we get this going? This is important to me and I wonder what the best approach is to get an "official" libbacktrack.. tia.... |
|
Back to top |
|
|
moodboom n00b
Joined: 06 Aug 2007 Posts: 24
|
Posted: Thu Jan 18, 2018 7:24 pm Post subject: Is a /usr/local install of libbacktrace a Good Idea? |
|
|
Is a /usr/local install of libbacktrace a Good Idea?
Something like...
Code: | git clone https://github.com/ianlancetaylor/libbacktrace.git
cd libbacktrace && ./configure --prefix=/usr/local --libdir=/usr/local/lib64 --includedir=/usr/local/include/backtrace && make install |
|
|
Back to top |
|
|
moodboom n00b
Joined: 06 Aug 2007 Posts: 24
|
Posted: Fri Jan 19, 2018 12:43 am Post subject: |
|
|
I used a workaround. Boost has two methods of getting backtraces. One uses libbacktrace, and the other uses the addr2line cmd, which is (probably) already in /usr/bin.
Code: | #define BOOST_STACKTRACE_USE_ADDR2LINE
#include <boost/stacktrace.hpp>
.
.
.
std::cout << boost::stacktrace::stacktrace(); |
And away we go. |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21633
|
Posted: Sat Jan 20, 2018 7:16 pm Post subject: |
|
|
Based on the instructions posted, it looks like a separate ebuild for it should be quite simple. The main issue is the report that Boost does not react well to preinstalling this separate package. This needs to be investigated and fixed.
An install to /usr/local is fine for spot testing, but the package ought to be wrapped in an ebuild for long term maintenance. |
|
Back to top |
|
|
|