国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

configure: error: C compiler cannot create executables錯誤解析

這篇具有很好參考價值的文章主要介紹了configure: error: C compiler cannot create executables錯誤解析。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

一. 前言

? ? ? ? 在編譯開源軟件的時候,有時會遇到"configure: error: C compiler cannot create executables"的錯誤,表示不能生成可執(zhí)行文件。本文以編譯curl-7.40.0為例,模擬出這種錯誤,并講解解決這種錯誤的方法。錯誤輸出如下:

[root@192 curl-7.40.0]# ./configure LIBS=-lopenssl
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether to enable debug build options... no
checking whether to enable compiler optimizer... (assumed) yes
checking whether to enable strict compiler warnings... no
checking whether to enable compiler warnings as errors... no
checking whether to enable curl debug memory tracking... no
checking whether to enable hiding of library internal symbols... yes
checking whether to enable c-ares for DNS lookups... no
checking for path separator... :
checking for sed... /usr/bin/sed
checking for grep... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ar... /usr/bin/ar
checking for a BSD-compatible install... /usr/bin/install -c
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/home/betterman/opensource/curl-7.40.0':
configure: error: C compiler cannot create executables
See `config.log' for more details

二. 錯誤解析

? ? ? ? 根據(jù)最后一句輸出,我們需要參考config.log的內(nèi)容。從config.log文件中,可以找到如下一段內(nèi)容:

configure:4216: checking whether the C compiler works
configure:4238: gcc ? ?conftest.c -lopenssl >&5? ? ? ? ? ? ? ? ? ?(1)
/usr/bin/ld: cannot find -lopenssl? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (2)
collect2: error: ld returned 1 exit status
configure:4242: $? = 1
configure:4280: result: no
configure: failed program was:
| /* confdefs.h */? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (3)
| #define PACKAGE_NAME "curl"
| #define PACKAGE_TARNAME "curl"
| #define PACKAGE_VERSION "-"
| #define PACKAGE_STRING "curl -"
| #define PACKAGE_BUGREPORT "a suitable curl mailing list: http://curl.haxx.se/mail/"
| #define PACKAGE_URL ""
| /* end confdefs.h. ?*/
|?
| int main (void)
| {
|?
| ?;
| ?return 0;
| }
configure:4285: error: in `/home/wenyong/opensource/curl-7.40.0':
configure:4287: error: C compiler cannot create executables? ? ? ? ? ? ? ? (4)
See `config.log' for more details

? ? ? ? 從(1)可知,gcc會編譯conftest.c文件并且需要鏈接libopenssl.so,所以報(2)的錯誤,表示編譯時找不到libopenssl.so庫,conftest.c的內(nèi)容是從(3)開始,最后產(chǎn)生了(4)處的錯誤。

三. 解決方法

? ? ? ? 由上可知,可以得出結論:軟件包在configure的時候,configure會根據(jù)用戶指定的編譯選項編譯conftest.c文件,由此來預檢查編譯時要用到的gcc,動態(tài)庫等是否可以找到,盡早讓用戶檢查錯誤。

? ? ? ? 本例的錯誤是由于libopenssl.so找不到,所以解決方法有:

1. 通過LDFLAGS選項指定libopenssl.so所在的路徑,例如:

./configure LIBS=-lopenssl?LDFLAGS=/root/libopenssl/usr/lib

2. 直接使用./configure編譯

? ? ? ? 如果編譯curl不需要用到openssl的庫,可以不鏈接。

四. 總結

? ? ? ? 本文講解了解決"configure: error: C compiler cannot create executables"問題出現(xiàn)的原因與解決的思路:configure運行的時候需要使用用戶指定的選項編譯conftest.c文件,但是由于選項指定的gcc或動態(tài)庫找不到,導致編譯報錯,解決的方法是指定gcc和動態(tài)庫的路徑。文章來源地址http://www.zghlxwxcb.cn/news/detail-545967.html

到了這里,關于configure: error: C compiler cannot create executables錯誤解析的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若轉載,請注明出處: 如若內(nèi)容造成侵權/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包