Identifying which Linux system library contains a function

前端 未结 6 715
误落风尘
误落风尘 2020-12-20 14:30

I am using a dev system where I have to specify the lib name when accessing a function inside it.

I\'ve used functions like open() before, and somehow found out that

6条回答
  •  借酒劲吻你
    2020-12-20 14:54

    When I cross-compile Windows applications on Linux, if I have an issue with linking I tend to use this script that I named mingw-findin. A similar script could be used for regular Linux compilation, just instead of using the mingw alternative, use regular nm and instead of looking in the cross-compile prefixed directory, look in /usr/lib. To use this script, I run

    ./mingw-findin NameOfFunction

    Here's the code:

    #!/bin/sh
    liblist=` ls /usr/x86_64-w64-mingw32/lib `
    
    for i in $liblist
    do
    
    if x86_64-w64-mingw32-nm /usr/x86_64-w64-mingw32/lib/$i | grep -q $1; then
            echo $i
            x86_64-w64-mingw32-nm /usr/x86_64-w64-mingw32/lib/$i | grep $1
    fi
    
    done
    

提交回复
热议问题