软讯网络 > 操作系统 > Linux > gcc/g++: 连接到特定library
【标 题】:gcc/g++: 连接到特定library
【关键字】:
gcc/g++,library
【来 源】:http://blog.csdn.net/antk119/archive/2006/11/14/1383320.aspx
gcc/g++: 连接到特定library
- 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