468,513 Members | 1,766 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,513 developers. It's quick & easy.

multiple definition error in linker

1
Hi,
I am trying to set up a cardiac simulator using CVODE package.

I have a integrator.cpp file where I set up all the parameters to call the CVODe package.

The file compiles just fine, but when I try to build it it crashed with a multiple definition error on all the functions and variables defined in the file.

This problem is portable from VC++ to cygwwin g++

here is the error in VC++:


integrator.obj : error LNK2005: "public: void __thiscall CDFNCell::CVode_run(double,double * const)" (?CVode_run@CDFNCell@@QAEXNQAN@Z) already defined in cardiacsimulator.obj
integrator.obj : error LNK2005: _func_f already defined in cardiacsimulator.obj
integrator.obj : error LNK2005: "public: void __thiscall CDFNCell::CVode_f(int,double,struct _generic_N_Vector *,struct _generic_N_Vector *,void *)" (?CVode_f@CDFNCell@@QAEXHNPAU_generic_N_Vector@@0P AX@Z) already defined in cardiacsimulator.obj
.......

Please help!

Thx
Oct 5 '06 #1
2 3958
Banfa
9,056 Expert Mod 8TB
integrator.obj : error LNK2005: "public: void __thiscall CDFNCell::CVode_run(double,double * const)" (?CVode_run@CDFNCell@@QAEXNQAN@Z) already defined in cardiacsimulator.obj
integrator.obj : error LNK2005: _func_f already defined in cardiacsimulator.obj
integrator.obj : error LNK2005: "public: void __thiscall CDFNCell::CVode_f(int,double,struct _generic_N_Vector *,struct _generic_N_Vector *,void *)" (?CVode_f@CDFNCell@@QAEXHNPAU_generic_N_Vector@@0P AX@Z) already defined in cardiacsimulator.obj
These errors are actually telling what the problem is.

The first 3 lines are saying

The function CDFNCell::CVode_run(double,double * const) which is defined in integrator.obj (presumably compiled from integrator.cpp) is already defined (i.e. already exists) in cardiacsimulator.obj (presumably compiled from cardiacsimulator.cpp).

i.e. you have implemented the function twice once in each file

The second 3 lines say the same thing about CDFNCell::CVode_f(int,double,struct _generic_N_Vector *,struct _generic_N_Vector *,void *)


Generally speaking it is a good idea to only implement the functions of your program once per program :D
Oct 5 '06 #2
If your func is not implemented at multiple places. Then check if it is not inline and defined in a .h file which is included by both integrator.cc and cardiacsimulator.cc.
Either the func should be inline or defined in a .cc file.
Aug 31 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by Georg Teichtmeister | last post: by
7 posts views Thread by Ittay Dror | last post: by
3 posts views Thread by Robert Mens | last post: by
9 posts views Thread by lbj137 | last post: by
1 post views Thread by Yogesh | last post: by
10 posts views Thread by subramanian100in | last post: by
8 posts views Thread by subramanian100in | last post: by
6 posts views Thread by The Architect | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.