473,779 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

linking error when compiling CVOde in cygwin

have functions in my cell model calling CVODE for each time step.

When I build the application I get a number of link errors:

\cardiacsimulat or.o Release\ccardia ccell.o Release\ccellda ta.o
Release\cgapjun ction.o Release\cheart2 d.o Release\integra tor.o -o
D:\kp\programs\ cardiacsimulato r\Release\cardi acsimulator.exe
Release\integra tor.o: In function `func_f':
/cygdrive/d/kp/programs/cardiacsimulato r/integrator.cpp: 70: multiple
definition of `_func_f'
Release\cardiac simulator.o:/cygdrive/d/kp/programs/cardiacsimulato r/integrator.cpp: 70:
first defined here

What am I doing wrong? I am definitely not redefining any of the
functions!

This is the integrator file
)************** *************** *************** *************** *************** *88
#include "CDFNCell.h "

/* ----------------------------------------------------

code to call CVode
starts here

----------------------------------------------------
*/

#include <sundialstypes. h /* definitions of types realtype and
*/
/* integertype, and the constant FALSE
*/
#include <cvode.h /* prototypes for CVodeMalloc, CVode, and
*/
/* CVodeFree, constants OPT_SIZE, BDF,
NEWTON, */
/* SV, SUCCESS, NST,NFE,NSETUPS , NNI,
NCFN, NETF */
#include <cvdense.h /* prototype for CVDense, constant
DENSE_NJE */
#include <nvector_serial .h /* definitions of type N_Vector and macro
*/
/* NV_Ith_S, prototypes for N_VNew,
N_VFree */
#include <dense.h /* definitions of type DenseMat, macro
DENSE_ELEM*/

/*
CVode specific functions

CVode is a stiff/non-stiff integrator written in C (not in
C++)
To work this code needs header files and a cvode library

*/
extern "C" {

static N_Vector cvode_y;
static void *cvode_mem;
static realtype reltol,abstol;
static N_Vector ew;
static double cvode_t;
M_Env MachEnv;

static realtype ropt[OPT_SIZE];
static long int iopt[OPT_SIZE];

}

// Call CVode
void CDFNCell::CVode _run(double h,double states[])
{
int flag=0,i;

// call CVode to solve ydot(t)=f(y,t) with y(0) given
flag = CVode(cvode_mem , start_time+h, cvode_y, &cvode_t,
NORMAL);

if (flag != SUCCESS) {
cerr<<"CVode failed, flag="<<flag<<" ."<<endl;
}

// copy vector y to states which is returned to compute
for(i=0;i<state size;i++)
states[i]=NV_Ith_S(cvode _y,i);

states[0]=y0[0];

}

// Extra function that acts as a front to CVode
extern "C" void func_f(long N, realtype time, N_Vector y, N_Vector
ydot, void *f_data)
{
cellptr->CVode_f(N, time, y, ydot, f_data);

}

// function f(t,y) for CVode, returns derivatives of variables to CVode
void CDFNCell::CVode _f(int N, double time, N_Vector y, N_Vector ydot,
void *f_data)
{
int z;
static double states2[MAXSTATES];
bool flag=true;

// copy vector y to states2
for(z=0;z<N;z++ )
states2[z]=NV_Ith_S(y,z);

// send states2 to getF which uses it to produce derivatives
calDiff(time,st ates2,flag);

// copy derivatives to vector ydot which is returned to CVode
for(z=0;z<N;z++ ) {
NV_Ith_S(ydot,z )=Diff[z];
}

}

// Initializes CVode
void CDFNCell::CVode Init(double states[],double timenow)
{
int i;

MachEnv = M_EnvInit_Seria l((int)statesiz e);
if (MachEnv == NULL) {
cerr<<"Trouble with MachEnv in CVODE"<<endl;
exit(-3);
}

// Allocate memory for solution vector y(t)
cvode_y = N_VNew((int)sta tesize, MachEnv);
// Allocate memory for solution vector ew(t)
ew = N_VNew((int)sta tesize, MachEnv);

// rel tolerance of 10^-5 might be a good idea
reltol = tolerance_relat ive;
abstol = tolerance_absol ute;

// initialize vector cvode_y with states
for(i=0;i<state size;i++)
NV_Ith_S(cvode_ y,i)=states[i];

// use default values for options
for(i=0;i<OPT_S IZE;i++) {
ropt[i]=0.0;
iopt[i]=0;
}
// except for these
ropt[HMAX]=step_max; // Largest step size
ropt[HMIN]=step_min; // Smallest step size
iopt[MXSTEP]=100000; // max internal step number for cvode

// scale tolerance based on maximum value of state
for(i=0;i<state size;i++) {
NV_Ith_S(ew,i)= abstol/errweight[i];
}

/* CVodeMalloc sets up initial settings for CVode. See
CVODE
documentation.
Integration method is BDF(Backward Differential
Formula)
Other choice would be ADAMS but it is not as stable as
BDF */
#if 0
// This method of calling CVODE does not pass error
weights
cvode_mem = CVodeMalloc(sta tesize, func_f, timenow, cvode_y,
BDF,
NEWTON, SS, &reltol, &abstol,
NULL, NULL, TRUE, iopt, ropt, MachEnv);

//#else
// We wish to pass errorweight to CVODE
//cvode_mem = CVodeMalloc(sta tesize, func_f, timenow, cvode_y,
BDF,
NEWTON,
// SV, &reltol,
ew, NULL, NULL, TRUE, iopt, ropt, MachEnv);
#endif

if (cvode_mem == NULL) {
cerr<<"CVodeMal loc failed."<<endl;
exit(1);
}

/* CVDense is needed by Newton algorithm for solving linear
system
The second NULL tells the solver to compute an approximation
of the
Jacobian. */
CVDense(cvode_m em, NULL, NULL);

}

void CDFNCell::CVode Exit(void)
{
N_VFree(cvode_y );
CVodeFree(cvode _mem);
M_EnvFree_Seria l(MachEnv);

}

*************** *************** *************** *************** ***********
THis is the class definition:

#define CDFNCELL_H
#include <math.h>
#include <iostream>
#include "ccardiaccell.h "
#include <cvode.h /* prototypes for CVodeMalloc, CVode, and
CVodeFree, */
/* constants OPT_SIZE, BDF, NEWTON, SV, SUCCESS,
*/
/* NST, NFE, NSETUPS, NNI, NCFN, NETF
*/
#include <cvdense.h /* prototype for CVDense, constant DENSE_NJE
*/
#include <nvector.h /* definitions of type N_Vector and macro N_VIth,
*/
#include <nvector_serial .h /* definitions of type N_Vector and macro
N_VIth, */
/* prototypes for N_VNew, N_VFree
*/
#include <dense.h /* definitions of type DenseMat, macro DENSE_ELEM
*/
#include <vector>

using namespace std;
const int MAXSTATES = 16;

//Noble Cell Constants
class CDFNCell : public CCardiacCell {
private:
//double iteration;
double I_DFN;
//Membranne Potential
double Vm;
//stim current
double IStim;

void copy(const CDFNCell &);

void setDifferential ();
void setState();

public:
CDFNCell();
~CDFNCell();
void initialize();
void simulate(double Iext);
void calDiff(double, double[],bool);
void returnParameter List(vector<str ing>&);
void returnParamater Values(const vector<string>&
requestedParame ters, vector<double>& );
inline double returnVolt(){re turn (Vm);};
inline double returnNa_i(){re turn (Na_i);};
inline double returnCa_i(){re turn (Ca_i);}; //repeat
function for m n
h
inline double returnK_i(){ret urn (K_i);};
inline double returnK_o(){ret urn (K_c);};

//CVOde functions
void CVode_f(int N, double time, N_Vector y, N_Vector ydot,
void
*f_data);
void CVodeInit(doubl e[],double);
void CVodeExit(void) ;
void CVode_run(doubl e h,double states[]);

int statesize;
bool success;
double start_time;
bool notdone;
double tr_error,errtmp ;
double errweight[15];
double tolerance_relat ive,tolerance_a bsolute; // tolerances for
integrators
double tstep;
double step_min,step_m ax; // minimum and maximum step sizes for
integrators

//constants

int stateFlag; // Is state.txt written out
int currentFlag; // Is current.txt written out
int statederivsFlag ; // Is Deriv.txt written out
int stimulusFlag; // Is stimulus used or not
double y0[15];
double States[MAXSTATES];
double Diff[MAXSTATES];

};

extern CDFNCell *cellptr;

#endif

Oct 4 '06 #1
0 1907

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4933
by: Joonas Paalasmaa | last post by:
Hi, When compiling Sketch's streamfilter C extension the errors below are raised during linking. What could cause the errors? (Python 2.3, MinGw 1.1 with GCC 2.95.3-6, Windows 98) Here are the occurrences of FilterType that may be relevant: ------- C:\sketch\sketch-0.7.12\Filter\filterobj.c: 949: PyTypeObject FilterType = {
0
1418
by: Francisco J. Reyes | last post by:
I get an Internal complier error when compiling C# windows project that uses a custom Class add as reference to the project. The problem appears to be related to the ENUM type used in the class controland where the windows project attempts to call the custom class property set\get a specific value using enum values from the custom class. Thanks in advance.
22
2222
by: TuPLaD | last post by:
Hello, I just made a little C++ console application: #include "iostream" using namespace std; int main () { cout << "Hello Mars !"; return 0;
6
6244
by: mihailsmilev | last post by:
Hello, let me first describe the situation: I am developing an application using Qt Designer 3.3.5 on OpenSuSE Linux for my mp3 player. So I need to get the id3 tags from the mp3 files, and I've downloaded the sources of id3lib. I've included the headers (there are no other files) in my project in Qt designer, then created an object from my files. When starting the make command, it compiles normally all the headers (although giving some...
2
2115
by: etienne | last post by:
Hello, I'm trying to compile this C++ code with gcc 3.4.5 under Solaris/SPARC (from a complete application, the file is : FullLinkedList.hh) but the make fails (no problem when compiling under ubuntu/x86) : (from line 330 to 481) /***************************************************************************** * ITERATOR SECTION - INNER CLASSES
6
3471
by: tony | last post by:
Hello! I have several projects where each one build a library.(class library or window control library). Now I get some strange compile error when building the *.exe file and doesn't understand what this means. Can somebody tell me what is causing this? Do I have made some setup in a wrong way for some of my project where I build my library.
3
2285
by: B. | last post by:
We converted VC++ 6.0 to VS 2005 and tried to compile with /clr, however, we got few linking errors: MSVCMRTD.lib(mstartup.obj) : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (tagTEXTMETRICA): (0x02000039). I knew that other ppl had same problem and solved it by turning Struct Member Alignment to be default. However, our application need it to be 1 byte. Is there any other way...
16
43731
by: Micko1 | last post by:
Hello there :) I have been using Visual Studio on a program which I have just completed, however I need to have it compiling using a unix based compiler, when I try in cygwin, I get the following error: undefined reference to `_WinMain@16' I have tried searching for a workaround, although I am not a programming guru, and I find it difficult to comprehend the discussions on this topic :) Any help is appreciated.
0
9636
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9930
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8961
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.