Code Monkey home page Code Monkey logo

libfinder's Introduction

LibFinder

Problem
You include some system header, compile and you get undefined reference to X and now need to hunt down the library you need to link.

Solution
You run sudo updatedb to update your file location database, then libfinder -u to update the lookup table and then libfinder -s X and libfinder will tell you which libraries define the symbol you need.

Further options
Output of libfinder -h:

libfinder finds the libraries that define a given symbol.
Run 'sudo updatedb' to make sure all libs are locatable, create an index with
'libfinder -u' (once every time your libs change) and look up a symbol with
'libfinder -s [symbol]' to get a list of libraries that define [symbol].
Parameters:
  -h [ --help ]              print this
  -u [ --update ] [=arg(=8)] update lookup table (must be done before first
                             use) with given number of threads (default=8)
  -s [ --symbol ] arg        the symbol to look up

Example output

% libfinder -s mysql_init
All symbols that have the prefix "mysql_init" and their libraries:
mysql_init
        /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18
        /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18.1.0
        /usr/lib/x86_64-linux-gnu/libmysqlclient_r.so.18
        /usr/lib/x86_64-linux-gnu/libmysqlclient_r.so.18.1.0
mysql_init_character_set
        /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18
        /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18.1.0
        /usr/lib/x86_64-linux-gnu/libmysqlclient_r.so.18
        /usr/lib/x86_64-linux-gnu/libmysqlclient_r.so.18.1.0

Future work
Add an option to instead of printing the file path, print either the linker flags or makefile line or CMakeLists.txt entry or qmake file entry to link that library.

libfinder's People

Contributors

toeger avatar

Stargazers

Advik avatar Magnus avatar  avatar  avatar

Watchers

James Cloos avatar  avatar

libfinder's Issues

Fix file_separator

Inside the lookup file there is an entry_separator with the value '\0' (the only character that cannot be in a filepath in linux) and a file_separator with the value '\1'. Unfortunately '\1' is a valid character in a path name in linux. Therefore libfinder will print the incorrect output when library files or their paths contain a '\1'. To fix this one needs to replace the file_separator with "\0\0" and add logic to support that and not confuse it with the entry_separator.

Add tests

Currently there are no tests at all. At least one would need to have a known library with known symbols and check if libfinder finds them. Also need to check if the first and last symbol can be found without any error.

Combine symbolic links in output

If a library is actually just a symbolic link to another library it should not be listed as a library with all symbols duplicated. Instead the real library should list all its alternative names and the symbols only once.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.