我想在linux中編譯一個簡單的應用程序。我的main.cpp看起來像在Linux中編譯C++
#include <string>
#include <iostream>
#include "Database.h"
using namespace std;
int main()
{
Database * db = new Database();
commandLineInterface(*db);
return 0;
}
其中Database.h是我的頭並有一個相應的Database.cpp。編譯時出現以下錯誤:
[email protected]:~/code$ g++ -std=c++0x main.cpp -o test
/tmp/ccf1PF28.o: In function `commandLineInterface(Database&)':
main.cpp:(.text+0x187): undefined reference to `Database::transducer(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
main.cpp:(.text+0x492): undefined reference to `Database::transducer(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
main.cpp:(.text+0x50c): undefined reference to `Database::transducer(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/tmp/ccf1PF28.o: In function `main':
main.cpp:(.text+0x721): undefined reference to `Database::Database()'
collect2: ld returned 1 exit status
搜索類似這樣的東西遍佈整個地方,你可以想象得到。對於我可以做些什麼來解決問題有什麼建議?
我想我們需要看看Database。(h | cpp)文件,或者至少是'Database'類和'commandLineInterface'接口/實現。 – 2011-04-21 15:05:21