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();
#endif // TEST_H_INCLUDED
test.c
#include "test.h"
void test()
{
}
在main.cpp檔案中應用test函式,引用test.h標頭檔案,顯示
/home/stu01/JOB/pick/main.cpp|281|undefined reference to `test()'|
不知道為啥?
這個test.h test.c的檔案位置放到src和main.cpp同一目錄都提示錯誤。
我的專案中用到了類似的應用,不過哪個是c++是類。不是函式,想想,更改下試試?
將test.c修改為test.cpp,重新編譯,ok沒錯了。不知道這是為啥?
記下來為遇到這個問題的兄弟指點迷津!
不過CentOS 7比我以前使用linux印象頗佳,基本不宕機了!但是必須剛開始裝系統的時候最佳選擇Server With GUI剩下啥也不裝,進入系統後再安裝。
否則還是宕機是主旋律!同樣也不知道為啥?呵呵!
相關推薦
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++] cmake 編譯時 undefined reference to `std::cout' 錯誤的解決方案
bin cut () cmake fin epo linking com urn cmake .. 和 make 之後,出現如下錯誤 Linking CXX executable ../../../bin/ModuleTest CMakeFiles/Modu
c++ template 多層繼承下找不到純虛擬函式實現 報錯:undefined reference to "xxx"
如下程式碼中,定義了3個類,ClassA,ClassB,ClassC,依次為被繼承關係,ClassA,ClassB是模板類, 在ClassA中定義了一個純虛擬函式getKeyFromObject,實現將從V中獲取K的功能: getKeyFromObject函
Eclipse c++ 中[Linker error] undefined reference to `
json-c 交叉編譯(undefined reference to rpl_malloc )
(如果有幫助,請點個贊;如果有錯誤,請指出;如果轉載,請註明出處)
關鍵詞:
(1)json-c
(2)mips、openwrt
(3)Relocations in generic ELF
正文
linux 連結庫檔案出現“undefined reference to" 問題的解決方法
最近在Linux下程式設計發現一個詭異的現象,就是在連結一個靜態庫的時候總是報錯,類似下面這樣的錯誤: (.text+0x13): undefined reference to `func' 關於undefined reference這樣的問題,大家其實經常會遇
呵呵噠,又是undefined reference to xxx
不搞C/C++,已經很久,但遇到問題, 還是要解決: [email protected]:~/taoge/zmq/test$ g++ -g -Wall -fPIC -I/hom
一個難解的undefined reference to xxx 讓我決定永遠告別json庫, 轉而用開源的RapidJson
最近, 需要用json庫來解析一個json串, 這是多麼簡單的事情啊, 而且我以前經常這麼幹。 可是, 我卻遇到了undefined reference to xxx這樣一個問題。 這個, 我已經很熟悉了, 肯定是沒有包含對應的json靜態庫
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選項即
linux下生產者與消費者問題程式碼,以及編譯c程式碼時error:undefined reference to sem_wait 解決方法之一
//本文的詳細講解內容請大家下載word文件:http://download.csdn.net/detail/chenqiai0/4611801 #include <stdio.h> #include <pthread.h>//執行緒 #includ
linux下開發,解決cocos2d-x中編譯出現的一個小問題, undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
water span x86 code bject data- ace 技術分享 inux 解決cocos2d-x中編譯出現的一個小問題 對於cocos2d-x 2.×中編譯中,若頭文件裏引入了#include "cocos-ext.h",在進行C++編譯的時候會遇到例
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沒有報錯,但是
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:
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)的順序表,資料元素的型別為整型,將該表分
關於移植jSON編譯時報錯sbrkr.c:(.text+0xc): undefined reference to `_sbrk'處理
最近有個專案需要用到jSON函式,在移植了jSON後編譯報錯如下:sbrkr.c:(.text+0xc): undefined reference to `_sbrk'。 通過百度查詢知道原來是GCC編譯器不支援malloc、free、memcpy、strlen等函式導致的,正常在嵌入式系統
gcc xx.c:(.text+0x11): undefined reference to `sqrt'
gcc prime.c -o prime報錯 undefined reference to `sqrt’ 由於程式碼中使用了math庫中的sqrt方法, 所以要這樣寫 gcc prime
C與C++混合程式設計問題:.C++呼叫.C檔案時出現:undefined reference to `xxxxx()'
本人使用qt的介面和opengl功能模擬演算法,該演算法需要在嵌入式中執行,因此需要用純C編寫,此時涉及到在C++寫的qt介面檔案中呼叫C檔案的庫函式,原先以為只需在C++中把C的.h檔案包含進去就可以正常使用,後來發現,使用這種方法時,在程式碼編寫時,C++檔案裡可以直接連
C 語言 undefined reference to 'sqrt' 問題解決
題目:一個整數,它加上100後是一個完全平方數,再加上168又是一個完全平方數,請問該數是多少? 1.程式分析:在10萬以內判斷,先將該數加上100後再開方,再將該數加上268後再開方,如果開方後 的結果滿足如下條件,即是結果。請看具體分析: 2.程式原始碼