[错误]文件中未定义的第一个引用符号 [英] [Error] Undefined first referenced symbol in file

查看:285
本文介绍了[错误]文件中未定义的第一个引用符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个cpp,其中我正在使用来自hpp的2个类并定义了在hpp中声明的函数.但是,当我编译时出现错误:


g ++ file.cpp
未定义的第一个引用
文件中的符号
主/auto/gnu/gcc/4.2.1/bin/../lib/gcc/sparc-sun-solaris2.10/4.2.1/crt1.o
ld:致命:符号引用错误.没有输出写入a.out
collect2:ld返回1退出状态

I have a cpp in which i am using 2 classes from a hpp and defining the functions declared in the hpp. However when i compile the error comes :


g++ file.cpp
Undefined first referenced
symbol in file
main /auto/gnu/gcc/4.2.1/bin/../lib/gcc/sparc-sun-solaris2.10/4.2.1/crt1.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status

推荐答案

模块my570list.cpp似乎不包含根据CPP源代码创建可执行文件所需的main()函数.如果您只是尝试编译为对象形式,则将-c选项添加到您的编译命令中,这样:
It would appear that module my570list.cpp does not contain a main() function as required for creating an executable from CPP source code. If you are merely trying to compile into object form then add the -c option to your compile command thus:
g++ -c my570list.cpp


这篇关于[错误]文件中未定义的第一个引用符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆