undefined reference to symbol even when nm indicates that this symbol is present in the shared library

后端 未结 1 668
北海茫月
北海茫月 2020-12-05 17:58

What could be wrong here? I have the following simple class:

#include  \"libmnl/libmnl.h\"

int main() {
    struct mnl_socket *a = mnl_socket_open(12);
}
<         


        
相关标签:
1条回答
  • 2020-12-05 18:08

    Libraries must be listed after the objects that use them (more precisely, a library will be used only if it contains a symbol that satisfies an undefined reference known at the time it is encountered). Move the -lmnl to the end of the command.

    0 讨论(0)
提交回复
热议问题