?
=?ISO-8859-15?Q?Luigi_Malag=F2?=
Hello,
i'm having a problem with "multiple definition error" linking a library.
I have a program with a main. I have another program with classes and a
main too. I created a library of the second program, after compiling, in
this way:
ar -r /path/lib/libtest.a ./Class1.o ./Class2.o ./Class3.o
Notice that from the list I excluded ./main.o !
then I copied all .h in a specific directory /path/include
Then i compiled the first program adding -I/path/include
and -L/path/lib and -ltest
In the main of the first program, I only include and use some classes
from the second program, I dont expect the first program to clash with
the main of the second program!
Of course I'm missing something, since I cannot compile the program, I
get a multiple definition error:
/path/lib/libbriantool.a(main.o): In function `main':
main.cpp.text+0x70): multiple definition of `main'
../main.o:main.cpp.text+0x70): first defined here
/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../../i686-pc-linux-gnu/bin/ld:
Warning: size of symbol `main' changed from 337 in ./main.o to 3125 in
/path/lib/libbriantool.a(main.o)
collect2: ld returned 1 exit status
make: *** [..] Error 1
Thanks for your help,
Luigi
i'm having a problem with "multiple definition error" linking a library.
I have a program with a main. I have another program with classes and a
main too. I created a library of the second program, after compiling, in
this way:
ar -r /path/lib/libtest.a ./Class1.o ./Class2.o ./Class3.o
Notice that from the list I excluded ./main.o !
then I copied all .h in a specific directory /path/include
Then i compiled the first program adding -I/path/include
and -L/path/lib and -ltest
In the main of the first program, I only include and use some classes
from the second program, I dont expect the first program to clash with
the main of the second program!
Of course I'm missing something, since I cannot compile the program, I
get a multiple definition error:
/path/lib/libbriantool.a(main.o): In function `main':
main.cpp.text+0x70): multiple definition of `main'
../main.o:main.cpp.text+0x70): first defined here
/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../../i686-pc-linux-gnu/bin/ld:
Warning: size of symbol `main' changed from 337 in ./main.o to 3125 in
/path/lib/libbriantool.a(main.o)
collect2: ld returned 1 exit status
make: *** [..] Error 1
Thanks for your help,
Luigi