就剩一个错误了 帮帮忙啊

wwankof 2008-11-18 03:10:40
//Global.h
#include <stdio.h>
#include <iostream.h>
#include <math.h>
#include <stdlib.h>
#include <iomanip.h>
#include <time.h>
#include <malloc.h>
#include <string.h>
#include <fstream.h>


#include "defines.h"


struct NODE{
double x;
double y;
double z;
double rho;
double P;
double u;
double v;
double w;
double f[Q];
double F[Q];

};
extern NODE ****node;
extern int NBLOCK;
extern int **BLOCK;



void Grid_Read();
void Grid_DataDeal();


//Grid Read.cpp
#include "Global.h"
int NBLOCK;
int **BLOCK;
NODE ****node;
void Grid_read()
{
int i=0,j=0,k=0,l=0;

FILE *fp;
if ( (fp = fopen( "Grid/airfoil.grd", "r" )) == NULL )
printf("ERROR on open Grid!\n");

fscanf( fp, "%d",&NBLOCK);

BLOCK = new int*[NBLOCK];
for(i = 0; i < NBLOCK; i++)
{
BLOCK[i] = new int[3];
}
for(i=0;i <NBLOCK;i++)
for(j=0;j <3;j++)
{
fscanf( fp, "%d",&BLOCK[i][j]);
}

node = new NODE ***[NBLOCK];
for( i=0;i <NBLOCK;i++)
{
node[i]= new NODE**[BLOCK[i][0]];
for(j=0;j <BLOCK[i][0];j++)
{
node[i][j]=new NODE*[BLOCK[i][1]];
for(k=0;k <BLOCK[i][j];k++)
{
node[i][j][k]=new NODE[BLOCK[i][2]];
}
}
}


for(i=0;i <NBLOCK;i++)
{
for(l=0;l <BLOCK[i][2];l++)
for(k=0;k <BLOCK[i][1];k++)
for(j=0;j <BLOCK[i][0];j++)
fscanf( fp, "%lf",&node[i][j][k][l].x);
for(l=0;l <BLOCK[i][2];l++)
for(k=0;k <BLOCK[i][1];k++)
for(j=0;j <BLOCK[i][0];j++)
fscanf( fp, "%lf",&node[i][j][k][l].y);
for(l=0;l <BLOCK[i][2];l++)
for(k=0;k <BLOCK[i][1];k++)
for(j=0;j <BLOCK[i][0];j++)
fscanf( fp, "%lf",&node[i][j][k][l].z);
}
fclose(fp);

cout < <"Read Grid successfully!!!" < <endl;
}


//Grid deal.cpp
#include "Global.h"

void Grid_DataDeal()
{


int i,j,k,l;
FILE *outfp;
char temp[500];
sprintf(temp,"Grid.dat");
outfp=fopen("output/temp","w");
fprintf(outfp,"%d\n",NBLOCK);
for(i=0;i <NBLOCK;i++)
fprintf(outfp,"%d\t%d\t%d\n",BLOCK[i][0],BLOCK[i][1],BLOCK[i][2]);
for(i=0;i <NBLOCK;i++)
{
for(l=0;l <BLOCK[i][2];l++)
for(k=0;k <BLOCK[i][1];k++)
for(j=0;j <BLOCK[i][0];j++)
fprintf( outfp, "%lf",&node[i][j][k][l].x);
for(l=0;l <BLOCK[i][2];l++)
for(k=0;k <BLOCK[i][1];k++)
for(j=0;j <BLOCK[i][0];j++)
fprintf( outfp, "%lf",&node[i][j][k][l].y);
for(l=0;l <BLOCK[i][2];l++)
for(k=0;k <BLOCK[i][1];k++)
for(j=0;j <BLOCK[i][0];j++)
fprintf( outfp, "%lf",&node[i][j][k][l].z);
}
fclose(outfp);
cout < <"Datadeal Grid successfully!" < <endl;
}


//main.cpp
#include "Global.h"

void main()
{

Grid_Read();
Grid_DataDeal();
}


编译时 出现如下错误
Linking...
main.obj : error LNK2001: unresolved external symbol "void __cdecl Grid_Read(void)" (?Grid_Read@@YAXXZ)
Debug/ISLBM.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.

...全文
109 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
cyj626 2008-11-18
  • 打赏
  • 举报
回复
4 楼细心
cyj626 2008-11-18
  • 打赏
  • 举报
回复
楼上的为什么一定非要加extern "C" {} 定义,C++应该可以直接包含的啊。
难道是编译器的不同??
liumingrong 2008-11-18
  • 打赏
  • 举报
回复
定义时写错了
void Grid_read() ;
改成void Grid_Read() 应该就ok了
xkyx_cn 2008-11-18
  • 打赏
  • 举报
回复
Global.h 改一下:

//Global.h
#include <stdio.h>
#include <iostream.h>
#include <math.h>
#include <stdlib.h>
#include <iomanip.h>
#include <time.h>
#include <malloc.h>
#include <string.h>
#include <fstream.h>


#include "defines.h"


struct NODE{
double x;
double y;
double z;
double rho;
double P;
double u;
double v;
double w;
double f[Q];
double F[Q];

};
extern NODE ****node;
extern int NBLOCK;
extern int **BLOCK;

#ifdef __cplusplus
extern "C" {
#end if

void Grid_Read();
void Grid_DataDeal();

#ifdef __cplusplus
}
#end if
xhs_lh04 2008-11-18
  • 打赏
  • 举报
回复
有没把三个文件都加到项目里
  • 打赏
  • 举报
回复
extern "C"
{
void Grid_Read();
void Grid_DataDeal();
}
试试

65,211

社区成员

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

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