【发布时间】:2011-04-21 15:02:01
【问题描述】:
我正在尝试在 linux 中编译一个简单的应用程序。我的 main.cpp 看起来像
#include <string>
#include <iostream>
#include "Database.h"
using namespace std;
int main()
{
Database * db = new Database();
commandLineInterface(*db);
return 0;
}
Database.h 是我的头文件并且有一个对应的 Database.cpp。编译时出现以下错误:
me@ubuntu:~/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接口/实现。
标签: c++ linux compiler-errors compilation