User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Oct 2007
Posts: 13
Reputation: Paulville is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Paulville Paulville is offline Offline
Newbie Poster

Help problems with a code made in linux working in windows

  #1  
Oct 20th, 2007
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)
Last edited by Paulville : Oct 20th, 2007 at 11:51 am. Reason: include error, so help understand my problem
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2005
Posts: 3,834
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 23
Solved Threads: 436
Colleague
Salem's Avatar
Salem Salem is offline Offline
banned

Re: problems with a code made in linux working in windows

  #2  
Oct 20th, 2007
Pasting the first 100 lines (so we see everything upto the first error line number, and a bit beyond) would be helpful.
Reply With Quote  
Join Date: Oct 2007
Posts: 13
Reputation: Paulville is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Paulville Paulville is offline Offline
Newbie Poster

Re: problems with a code made in linux working in windows

  #3  
Oct 20th, 2007
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.
Reply With Quote  
Join Date: Dec 2006
Posts: 1,569
Reputation: Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold 
Rep Power: 12
Solved Threads: 114
Aia's Avatar
Aia Aia is offline Offline
Posting Virtuoso

Re: problems with a code made in linux working in windows

  #4  
Oct 20th, 2007
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.
Reply With Quote  
Join Date: Oct 2007
Posts: 13
Reputation: Paulville is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Paulville Paulville is offline Offline
Newbie Poster

Re: problems with a code made in linux working in windows

  #5  
Oct 20th, 2007
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
Last edited by Paulville : Oct 20th, 2007 at 1:13 pm. Reason: Forget something
Reply With Quote  
Join Date: Dec 2006
Posts: 1,569
Reputation: Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold 
Rep Power: 12
Solved Threads: 114
Aia's Avatar
Aia Aia is offline Offline
Posting Virtuoso

Re: problems with a code made in linux working in windows

  #6  
Oct 20th, 2007
Originally Posted by Paulville View Post
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.
Reply With Quote  
Join Date: Oct 2007
Posts: 13
Reputation: Paulville is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Paulville Paulville is offline Offline
Newbie Poster

Re: problems with a code made in linux working in windows

  #7  
Oct 20th, 2007
Ok!

I´m going to do that. But someone knows why it could be running well in Linux and but in Windows, that is something normal, do you recommends me to make a partition in my hard disk, linux:windows? Or what!??
Reply With Quote  
Join Date: Dec 2006
Posts: 1,569
Reputation: Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold 
Rep Power: 12
Solved Threads: 114
Aia's Avatar
Aia Aia is offline Offline
Posting Virtuoso

Re: problems with a code made in linux working in windows

  #8  
Oct 20th, 2007
Originally Posted by Paulville View Post
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.
Reply With Quote  
Join Date: Oct 2007
Posts: 13
Reputation: Paulville is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Paulville Paulville is offline Offline
Newbie Poster

Re: problems with a code made in linux working in windows

  #9  
Oct 20th, 2007
Originally Posted by Aia View Post
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
Reply With Quote  
Join Date: Dec 2006
Posts: 1,569
Reputation: Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold 
Rep Power: 12
Solved Threads: 114
Aia's Avatar
Aia Aia is offline Offline
Posting Virtuoso

Re: problems with a code made in linux working in windows

  #10  
Oct 20th, 2007
Originally Posted by Paulville View Post
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 5:41 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC