|
Home > Archive > Unix Programming > June 2007 > multiple defination errors in makefile
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
multiple defination errors in makefile
|
|
| raju2000myin@gmail.com 2007-06-20, 7:22 am |
| when i running a makefile it shows multiple defination errors.........
if the same code run with g++ compiler it gave correct results means
the functions in that header file is correctly linking but in writing
make file it shows errors like.............
g++ -o main_fwdDyn.x main_fwdDyn.o fwdDyn.o -g -O2 -I. -L../lib
fwdDyn.o(.text+0x0): In function `setmatrix(Matrix, double)':
/users/home/guest/ramesh/twotest/test/matrixfnc.h:11: multiple
definition of `setmatrix(Matrix, double)'
main_fwdDyn.o(.text+0x0):/users/home/guest/ramesh/test/matrixfnc.h:11:
first defined here
fwdDyn.o(.text+0x5c): In function `setelement(Matrix, int, int,
double)':
/users/home/guest/ramesh/twotest/test/matrixfnc.h:22: multiple
definition of `setelement(Matrix, int, int, double)'
main_fwdDyn.o(.text+0x5c):/users/home/guest/ramesh/test/matrixfnc.h:
22: first defined here
fwdDyn.o(.text+0x80): In function `mcalloc(int, int, double)':
/users/home/guest/ramesh/twotest/test/matrixfnc.h:28: multiple
definition of `mcalloc(int, int, double)'
main_fwdDyn.o(.text+0x80):/users/home/guest/ramesh/test/matrixfnc.h:
28: first defined here
fwdDyn.o(.text+0x11c): In function `setptr(Matrix*, double)':
/users/home/guest/ramesh/twotest/test/matrixfnc.h:42: multiple
definition of `setptr(Matrix*, double)'
main_fwdDyn.o(.text+0x11c):/users/home/guest/ramesh/test/matrixfnc.h:
42: first defined here
fwdDyn.o(.text+0x174): In function `ptrcalloc(int, int, int)':
/users/home/guest/ramesh/twotest/test/matrixfnc.h:54: multiple
definition of `ptrcalloc(int, int, int)'
main_fwdDyn.o(.text+0x174):/users/home/guest/ramesh/test/matrixfnc.h:
54: first defined here
fwdDyn.o(.text+0x238): In function `transpose(Matrix)':
/users/home/guest/ramesh/twotest/test/matrixfnc.h:75: multiple
definition of `transpose(Matrix)'
main_fwdDyn.o(.text+0x238):/users/home/guest/ramesh/test/matrixfnc.h:
75: first defined here
fwdDyn.o(.text+0x2e4): In function `operator+(Matrix, Matrix)':
please help me....... its urgent to me............
| |
| Maxim Yegorushkin 2007-06-20, 7:22 am |
| On 20 Jun, 08:11, raju2000m...@gmail.com wrote:
> when i running a makefile it shows multiple defination errors.........
> if the same code run with g++ compiler it gave correct results means
> the functions in that header file is correctly linking but in writing
> make file it shows errors like.............
> g++ -o main_fwdDyn.x main_fwdDyn.o fwdDyn.o -g -O2 -I. -L../lib
> fwdDyn.o(.text+0x0): In function `setmatrix(Matrix, double)':
> /users/home/guest/ramesh/twotest/test/matrixfnc.h:11: multiple
> definition of `setmatrix(Matrix, double)'
> main_fwdDyn.o(.text+0x0):/users/home/guest/ramesh/test/matrixfnc.h:11:
> first defined here
> fwdDyn.o(.text+0x5c): In function `setelement(Matrix, int, int,
> double)':
> /users/home/guest/ramesh/twotest/test/matrixfnc.h:22: multiple
> definition of `setelement(Matrix, int, int, double)'
> main_fwdDyn.o(.text+0x5c):/users/home/guest/ramesh/test/matrixfnc.h:
> 22: first defined here
> fwdDyn.o(.text+0x80): In function `mcalloc(int, int, double)':
> /users/home/guest/ramesh/twotest/test/matrixfnc.h:28: multiple
> definition of `mcalloc(int, int, double)'
> main_fwdDyn.o(.text+0x80):/users/home/guest/ramesh/test/matrixfnc.h:
> 28: first defined here
> fwdDyn.o(.text+0x11c): In function `setptr(Matrix*, double)':
> /users/home/guest/ramesh/twotest/test/matrixfnc.h:42: multiple
> definition of `setptr(Matrix*, double)'
> main_fwdDyn.o(.text+0x11c):/users/home/guest/ramesh/test/matrixfnc.h:
> 42: first defined here
> fwdDyn.o(.text+0x174): In function `ptrcalloc(int, int, int)':
> /users/home/guest/ramesh/twotest/test/matrixfnc.h:54: multiple
> definition of `ptrcalloc(int, int, int)'
> main_fwdDyn.o(.text+0x174):/users/home/guest/ramesh/test/matrixfnc.h:
> 54: first defined here
> fwdDyn.o(.text+0x238): In function `transpose(Matrix)':
> /users/home/guest/ramesh/twotest/test/matrixfnc.h:75: multiple
> definition of `transpose(Matrix)'
> main_fwdDyn.o(.text+0x238):/users/home/guest/ramesh/test/matrixfnc.h:
> 75: first defined here
> fwdDyn.o(.text+0x2e4): In function `operator+(Matrix, Matrix)':
>
> please help me....... its urgent to me............
It probably means that you have function definitions in matrixfnc.h
which are not declared inline. This header gets included in sources
from which fwdDyn.o and main_fwdDyn.o are build. The compiler is
telling you that those functions exist in both of these .o.
Try declaring the multiple defined functions from matrixfnc.h inline.
| |
| Joachim Schmitz 2007-06-20, 7:22 am |
| <raju2000myin@gmail.com> schrieb im Newsbeitrag
news:1182323464.335531.288900@i38g2000prf.googlegroups.com...
> when i running a makefile it shows multiple defination errors.........
> if the same code run with g++ compiler it gave correct results means
> the functions in that header file is correctly linking but in writing
> make file it shows errors like.............
> g++ -o main_fwdDyn.x main_fwdDyn.o fwdDyn.o -g -O2 -I. -L../lib
> fwdDyn.o(.text+0x0): In function `setmatrix(Matrix, double)':
> /users/home/guest/ramesh/twotest/test/matrixfnc.h:11: multiple
> definition of `setmatrix(Matrix, double)'
> main_fwdDyn.o(.text+0x0):/users/home/guest/ramesh/test/matrixfnc.h:11:
> first defined here
> fwdDyn.o(.text+0x5c): In function `setelement(Matrix, int, int,
> double)':
> /users/home/guest/ramesh/twotest/test/matrixfnc.h:22: multiple
> definition of `setelement(Matrix, int, int, double)'
> main_fwdDyn.o(.text+0x5c):/users/home/guest/ramesh/test/matrixfnc.h:
> 22: first defined here
> fwdDyn.o(.text+0x80): In function `mcalloc(int, int, double)':
> /users/home/guest/ramesh/twotest/test/matrixfnc.h:28: multiple
> definition of `mcalloc(int, int, double)'
> main_fwdDyn.o(.text+0x80):/users/home/guest/ramesh/test/matrixfnc.h:
> 28: first defined here
> fwdDyn.o(.text+0x11c): In function `setptr(Matrix*, double)':
> /users/home/guest/ramesh/twotest/test/matrixfnc.h:42: multiple
> definition of `setptr(Matrix*, double)'
> main_fwdDyn.o(.text+0x11c):/users/home/guest/ramesh/test/matrixfnc.h:
> 42: first defined here
> fwdDyn.o(.text+0x174): In function `ptrcalloc(int, int, int)':
> /users/home/guest/ramesh/twotest/test/matrixfnc.h:54: multiple
> definition of `ptrcalloc(int, int, int)'
> main_fwdDyn.o(.text+0x174):/users/home/guest/ramesh/test/matrixfnc.h:
> 54: first defined here
> fwdDyn.o(.text+0x238): In function `transpose(Matrix)':
> /users/home/guest/ramesh/twotest/test/matrixfnc.h:75: multiple
> definition of `transpose(Matrix)'
> main_fwdDyn.o(.text+0x238):/users/home/guest/ramesh/test/matrixfnc.h:
> 75: first defined here
> fwdDyn.o(.text+0x2e4): In function `operator+(Matrix, Matrix)':
Haven't you read Darko's reply to your earlier post?
Apparently (attention: guess work, as you haven't profided the code) some
funktions are defined (rather than declared) in your header file matrixfnc.h
If now main_fwdDyn.C _and_ fwdDyn.C (seems to be C++, right?) both #include
that header, both contain the code for that funktion and the Linker tells
you about the duplication.
Bye, Jojo
|
|
|
|
|