I’m trying to create a shared library version of praatlib. The code itself comes with a Makefile that produces a static library, but for my purposes I need a shared library. I’ve tried two things. The first thing I tried doing was editing the Makefile to produce a shared library along with the static one.
Here is the part of the makefile that produces the static library:
libpraat.a:
cd GSL; make
cd num; make
cd num/glpk; make
cd kar; make
cd audio; make
cd mp3; make
cd FLAC; make
cd stat; make
cd fon; make
cd dwsys; make
cd dwtools; make
cd LPC; make
cd FFNet; make
cd artsynth; make
cd library; make
rm -f libpraat.a
ar r libpraat.a `find num glpk audio stat LPC FFNet dwtools artsynth fon stat dwsys GSL kar FLAC mp3 library -name "*.o"`
And here is what I added to produce the shared library.
libpraat.so:
cd GSL; make
cd num; make
cd num/glpk; make
cd kar; make
cd audio; make
cd mp3; make
cd FLAC; make
cd stat; make
cd fon; make
cd dwsys; make
cd dwtools; make
cd LPC; make
cd FFNet; make
cd artsynth; make
cd library; make
rm -f libpraat.so
$(CC) -shared -Wl,-soname,libpraat.so -o libpraat.so `find num glpk audio stat LPC FFNet dwtools artsynth fon stat dwsys GSL kar FLAC mp3 library -name "*.o"`
The static library gets made without encountering any problems however when it tries to make the shared library it errors out.
Here is the beginning of the error message (there are a lot of errors but they’re all basically the same as the one’s I’ve pasted below).
gcc -std=gnu99 -DUNIX -Dlinux -DCONSOLE_APPLICATION -I /usr/local/include -I /usr/X11R6/include -Wimplicit -Wreturn-type -Wunused -Wunused-parameter -Wuninitialized -O -fPIC -Wall -shared -Wl,-soname,libpraat.so -o libpraat.so `find num glpk audio stat LPC FFNet dwtools artsynth fon stat dwsys GSL kar FLAC mp3 library -name "*.o"`
stat/Table.o: In function `Table_getStringValue':
Table.c:(.text+0x246): multiple definition of `Table_getStringValue'
stat/Table.o:Table.c:(.text+0x246): first defined here
stat/Table.o:(.data.rel+0x174): multiple definition of `classTable'
stat/Table.o:(.data.rel+0x174): first defined here
stat/Table.o:(.data.rel+0xb4): multiple definition of `classTableRow'
stat/Table.o:(.data.rel+0xb4): first defined here
stat/Table.o: In function `Table_appendRow':
Table.c:(.text+0x1147): multiple definition of `Table_appendRow'
stat/Table.o:Table.c:(.text+0x1147): first defined here
stat/Table.o: In function `Table_initWithoutColumnNames':
Table.c:(.text+0x11a5): multiple definition of `Table_initWithoutColumnNames'
stat/Table.o:Table.c:(.text+0x11a5): first defined here
stat/Table.o: In function `Table_createWithoutColumnNames':
Table.c:(.text+0x123f): multiple definition of `Table_createWithoutColumnNames'
stat/Table.o:Table.c:(.text+0x123f): first defined here
stat/Table.o: In function `Table_insertColumn':
Table.c:(.text+0x1298): multiple definition of `Table_insertColumn'
stat/Table.o:Table.c:(.text+0x1298): first defined here
stat/Table.o: In function `Table_appendColumn':
Table.c:(.text+0x151e): multiple definition of `Table_appendColumn'
After trying a lot of different things and getting frustrated I tried just converting the static library that I had directly into a shared library using this command:
g++ -std=c++98 -fpic -g -O1 -shared -o libpraat.so -Wl,--whole-archive libpraat.a
but I got a similar error message as before. I’m not extremely experienced with building large projects or libraries and so I’m lost as to how I can get this to work. I would greatly appreciate it if anyone could explain what causes the error I’m experiencing and how I can go about fixing it.
Let’s look carefully at the command you use for finding object files:
Notice that
statappears twice. Don’t do that.