f******e 发帖数: 582 | 1 I have one C program project1.c. When I compile it, I got the following
errors:
================
In function `main':
project1.c:(.text+0xa7): undefined reference to `parseName'
collect2: ld returned 1 exit status
================
I have checked, function parseName() is defined in project1.c What is the
problem here?
Thanks a lot. |
D*******a 发帖数: 3688 | 2 namespace?
【在 f******e 的大作中提到】 : I have one C program project1.c. When I compile it, I got the following : errors: : ================ : In function `main': : project1.c:(.text+0xa7): undefined reference to `parseName' : collect2: ld returned 1 exit status : ================ : I have checked, function parseName() is defined in project1.c What is the : problem here? : Thanks a lot.
|
r****t 发帖数: 10904 | 3 (or parseName function defined is not viable) scratch this. most likely parseName is not defined, though OP claimed it is.
【在 D*******a 的大作中提到】 : namespace?
|
b******n 发帖数: 592 | 4 in C?
【在 D*******a 的大作中提到】 : namespace?
|
p*********t 发帖数: 2690 | 5 好歹给个程序出来吧.
【在 f******e 的大作中提到】 : I have one C program project1.c. When I compile it, I got the following : errors: : ================ : In function `main': : project1.c:(.text+0xa7): undefined reference to `parseName' : collect2: ld returned 1 exit status : ================ : I have checked, function parseName() is defined in project1.c What is the : problem here? : Thanks a lot.
|
j*****k 发帖数: 1198 | 6 Need declare the function before define it. |
f********n 发帖数: 1163 | |
r*********r 发帖数: 3195 | 8 if u cann't even understand this error message, better put all ur code in
one file. |
c*********s 发帖数: 85 | 9 in c/c++, you need to declare the function before you define it as jobseek
said. More precisely, declare or define the function before you use it. In
other words, add one line to the top of the file or move the parseName
function up toward the top of the file.
...
void parseName();
or
void parseName()
{
// guts of the function
}
...
void main()
{
parseName();
} |
h**i 发帖数: 712 | 10 定义parseName的文件应该包括在Makefile
你这显然是连接错误。
【在 f******e 的大作中提到】 : I have one C program project1.c. When I compile it, I got the following : errors: : ================ : In function `main': : project1.c:(.text+0xa7): undefined reference to `parseName' : collect2: ld returned 1 exit status : ================ : I have checked, function parseName() is defined in project1.c What is the : problem here? : Thanks a lot.
|
m*********t 发帖数: 527 | 11 看到 ld 错误的还建议声明函数在顶部的都回去重练。要是没声明直接就是编译错误了。确实有可能是 make file 的问题。楼主没有给出怎么编译,多少个源代码文件什么的基本帮不了他。。。 |
a9 发帖数: 21638 | 12 同意,不过貌似楼主就一个c文件。
了。确实有可能是 make file 的问题。楼主没有给出怎么编译,多少个源代码文件什
么的基本帮不了他。。。
【在 m*********t 的大作中提到】 : 看到 ld 错误的还建议声明函数在顶部的都回去重练。要是没声明直接就是编译错误了。确实有可能是 make file 的问题。楼主没有给出怎么编译,多少个源代码文件什么的基本帮不了他。。。
|