C++ debug 报错问题 fatal error LNK1120

hansiman 2009-09-24 09:18:13
高手帮忙看看:
test_f.h 文件

#ifndef _H_H
#define _H_H

extern int k;//k为偏移量数组中的计数变量
extern int in_tab[9999]={0};
extern float coef_tab[9999]={0};
extern float out_tab[9999]={0};
extern int io[256];
extern int co[256];
extern int oo[256];

extern void init_alg(char *p_buf);
extern int two_one(char a,char b);


extern struct rbn
{
int blk_num;//block number
int fun_num;//function code number
int MFP;//MFP number
int seq_blk;// initial sequence
int in_num;//input number
int coef_num;// coeffcient number
int out_num;// output number
int *in_offet;//input offset
float *coef_offet;//coeffcient offset
float *out_offet;//output offset
int *in;
float *coef;
float *out;
float dt;//compute periods

}init_rbn[10000];

#endif

test_f.cpp文件
#include <stdlib.h>
#include <stdio.h>
#include "test_f.h"
#include "math.h"
#include <iostream.h>

int two_one(char a,char b)
{
int blk_n;
blk_n = ((unsigned char)a <<8)|(unsigned char)b;
return(blk_n);
}

int io[256]={0,1,0,2,2,1,1,1,2,3,4,
4,1,3,4,2,2,2,3,4,3,
6,6,6,1,0,0
};
int co[256]={0,12,1,2,4,2,2,1,2,2,0,
0, 2,0,0,2,1,1,7,8,1,
10,10,10,2,2,3
};
int oo[256]={0,1,1,1,2,1,1,1,1,1,1,
1,2,1,1,1,1,1,1,1,1,
6,6,6,1,1
};




void init_alg(char *p_buf)
{


init_rbn[0].in_offet=&in_tab[0];
init_rbn[0].coef_offet=&coef_tab[0];
init_rbn[0].out_offet=&out_tab[0];
init_rbn[k].blk_num=two_one(p_buf[28],p_buf[29]);

}

int main()
{
int *p=&in_tab[0];
printf("*p=\n",*p);

return 0;
}


Configuration: test_f - Win32 Debug--------------------
Compiling...
test_f.cpp
Linking...
test_f.obj : error LNK2001: unresolved external symbol "int k" (?k@@3HA)
test_f.obj : error LNK2001: unresolved external symbol "struct rbn * init_rbn" (?init_rbn@@3PAUrbn@@A)
Debug/test_f.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

test_f.exe - 3 error(s), 0 warning(s)


在线等
...全文
138 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
mgr645 2009-09-24
  • 打赏
  • 举报
回复
同意楼上的,声明之后需要在.cpp中定义 ,不然不能使用的
zgjxwl 2009-09-24
  • 打赏
  • 举报
回复
cpp里加上

int k;//k为偏移量数组中的计数变量 
struct rbn init_rbn[10000];


extern只是它在其他地方定义。。。。没定义怎么能使用呢
v2002750 2009-09-24
  • 打赏
  • 举报
回复
学习一下“声明”和“定义”
brookmill 2009-09-24
  • 打赏
  • 举报
回复
删掉若干extern之后能编译通过,不过不知道这是不是符合楼主的需求
brookmill 2009-09-24
  • 打赏
  • 举报
回复
编译器认为init_rbn没有定义,因为头文件里的是一个extern声明

64,649

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧