我想在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