gcc xx.c:(.text+0x11): undefined reference to `sqrt'
gcc prime.c -o prime
報錯
undefined reference to `sqrt’
由於程式碼中使用了math庫中的sqrt方法, 所以要這樣寫
gcc prime.c -o prime -lm
-l選項是連結某個庫, 這裡我們連結math庫.
Linux的庫命名是一致的,一般為libxxx.so,或libxxx.a,libxxx.la,那麼你要連結某個庫就用-lxxx,去掉頭lib及”.”後面的so,la,a等即可。 因為數學函式位於libm.so庫檔案中(通常在/lib目錄下),-lm選項告訴編譯器,我們程式中用到的數學函式要到這個庫檔案裡找.
[ro[email protected] c]# find / -name libm.so
/usr/lib64/libm.so
歡迎補充指正!
相關推薦
gcc xx.c:(.text+0x11): undefined reference to `sqrt'
gcc prime.c -o prime報錯 undefined reference to `sqrt’ 由於程式碼中使用了math庫中的sqrt方法, 所以要這樣寫 gcc prime
Linux程式設計時使用gcc編譯.c出現以下問題,pthread.c:(.text+0x29): undefined reference to `pthread_create'collect2: err
Linux程式設計時使用gcc編譯.c出現以下問題 client.c:(.text+0x13e): undefined reference to `pthread_create' collect2: ld 返回 1 解決方法如下: 只需在用gcc編譯時加上-pthread選項即
關於移植jSON編譯時報錯sbrkr.c:(.text+0xc): undefined reference to `_sbrk'處理
最近有個專案需要用到jSON函式,在移植了jSON後編譯報錯如下:sbrkr.c:(.text+0xc): undefined reference to `_sbrk'。 通過百度查詢知道原來是GCC編譯器不支援malloc、free、memcpy、strlen等函式導致的,正常在嵌入式系統
thread_join.c:(.text+0x6f): undefined reference to `pthread_create' 問題的解決
今天在測試一個執行緒例子時,結果出現如下錯誤 [[email protected] fzf]# gcc thread_join.c -o thread_join /tmp/cc1HozRv.o: In function `main': thread_join.
ffmpeg:libavformat/http.c:1435: error: undefined reference to 'inflateEnd'
安卓動態庫編譯過程中遇到了一個ffmpeg相關的報錯,具體資訊如下: libavformat/http.c:1435: error: undefined reference to 'inflateEnd' libavformat/http.c:626: error: undefined re
ffmpeg:libavfilter/vf_elbg.c:169: error: undefined reference to 'avpriv_init_elbg'
ffmpeg編譯過程中遇到的一個報錯,具體資訊如下: -e [info] [*] link ffmpeg -------------------- libavfilter/vf_elbg.c:169: error: undefined reference to 'avpriv_init_el
C++編譯提示“undefined reference to...”
編寫的一個簡單C++時鐘Clock類,放入了標頭檔案中,主函式在呼叫標頭檔案進行編譯時出現上述錯誤,具體程式碼如下: clock.h: #include <iostream> using namespace std; class Clock { private:
Linux C/C++ 開發遇到 undefined reference to xxx
環境 CentOS 7.3 CodeBlocks 16.01 gcc 4.9.4 wxGTK 3.0.2 非常簡單的應用。例如: test.h #ifndef TEST_H_INCLUDED #define TEST_H_INCLUDED void test(); #end
C 語言 undefined reference to 'sqrt' 問題解決
題目:一個整數,它加上100後是一個完全平方數,再加上168又是一個完全平方數,請問該數是多少? 1.程式分析:在10萬以內判斷,先將該數加上100後再開方,再將該數加上268後再開方,如果開方後 的結果滿足如下條件,即是結果。請看具體分析: 2.程式原始碼
c/c++中出現“undefined reference to”的解決
undefined reference to”的意思是,該函式未定義。 如果使用的是gcc,有以下檢查方案: 如果提示未定義的函式是某個庫的函式。檢查庫時候已經安裝,並在編譯命令中採用-l和-L引數匯入庫。 如果提示未定義的函式是程式中的函式。檢查是否在標頭檔案中宣告
test.cpp:(.text+0xc0): undefined reference to `cv::imread(std::string const&, int)'
defined mpi x11 -c nal pil enc lib issue opencv報錯: test.cpp:(.text+0xc0): undefined reference to `cv::imread(std::string const&, int
庫依賴錯誤導致main.c:(.text+0x7): undefined reference問題
最近在Linux下程式設計發現一個詭異的現象,就是在連結一個靜態庫的時候總是報錯,類似下面這樣的錯誤: (.text+0x13): undefined reference to `func' 關於undefined reference這樣的問題,大家其實
ubuntu下 GCC編譯程式出現 undefined reference to `std::ios_base::Init::Init()'問題——gcc編譯C++程式碼
hello.o: In function `main':hello.cpp:(.text+0x41): undefined reference to `std::cin'hello.cpp:(.text+0xd1): undefined reference to `std::cout'hello.o: In
[ c++] cmake 編譯時 undefined reference to `std::cout' 錯誤的解決方案
bin cut () cmake fin epo linking com urn cmake .. 和 make 之後,出現如下錯誤 Linking CXX executable ../../../bin/ModuleTest CMakeFiles/Modu
undefined reference to `recvIpcMsg(int, ipc_msg*)'——#ifdef __cplusplus extern "C" { #endif
使用 type -s endif 但是 pcm nbsp rec c語言 最近在弄一個進程間通信,原始測試demon用c語言寫的,經過測試ok,然後把接口封裝起來了一個send,一個recv。 使用的時候send端是在一個c語言寫的http服務端使用,編譯ok沒有報錯,但是
gcc編譯undefined reference to本質原因
專案中的LVS用到keepalived和ipvsadm等三方件,在suse11和suse12上編譯最新版本的過程中遇到的最多的錯誤便是 undefined reference to xxx。由於對背後的原理基本沒啥理解,所以遇到問題的解決辦法就是把錯誤資訊拿去google,baidu搜。當遇
undefined reference to 與gcc編譯器細節的關係
在用c語言寫專案的時候,有三個檔案,一個頭檔案兩個原始檔分檔案1檔案2,在編譯的時候,出現瞭如下的錯誤 經過檢查,在標頭檔案中的函式聲名沒有錯誤,在原始檔1中的函式定義也沒有錯誤,在原始檔2中的函式呼叫也沒有出現錯誤, 從此開始在網上查閱各種資料,都沒有得到滿意的答覆,然後問了一遍大佬
gcc 在連結相關so或者a檔案時出現 undefined reference to "xxx"
gcc 在連結相關so或者a檔案時出現 undefined reference to "xxx", 首先確認是否有這個xxx介面的真身,然後查明其所在的庫檔案,之後在當前makefile裡新增就行。 可是今天遇到一種特殊情況,在如下的libs後面直接新增libapps_vram.a檔案時
C++順序表應用3:元素位置互換之移位演算法(好好看著函式名!!)要不然就會 undefined reference to `build_table(Table&, int, int)'
順序表應用3:元素位置互換之移位演算法 Time Limit: 1000 ms Memory Limit: 570 KiB Problem Description 一個長度為len(1<=len<=1000000)的順序表,資料元素的型別為整型,將該表分
gcc "undefined reference to" 問題解決方法(使用庫)
最近在Linux下程式設計發現一個詭異的現象,就是在連結一個靜態庫的時候總是報錯,類似下面這樣的錯誤: (.text+0x13): undefined reference to `func'