Linux c ++错误:未定义引用'dlopen' [英] Linux c++ error: undefined reference to 'dlopen'

查看:900
本文介绍了Linux c ++错误:未定义引用'dlopen'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Linux中使用C ++(Eclipse),并且想使用库。
Eclipse显示我一个错误:

I work in Linux with C++ (Eclipse), and want to use a library. Eclipse shows me an error:

undefined reference to 'dlopen' 

你知道一个解决方案吗?

Do you know a solution?

这是我的代码:

#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>

int main(int argc, char **argv) {
    void *handle;
    double (*desk)(char*);
    char *error;

    handle = dlopen ("/lib/CEDD_LIB.so.6", RTLD_LAZY);
    if (!handle) {
        fputs (dlerror(), stderr);
        exit(1);
    }

    desk= dlsym(handle, "Apply");

    if ((error = dlerror()) != NULL)  {
        fputs(error, stderr);
        exit(1);
    }

    dlclose(handle);
}


推荐答案

,添加


-ldl

-ldl

您的链接器选项

这篇关于Linux c ++错误:未定义引用'dlopen'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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