【发布时间】:2010-05-25 20:08:08
【问题描述】:
我在编译我编写的程序时遇到问题。我有两个包含相同包含的不同文件,但只有一个在使用 g++ 编译时会生成以下错误
/usr/lib/gcc/x86_64-linux-gnu/4.4.1/../../../../lib/crt1.o: In function `_start':
/build/buildd/eglibc-2.10.1/csu/../sysdeps/x86_64/elf/start.S:109: undefined reference to `main'
collect2: ld returned 1 exit status
我在标题中包含的文件如下:
#include <google/sparse_hash_map>
using google::sparse_hash_map;
#include <ext/hash_map>
#include <math.h>
#include <iostream>
#include <queue>
#include <vector>
#include <stack>
using std::priority_queue;
using std::stack;
using std::vector;
using __gnu_cxx::hash_map;
using __gnu_cxx::hash;
using namespace std;
在互联网上搜索这两条线并没有对我有任何帮助。我将非常感谢任何建议。谢谢
【问题讨论】:
-
您能否给我们完整的源代码,或者至少在文件中 main() 之前的几行编译失败?
-
大家好,感谢您的提示。我听从了你的一些建议,并意识到我不明白我编程方式对 main 的需求。以为我可以编译为一个函数。看来我还有很多东西要学。
标签: c++ linker compiler-errors