•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 456,562 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,507 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 926 | Replies: 10
![]() |
•
•
Join Date: Oct 2007
Posts: 13
Reputation:
Rep Power: 2
Solved Threads: 0
Hi People
I'm a newbie in c, I learn in c++, but I don`t really know to much. A friend make a code in c, working in a linux pc. And works perfect.
I normally work in Micorsoft Visual Studio, but this c code, seems not to work well (88 errors). So I start using DevCpp and looks that the c code runs, but there still are too much errors (31). Why the different compilers show different number of errors. The code employ a lot of gsl libraries (GNU Scientific Library).
You have any idea what ould be happening.
Thanx in advance for your time
Paulville
This are the kind of error that appears
In function `web_calc':
92: parse error before `double'
96: `y' undeclared (first use in this function)
96: (Each undeclared identifier is reported only once
96: for each function it appears in.)
100: parse error before `)'
103: `params' undeclared (first use in this function)
115: parse error before `const'
126: `t' undeclared (first use in this function)
135: `tend' undeclared (first use in this function)
146: parse error before `int'
147: `status' undeclared (first use in this function)
187: `s' undeclared (first use in this function)
188: `c' undeclared (first use in this function)
189: `e' undeclared (first use in this function)
In function `dynamics':
227: parse error before `ydot_vec'
245: `EAgsl' undeclared (first use in this function)
245: `yjgsl' undeclared (first use in this function)
245: `tvec' undeclared (first use in this function)
247: `Hmat' undeclared (first use in this function)
251: `Gmat' undeclared (first use in this function)
262: `Tmat' undeclared (first use in this function)
268: parse error before `*'
273: `Bp' undeclared (first use in this function)
277: `ratio' undeclared (first use in this function)
282: `death' undeclared (first use in this function)
291: `ydotgsl' undeclared (first use in this function)
295: parse error before `double'
311: `growth' undeclared (first use in this function)
312: `index1' undeclared (first use in this function)
313: `index2' undeclared (first use in this function)
315: `oldtemp' undeclared (first use in this function)
I'm a newbie in c, I learn in c++, but I don`t really know to much. A friend make a code in c, working in a linux pc. And works perfect.
I normally work in Micorsoft Visual Studio, but this c code, seems not to work well (88 errors). So I start using DevCpp and looks that the c code runs, but there still are too much errors (31). Why the different compilers show different number of errors. The code employ a lot of gsl libraries (GNU Scientific Library).
You have any idea what ould be happening.
Thanx in advance for your time
Paulville
This are the kind of error that appears
In function `web_calc':
92: parse error before `double'
96: `y' undeclared (first use in this function)
96: (Each undeclared identifier is reported only once
96: for each function it appears in.)
100: parse error before `)'
103: `params' undeclared (first use in this function)
115: parse error before `const'
126: `t' undeclared (first use in this function)
135: `tend' undeclared (first use in this function)
146: parse error before `int'
147: `status' undeclared (first use in this function)
187: `s' undeclared (first use in this function)
188: `c' undeclared (first use in this function)
189: `e' undeclared (first use in this function)
In function `dynamics':
227: parse error before `ydot_vec'
245: `EAgsl' undeclared (first use in this function)
245: `yjgsl' undeclared (first use in this function)
245: `tvec' undeclared (first use in this function)
247: `Hmat' undeclared (first use in this function)
251: `Gmat' undeclared (first use in this function)
262: `Tmat' undeclared (first use in this function)
268: parse error before `*'
273: `Bp' undeclared (first use in this function)
277: `ratio' undeclared (first use in this function)
282: `death' undeclared (first use in this function)
291: `ydotgsl' undeclared (first use in this function)
295: parse error before `double'
311: `growth' undeclared (first use in this function)
312: `index1' undeclared (first use in this function)
313: `index2' undeclared (first use in this function)
315: `oldtemp' undeclared (first use in this function)
Last edited by Paulville : Oct 20th, 2007 at 11:51 am. Reason: include error, so help understand my problem
•
•
Join Date: Oct 2007
Posts: 13
Reputation:
Rep Power: 2
Solved Threads: 0
Ok Salem I'll do it. I will edit it, but like the line with errors appear in here, I don't change it.
#include <stdio.h>
#include <math.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_rng.h> // random number generator
#include <gsl/gsl_odeiv.h> // ODE-solving procedures
#include <gsl/gsl_errno.h> // errorhandler
#include <gsl/gsl_blas.h> // linear algebra with vecors and matrices
// global variables:
double alpha=0.1; // mortality rate
double beta=1; // interspecific concurrence
double lambda=0.5; // biologic efficiency
double K1=1; // carrying capacity of resources
double aleph=1; // half saturation density (scaling parameter for volumes)
double beth=1; // handling time
double delta1=20; // growth rate of resources
double z=0.5; // ration of sizes between two size classes
double Imax=10; // maximum ingestion rate
double T=1; // metabolic requirements (maintenace costs)
int GC=0;
double *web_calc(int S, int B, const gsl_rng_type *T, gsl_rng *r, FILE *populdata, FILE *inputdata);
int dynamics(double t, const double y[], double ydot[], void *params);
int Delta(int i, int j);
int Theta(double g);
//*******************************************************************
// Main Part
//*******************************************************************
int main(void)
{
FILE *populdata; // Hier werden die Populationen reingeschrieben
FILE *inputdata; // File with input parameters/ abundances
int B=1; // Anzahl der unabhaengigen externen Ressourcen
int S=4; // Anzahl der Spezies im Netz (ohne Ressourcen)
const gsl_rng_type *T; // ****
gsl_rng *r; // Initialisierung des Zufallszahlengenerators
gsl_rng_env_setup(); // ****
T=gsl_rng_default; // default random number generator (so called mt19937)
gsl_rng_default_seed=4395; // Startwert fuer den RNG
r=gsl_rng_alloc(T);
populdata=fopen("ssp-N.out","w");
inputdata=fopen("data.input","r");
web_calc(S,B,T,r,populdata,inputdata);
fclose(populdata);
fclose(inputdata);
gsl_rng_free(r);
return(0);
}
//****************************************************************************
// Produce network structure and calculate the population sizes
//****************************************************************************
double *web_calc(int S, int B, const gsl_rng_type *T, gsl_rng *r, FILE *populdata, FILE *inputdata)
{
int i,j,k;
int L=2,flag,xflag; // Kontrollvariablen
double *test=(double *)calloc(2*B+2*(S+L),sizeof(double));
gsl_matrix *Ap=gsl_matrix_calloc (B+S,B+S);
gsl_matrix *A=gsl_matrix_calloc (B+S,B+S);
// determine feeding relationships
gsl_matrix_set(Ap,1,0,1);
gsl_matrix_set(Ap,2,0,1);
gsl_matrix_set(Ap,2,1,1);
gsl_matrix_set(Ap,3,0,1);
gsl_matrix_set(Ap,3,2,1);
gsl_matrix_set(Ap,4,0,1);
gsl_matrix_set(Ap,4,3,1);
gsl_matrix_set(A,1,0,1);
gsl_matrix_set(A,2,0,0.7);
gsl_matrix_set(A,2,1,0.3);
gsl_matrix_set(A,3,0,0.7);
gsl_matrix_set(A,3,2,0.3);
gsl_matrix_set(A,4,0,0.7);
gsl_matrix_set(A,4,3,0.3);
double *y = (double *) calloc(B+S,sizeof(double)); // populations
double *params=(double *) calloc(2+(B+S)*(B+S),sizeof(double));
for(i=0;i<=B-1;i++)
y[i]=1;
for(i=B;i<=B+S-1;i++)
// y[i]=gsl_rng_uniform_pos(r)*1/(double)S;
y[i]=1/(double)S);
// fscanf(inputdata,"%lf \n",&y[i]);
The code simulates a trophic network based on the size of the individuals. At the beggining we ceate some matrix that indicate who eats who, and there preference for each other.
#include <stdio.h>
#include <math.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_rng.h> // random number generator
#include <gsl/gsl_odeiv.h> // ODE-solving procedures
#include <gsl/gsl_errno.h> // errorhandler
#include <gsl/gsl_blas.h> // linear algebra with vecors and matrices
// global variables:
double alpha=0.1; // mortality rate
double beta=1; // interspecific concurrence
double lambda=0.5; // biologic efficiency
double K1=1; // carrying capacity of resources
double aleph=1; // half saturation density (scaling parameter for volumes)
double beth=1; // handling time
double delta1=20; // growth rate of resources
double z=0.5; // ration of sizes between two size classes
double Imax=10; // maximum ingestion rate
double T=1; // metabolic requirements (maintenace costs)
int GC=0;
double *web_calc(int S, int B, const gsl_rng_type *T, gsl_rng *r, FILE *populdata, FILE *inputdata);
int dynamics(double t, const double y[], double ydot[], void *params);
int Delta(int i, int j);
int Theta(double g);
//*******************************************************************
// Main Part
//*******************************************************************
int main(void)
{
FILE *populdata; // Hier werden die Populationen reingeschrieben
FILE *inputdata; // File with input parameters/ abundances
int B=1; // Anzahl der unabhaengigen externen Ressourcen
int S=4; // Anzahl der Spezies im Netz (ohne Ressourcen)
const gsl_rng_type *T; // ****
gsl_rng *r; // Initialisierung des Zufallszahlengenerators
gsl_rng_env_setup(); // ****
T=gsl_rng_default; // default random number generator (so called mt19937)
gsl_rng_default_seed=4395; // Startwert fuer den RNG
r=gsl_rng_alloc(T);
populdata=fopen("ssp-N.out","w");
inputdata=fopen("data.input","r");
web_calc(S,B,T,r,populdata,inputdata);
fclose(populdata);
fclose(inputdata);
gsl_rng_free(r);
return(0);
}
//****************************************************************************
// Produce network structure and calculate the population sizes
//****************************************************************************
double *web_calc(int S, int B, const gsl_rng_type *T, gsl_rng *r, FILE *populdata, FILE *inputdata)
{
int i,j,k;
int L=2,flag,xflag; // Kontrollvariablen
double *test=(double *)calloc(2*B+2*(S+L),sizeof(double));
gsl_matrix *Ap=gsl_matrix_calloc (B+S,B+S);
gsl_matrix *A=gsl_matrix_calloc (B+S,B+S);
// determine feeding relationships
gsl_matrix_set(Ap,1,0,1);
gsl_matrix_set(Ap,2,0,1);
gsl_matrix_set(Ap,2,1,1);
gsl_matrix_set(Ap,3,0,1);
gsl_matrix_set(Ap,3,2,1);
gsl_matrix_set(Ap,4,0,1);
gsl_matrix_set(Ap,4,3,1);
gsl_matrix_set(A,1,0,1);
gsl_matrix_set(A,2,0,0.7);
gsl_matrix_set(A,2,1,0.3);
gsl_matrix_set(A,3,0,0.7);
gsl_matrix_set(A,3,2,0.3);
gsl_matrix_set(A,4,0,0.7);
gsl_matrix_set(A,4,3,0.3);
double *y = (double *) calloc(B+S,sizeof(double)); // populations
double *params=(double *) calloc(2+(B+S)*(B+S),sizeof(double));
for(i=0;i<=B-1;i++)
y[i]=1;
for(i=B;i<=B+S-1;i++)
// y[i]=gsl_rng_uniform_pos(r)*1/(double)S;
y[i]=1/(double)S);
// fscanf(inputdata,"%lf \n",&y[i]);
The code simulates a trophic network based on the size of the individuals. At the beggining we ceate some matrix that indicate who eats who, and there preference for each other.
In function `web_calc': /* in the function web_calc you have the following errors */ 92: parse error before `double' 96: `y' undeclared (first use in this function) /* y is a variable not declared before use */ 96: (Each undeclared identifier is reported only once 96: for each function it appears in.) 100: parse error before `)' /* Probably error because the lack of variable y */ 103: `params' undeclared (first use in this function) /* variable params is not declared */ 115: parse error before `const' 126: `t' undeclared (first use in this function) /* var t is not declared before use */ 135: `tend' undeclared (first use in this function) /* var tend is not declared */ 146: parse error before `int' 147: `status' undeclared (first use in this function) /* var status is not declared */ 187: `s' undeclared (first use in this function) /* var s is not found before use */ 188: `c' undeclared (first use in this function) /* variable c is not declared */ 189: `e' undeclared (first use in this function) /* variable e is not declared */ In function `dynamics': /* in function dynamics you have the following errors */ 227: parse error before `ydot_vec' /* error due because of missing undeclared variables */ 245: `EAgsl' undeclared (first use in this function) /* EAgsl is not declared */ 245: `yjgsl' undeclared (first use in this function) /* yjgsl is missing */ 245: `tvec' undeclared (first use in this function) /* tvec is not declared */ 247: `Hmat' undeclared (first use in this function) /* Hmat is not declared */ 251: `Gmat' undeclared (first use in this function) /* Gmat is not declared */ 262: `Tmat' undeclared (first use in this function) /* Tmat is missing */ 268: parse error before `*' 273: `Bp' undeclared (first use in this function) /* Bp not found before using */ 277: `ratio' undeclared (first use in this function) /* ratio missing */ 282: `death' undeclared (first use in this function) /* death is not found. "I wish it were true" */ 291: `ydotgsl' undeclared (first use in this function) /* ydotgsl not there */ 295: parse error before `double' 311: `growth' undeclared (first use in this function) /* growth variable is gone fishing */ 312: `index1' undeclared (first use in this function) /* index1 is not declared */ 313: `index2' undeclared (first use in this function) /* index2 gone with buddy index1 */ 315: `oldtemp' undeclared (first use in this function) /* oldtemp got tire of being old and die */ [/quote]
Basically your compiler is complainig that is missing a lot of variables. Are you sure you are including every Header file necesary for the code to compile. A header file might have what web_calc and dynamics functions are.
Last edited by Aia : Oct 20th, 2007 at 1:29 pm.
At the very moment that I find myself in the side of the mayority, I will know that I need to re-think my ideas. ~ In my book.
•
•
•
•
Yes, I have included all the headers!!
math.h
stdio.h
and all the gsl libraries
And like I tell you the same folder runs well in linux!! And the compiler never complains about a missing header. It always does
I see that you post some code portion while I was replaying.
Try to locate every variable or function that the compile doesn't see. And find out why it doesn't see it.
At the very moment that I find myself in the side of the mayority, I will know that I need to re-think my ideas. ~ In my book.
•
•
•
•
Ok!
I´m going to do that. But someone knows why it could be running well in Linux and but in Windows
These header files are not part of the Standard C Library:
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_rng.h> // random number generator
#include <gsl/gsl_odeiv.h> // ODE-solving procedures
#include <gsl/gsl_errno.h> // errorhandler
#include <gsl/gsl_blas.h> // linear algebra with vecors and matrices
Those are part of the GNU Scientific Library. No in your Windows compiler by default.
At the very moment that I find myself in the side of the mayority, I will know that I need to re-think my ideas. ~ In my book.
•
•
Join Date: Oct 2007
Posts: 13
Reputation:
Rep Power: 2
Solved Threads: 0
•
•
•
•
These header files are not part of the Standard C Library:
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_rng.h> // random number generator
#include <gsl/gsl_odeiv.h> // ODE-solving procedures
#include <gsl/gsl_errno.h> // errorhandler
#include <gsl/gsl_blas.h> // linear algebra with vecors and matrices
Those are part of the GNU Scientific Library. No in your Windows compiler by default.
I know. I lalready copy the GSL library in the default folder of my Windows compiler
•
•
•
•
I know. I lalready copy the GSL library in the default folder of my Windows compiler
I was trying to point to some possible cause why it worked in Linux but not in Windows.
Just because you have installed a port of those libraries to Windows is not garantie that the implementation of the code is the same. If there were Standard C Libraries then you'll know that the implementation of the code would have a greater chance of running in both
platforms without any major change.
At the very moment that I find myself in the side of the mayority, I will know that I need to re-think my ideas. ~ In my book.
![]() |
•
•
•
•
•
•
•
•
DaniWeb C Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
apple browser cellphone code computer core crack data dell desktop development enterprise environment fedora gentoo gpl hardware ibm install internet key laptop linux microsoft mobile network news novell office open open source openoffice operating os pirate red hat security server software source sun survey system ubuntu unix upgrade vista web windows xp
- possible working windows image in dvd? (Windows NT / 2000 / XP / 2003)
- How to remove Linux and install Windows XP? (Linux Users Lounge)
- compiling errors (C++)
- installing linux over troubled windows (*nix Software)
- Linux vs. Microsoft Windows (Linux Users Lounge)
- what are steps to uninstall linux and reinstall windows (Windows NT / 2000 / XP / 2003)
- Mounting an ext2 Linux Filesystem in Windows XP/NT/2000 (*nix Hardware Configuration)
Other Threads in the C Forum
- Previous Thread: problem in the logic
- Next Thread: __XXXXXX Function Types



Linear Mode