zoukankan      html  css  js  c++  java
  • 增加ldl

    增加ldl

    g++ -o onecache tmp/eventloop.o tmp/logger.o tmp/main.o tmp/hash.o tmp/redisproto.o tmp/redisproxy.o tmp/redisservant.o tmp/command.o tmp/tcpsocket.o tmp/tcpserver.o tmp/thread.o tmp/tinystr.o tmp/tinyxml.o tmp/tinyxmlerror.o tmp/tinyxmlparser.o tmp/redis-proxy-config.o tmp/iobuffer.o tmp/redis-servant-select.o tmp/redisservantgroup.o tmp/locker.o tmp/monitor.o tmp/top-key.o tmp/non-portable.o tmp/proxymanager.o tmp/cmdhandler.o tmp/md5.o tmp/crc16.o tmp/crc32.o tmp/hsieh.o tmp/jenkins.o tmp/fnv.o tmp/murmur.o /usr/local/lib/libevent.a /usr/local/lib/libevent_pthreads.a -lrt -pthread /usr/local/lib/libjemalloc.a
    /usr/local/lib/libjemalloc.a(background_thread.o): In function `pthread_create_fptr_init':
    /data1/users/bikang1/jemalloc-5.2.1/src/background_thread.c:843: undefined reference to `dlsym'
    /data1/users/bikang1/jemalloc-5.2.1/src/background_thread.c:843: undefined reference to `dlsym'
    collect2: error: ld returned 1 exit status

    g++  -o onecache tmp/eventloop.o tmp/logger.o tmp/main.o tmp/hash.o tmp/redisproto.o tmp/redisproxy.o tmp/redisservant.o tmp/command.o tmp/tcpsocket.o tmp/tcpserver.o tmp/thread.o tmp/tinystr.o tmp/tinyxml.o tmp/tinyxmlerror.o tmp/tinyxmlparser.o tmp/redis-proxy-config.o tmp/iobuffer.o tmp/redis-servant-select.o tmp/redisservantgroup.o tmp/locker.o tmp/monitor.o tmp/top-key.o tmp/non-portable.o tmp/proxymanager.o tmp/cmdhandler.o tmp/md5.o tmp/crc16.o tmp/crc32.o tmp/hsieh.o tmp/jenkins.o tmp/fnv.o tmp/murmur.o      /usr/local/lib/libevent.a /usr/local/lib/libevent_pthreads.a -lrt -pthread /usr/local/lib/libjemalloc.a -ldl

    ldl的作用

    下面内容摘自 https://www.cnblogs.com/SZxiaochun/p/7718621.html

    如果你的程序中使用dlopen、dlsym、dlclose、dlerror 显示加载动态库,需要设置链接选项 -ldl

    加载动态链接库,首先为共享库分配物理内存,然后在进程对应的页表项中建立虚拟页和物理页面之间的映射。

    你可以认为系统中存在一种引用计数机制, 每当一个进程加载了共享库(在该进程的页表中进行一次映射),引用计数加一;

    一个进程显式卸载(通过dlclose等)共享库或进程退出时,引用计数减 一,

    当减少到0时,系统卸载共享库。

    (1)打开动态链接库:dlopen,函数原型void *dlopen (const char *filename, int flag); dlopen用于打开指定名字(filename)的动态链接库,并返回操作句柄。

    (2)取函数执行地址:dlsym,函数原型为: void *dlsym(void *handle, char *symbol); dlsym根据动态链接库操作句柄(handle)与符号(symbol),返回符号对应的函数的执行代码地址。

    (3)关闭动态链接库:dlclose,函数原型为: int dlclose (void *handle); dlclose用于关闭指定句柄的动态链接库,只有当此动态链接库的使用计数为0时,才会真正被系统卸载。

    (4)动态库错误函数:dlerror,函数原型为: const char *dlerror(void); 当动态链接库操作函数执行失败时,dlerror可以返回出错信息,返回值为NULL时表示操作函数执行成功。

  • 相关阅读:
    [LeetCode] 329. Longest Increasing Path in a Matrix
    [LeetCode] 1180. Count Substrings with Only One Distinct Letter
    [LeetCode] 1100. Find K-Length Substrings With No Repeated Characters
    [LeetCode] 312. Burst Balloons
    [LeetCode] 674. Longest Continuous Increasing Subsequence
    [LeetCode] 325. Maximum Size Subarray Sum Equals k
    [LeetCode] 904. Fruit Into Baskets
    [LeetCode] 68. Text Justification
    [LeetCode] 65. Valid Number
    [LeetCode] 785. Is Graph Bipartite?
  • 原文地址:https://www.cnblogs.com/beckbi/p/13155075.html
Copyright © 2011-2022 走看看