multiple definition ; first defined here
2012-05-31 14:12
429 查看
main.o(.data+0x0): multiple definition of `rect'
renlianjiance.o(.data+0x0): first defined here
main.o(.data+0x880): multiple definition of `LBP_tree'
renlianjiance.o(.data+0x880): first defined here
main.o(.data+0x2080): multiple definition of `LBP'
renlianjiance.o(.data+0x2080): first defined here
main.o(.data+0x2120): multiple definition of `std_g_jh'
renlianjiance.o(.data+0x2120): first defined here
collect2: ld returned 1 exit status
make: *** [renlianjiance] Error 1
这是我做人脸检测时候的一个错误。该错误的原因是在头文件中定义了数组或者数据结构并且初始化。
#ifndef STRUCT_TREE
#define STRUCT_TREE
struct tree
{
int rect_number;
signed int feature[8];
float leafvalue[2];
}struct tree
LBP_tree[139]={};//没有将定义和初始化分来
#endif
尽管使用了#ifndef #define *****#endif 语句来避免重复包含,这在编译的时候可以通过,但是在链接的时候就会产生上述错误。初始化后分配了空间,会使得所有引用了相同头文件的文件都包含了初始化的数据。
以下是我的更改:
#ifndef STRUCT_TREE
#define STRUCT_TREE
struct tree
{
int rect_number;
signed int feature[8];
float leafvalue[2];
};
#endif
struct tree LBP_tree[139]={};//将定义和初始化分来
然后再使用到struct tree的文件里面使用
#ifndef STRUCT_TREE
#define STRUCT_TREE
struct tree
{
int rect_number;
signed int feature[8];
float leafvalue[2];
};
#endif
这样就可以了,避免了重复定义,重复分配空间。其他的错误一次解决。
renlianjiance.o(.data+0x0): first defined here
main.o(.data+0x880): multiple definition of `LBP_tree'
renlianjiance.o(.data+0x880): first defined here
main.o(.data+0x2080): multiple definition of `LBP'
renlianjiance.o(.data+0x2080): first defined here
main.o(.data+0x2120): multiple definition of `std_g_jh'
renlianjiance.o(.data+0x2120): first defined here
collect2: ld returned 1 exit status
make: *** [renlianjiance] Error 1
这是我做人脸检测时候的一个错误。该错误的原因是在头文件中定义了数组或者数据结构并且初始化。
#ifndef STRUCT_TREE
#define STRUCT_TREE
struct tree
{
int rect_number;
signed int feature[8];
float leafvalue[2];
}struct tree
LBP_tree[139]={};//没有将定义和初始化分来
#endif
尽管使用了#ifndef #define *****#endif 语句来避免重复包含,这在编译的时候可以通过,但是在链接的时候就会产生上述错误。初始化后分配了空间,会使得所有引用了相同头文件的文件都包含了初始化的数据。
以下是我的更改:
#ifndef STRUCT_TREE
#define STRUCT_TREE
struct tree
{
int rect_number;
signed int feature[8];
float leafvalue[2];
};
#endif
struct tree LBP_tree[139]={};//将定义和初始化分来
然后再使用到struct tree的文件里面使用
#ifndef STRUCT_TREE
#define STRUCT_TREE
struct tree
{
int rect_number;
signed int feature[8];
float leafvalue[2];
};
#endif
这样就可以了,避免了重复定义,重复分配空间。其他的错误一次解决。
相关文章推荐
- C++ "multiple definition of .. first defined here 错误的修改
- C++的multiple definition of *** first defined here错误
- multiple definition of `main' /(text+0x0): first defined here
- C++ "multiple definition of .. first defined here" 错误的修改
- C++ "multiple definition of .. first defined here"
- C++ 解决 multiple definition of & previous definition here编译错误
- sqlite3fun.c:155: first defined here execSqlite3 closeSqlite3 getSqlite3dbName编译不通过
- freetextbox 只能显示两张图片 user defined custom images (here, we're just allowing the first two)
- //mark theFirstBlogHere
- JPA Multiple writable mappings exist for the field [{0}]. Only one may be defined as writable, all o
- Qt报Multiple definition错误的解决
- Segment FRAM_DATA must be defined in a segment definition option (-Z, -b or -P)
- gcc: multiple definition of [转]
- CC2530编译出现 Fatal Error[e72]: Segment BANKED_CODE must be defined in a segment definition option (-Z,
- stampede上编译c和fortran混编程序multiple definition of `main'问题解决
- a missing vtable usually means the first non-inline virtual member function has no definition.
- multiple definition of XXX情况分析
- gcc交叉编译错误:multiple definition of_时间流_百度空间
- 解决 multiple definition of
- MySQL错误:Incorrect table definition;there can be only one auto column and it must be defined as a key