2017-05-09 94 views
0

我想https://github.com/Rventric/Text-Detection但如果我運行此命令:如何解決我項目中的「未定義函數引用」錯誤?

g++ -o DEMO Demo.cpp `pkg-config opencv --cflags --libs` 

我得到這個錯誤:

/tmp/ccTKjiBu.o: In function `main': 
Demo.cpp:(.text+0x159): undefined reference to `TextDetection::detectText(cv::Mat const&, std::vector<std::string, std::allocator<std::string> >, bool)' 
/tmp/ccTKjiBu.o: In function `LinkCandidate::LinkCandidate()': 
Demo.cpp:(.text._ZN13LinkCandidateC2Ev[_ZN13LinkCandidateC5Ev]+0x4c): undefined reference to `Iqueue::Iqueue()' 
/tmp/ccTKjiBu.o: In function `GetCandidate::GetCandidate()': 
Demo.cpp:(.text._ZN12GetCandidateC2Ev[_ZN12GetCandidateC5Ev]+0x77): undefined reference to `Swt::Swt()' 
/tmp/ccTKjiBu.o: In function `VericaficationTextLine::VericaficationTextLine()': 
Demo.cpp:(.text._ZN22VericaficationTextLineC2Ev[_ZN22VericaficationTextLineC5Ev]+0x25): undefined reference to `FilterBox::FilterBox()' 
collect2: error: ld returned 1 exit status 

誰給解決這個問題?

+0

通過定義鏈接程序無法找到的函數來解決問題。基於你的g ++命令行,你忘了'-o'的參數,這意味着你的'TextDetection.cpp'文件沒有被編譯 - 並且可能已經被破壞了。 – cdhowie

+0

@cdhowie如何做到這一點? 給我的命令請 –

回答

3

哎呀,你正試圖創建一個名爲TextDirection.cpp的可執行文件。您沒有指定一個輸出文件名與-o標誌一起使用。如果你想創建一個名爲demo可執行文件,那麼你需要

g++ -o demo TextDetection.cpp Demo.cpp `pkg-config opencv --cflags --libs` 

此外,您可能需要恢復原來的源文件TextDirection.cpp,因爲你可能無意中破壞它。

+0

同樣的問題,我改變了命令To:g ++ -o Demo.cpp'pkg-config opencv --cflags --libs' –

+0

你有沒有檢查'TextDirection.cpp'還包含你期望它包含的代碼? – paddy

相關問題