gcc 的 -ldl 参数是什么意思? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
rrfeng
V2EX    问与答

gcc 的 -ldl 参数是什么意思?

  •  
  •   rrfeng 2013-04-27 17:22:15 +08:00 12332 次点击
    这是一个创建于 4601 天前的主题,其中的信息可能已经有所发展或是发生改变。
    情景:
    编译安装 keepalived,需要 openssl-devel 的库

    但是 openssl 也是编译安装的,安装目录是 /usr/local/openssl

    keepalived configure 的时候,无论是
    --libdir=/usr/local/openssl
    还是
    LDFLAGS="$LDFLAGS -L/usr/local/openssl" ;
    或者指定 /usr/local/openssl/lib /usr/local/openssl/include 等目录

    均提示 OpenSSL 库找不到。



    最终在
    LDFLAGS="-ldl" ./configure
    的时候编译成功了,成功的自动找到了 openssl 中相关文件
    2 条回复    1970-01-01 08:00:00 +08:00
    wwwjfy
        1
    wwwjfy  
       2013-04-27 17:53:30 +08:00   1
    -llibrary
    -l library
    Search the library named library when linking. (The second alternative with the library as a separate argument is only for POSIX compliance and is not recommended.)

    It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, foo.o -lz
    bar.o searches library z after file foo.o but before bar.o. If bar.o refers to functions in z, those functions may not be loaded.

    The linker searches a standard list of directories for the library, which is actually a file named liblibrary.a. The linker then uses this file as if it had been specified
    precisely by name.

    The directories searched include several standard system directories plus any that you specify with -L.

    Normally the files found this way are library files---archive files whose members are object files. The linker handles an archive file by scanning through it for members which
    define symbols that have so far been referenced but not defined. But if the file that is found is an ordinary object file, it is linked in the usual fashion. The only difference
    between using an -l option and specifying a file name is that -l surrounds library with lib and .a and searches several directories.


    -L 只是加入搜索库的路径,-l指定要链接的库
    -ldl, dl就是库的名字
    seupengdi
        2
    seupengdi  
       2013-04-27 23:55:12 +08:00
    就是libdl.so吧 某种有用的动态库
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     927 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 24ms UTC 22:11 PVG 06:11 LAX 14:11 JFK 17:11
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86