Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to place/find debug library on Linux?

On Windows, a debug library's name has a d as a postfix. But I don't know if there is a rule on Linux.

I know there is some dbg packages on Debian. For example, the library of the package libjpeg62-dbg is placed in /usr/lib/debug/usr/lib/libjpeg.so.62.0.0. Is it a standard rule to place a debug version library into /usr/lib/debug?

And more. For example, if I run pkg-config --libs opencv that will return the GCC link options to me such as:

-L/usr/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann

It's very good. But I don't find a option in pkg-config which can return link options of those debug version libraries such as:

-L/usr/lib/debug -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann

Why pkg-config has not a option to return debug version of options if there is a standard rule about debug version library?

So, I want to know:

  1. Is there a standard directory to place a debug library?
  2. Are there some commands or options to process a debug library like pkg-config --libs?
  3. How do you process the problem if the above two answers are no?

Thanks.

like image 931
Yantao Xie Avatar asked Sep 13 '11 03:09

Yantao Xie


2 Answers

Linux and windows have differing views on this. In Linux, there's really not much of a point in offering a debug library, because if someone really wants to debug the library they usually have the source code. Otherwise, you can mix and match (linking a "release" library with a "debug" program is just fine). You can be a nice guy and leave the debugging symbols in if you really want to (sysadmins can strip symbols out if they think there's too much bloat).

The other problem is that under linux there are too many compiler flags. There's not just "debug" and "release". There are a million flags you can turn on and off, as well as various target architectures. That's why most library developers just release the source code and let the user (or distro maintainer) decide what to turn on and off. In other words, there's no way your idea of a "debug" library would anticipate every developer's needs.

like image 140
Chris Eberle Avatar answered Oct 28 '22 09:10

Chris Eberle


You don't need to link with a debug version of the library in order to use it, which is why pkg-config doesn't offer such an option. All you need to do is set up your LD_LIBRARY_PATH appropriately when you run the program, and the debug library will get used at runtime.

like image 33
Chris Jester-Young Avatar answered Oct 28 '22 11:10

Chris Jester-Young