在我的Eclipse C / C ++项目中,这个undefined reference
错误不会消失,无论我做什么都不会出错。我已经更改了链接顺序,检查了是否编译并包含了所有文件(基本上是所有文件),这在Internet中在遇到此问题时建议使用。
这是我的程序:
[...]-表示还有更多与此无关的代码。
menulib.h
[...]
void start_GUI( void );
[...]
start_GUI.c -注意,这是一个.c
-文件
#include "menulib.h"
void start_GUI( void )
{
[...]
}
coreInterface.h
#ifndef COREINTERFACE_H_
#define COREINTERFACE_H_
#include <stdint.h>
#include <stdlib.h>
#ifdef __cplusplus
/** only include the Core when compiled for C++ */
#include "Core.h"
#endif /* #ifdef CORE */
#ifdef __cplusplus
extern "C" {
#endif
void init_GUI( Core* core);
#ifdef __cplusplus
}
#endif
#endif /* COREINTERFACE_H_ */
coreInterface.cpp -注意,这是一个.cpp
-文件
#include "coreInterface.h"
#include "menulib.h"
void init_GUI( Core* core)
{
gui_core = core;
start_GUI(); // <--- **error appears here** - calls a .c file
}
这是makefile(从Eclipse自动生成的文件)中的错误:
g++ -L/home/PC/the_Project/menu_GUI -o "the_Project" [...] ./menu_GUI/coreInterface.o [...] ./menu_GUI/start_GUI.o [...] -lcurses
./menu_GUI/coreInterface.o: In function `init_GUI':
/home/PC/the_Project/Default/../menu_GUI/coreInterface.cpp:23: undefined reference to `start_GUI()'
我相信这是来自合并.c
和.cpp
文件。仍然我无法解决。有人知道吗?
亲切的问候
工作示例:
#include "coreInterface.h"
extern "C" {
#include "menulib.h"
}
void init_GUI( Core* core)
{
gui_core = core;
start_GUI();
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句