现在的位置: 首页 > 综合 > 正文

gcc/g++: 连接到特定library

2013年09月07日 ⁄ 综合 ⁄ 共 388字 ⁄ 字号 评论关闭
  • 5. 執行程式的問題
  • 5-7. 編譯程式時發現如 " /tmp/ccQrRIy4.o(.text+0x7): undefined reference to `SSL_library_init' " 之找不到某library提供之function的錯誤訊息。

    解答:
    編譯程式若需要連結到特定library需增加 -lLIBNAME 之參數。

    這裡以test.c需要使用到openssl之library為例:

    % gcc -o mytest test.c  
    /tmp/ccZJHPg1.o: In function `main':
    /tmp/ccZJHPg1.o(.text+0x7): undefined reference to `SSL_library_init'
    % gcc -o mytest -lssl -lcrypto test.c
    % ls -l mytest
    -rwxr-xr-x   1 nestlin  wheel        4320 May 12 09:33 mytest

抱歉!评论已关闭.