Libnetlink,gcc.对rtnl_open的未定义引用 [英] Libnetlink, gcc. undefined reference to rtnl_open

查看:184
本文介绍了Libnetlink,gcc.对rtnl_open的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用libnetlink时遇到问题.

I have a problem with using libnetlink.

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <libnetlink.h>


int main(int argc, char **argv)
{

struct rtnl_handle* rth;
unsigned bitmap_socket_group;
if ((rtnl_open(rth,bitmap_socket_group))==-1)
{
    printf("Some sht happend\n");
    return -1;
}


return 0;
}

之后,我正在运行gcc -o rt route-test.c并返回:

After that i'm running gcc -o rt route-test.c and it returns:

/tmp/ccvqPhGI.o: In function `main': route-test.c:(.text+0x19): undefined reference to `rtnl_open'
collect2: error: ld returned 1 exit status

我想要的只是测试libnetlink.作为一个helloworld. gcc参数有问题吗? 希望获得帮助:)

All i want is just to test libnetlink. As a helloworld. Is it a problem with gcc arguments? Hope for help:)

推荐答案

似乎您缺少标头或未能链接到所需的库.您确定不需要在编译字符串中包含-lnetlink吗? –  David C. Rankin

It appears you are either missing a header or your a failing to link against a needed library. Are you sure there is no -lnetlink you need to include in your compile string? – David C. Rankin

您是对的,我需要-lnetlink!谢谢:) –  AlexZ

You're right, i need -lnetlink! Thank you:) – AlexZ

这篇关于Libnetlink,gcc.对rtnl_open的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆