codeblocks中出现undefined reference

问题描述:

在main.cpp中调用了一个函数,这个函数申明在func.h中,实现在func.cpp中,但是编译后显示undefined reference  func类似的问题

原因:

VC++中是没有这个错误的,因为VC++自动把目标文件链接到一起了,而 Codeblocks中并没有这么做。回想起自己当时添加该func文件的时候,有那个add file to active project in build targets,我虽然在上面打了对勾,但是在下面的选项中并没有选择。

解决:

只要把所有文件添加到Build target中就可以了

选中当前项目,工具栏--->Project--->Properties--->Build targets--->Debug--->Build target files

将所有文件选中,就可以正常编译了

 

参考:http://blog.csdn.net/lisong396/article/details/9256645

 

posted @ 2016-03-15 09:36  VIPWTL  阅读(795)  评论(0编辑  收藏  举报