C/C++ 尝试创建共享库时出错.创建库的静态版本时不会发生错误
C/C++ Error when trying to create a shared library. Error does not occur when making the static version of the library
我正在尝试创建一个共享库版本的praatlib。 代码本身带有一个生成静态库的 Makefile,但出于我的目的,我需要一个共享库。 我尝试了两件事。 我尝试做的第一件事是编辑 Makefile 以生成一个共享库以及静态库。
下面是生成静态库的生成文件的一部分:
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"`
这是我为生成共享库而添加的内容。
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"`
静态库的创建不会遇到任何问题,但是当它尝试创建共享库时,它会出错。
这是错误消息的开头(有很多错误,但它们基本上都与我在下面粘贴的错误相同(。
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'
在尝试了很多不同的东西并感到沮丧之后,我尝试使用以下命令将我拥有的静态库直接转换为共享库:
g++ -std=c++98 -fpic -g -O1 -shared -o libpraat.so -Wl,--whole-archive libpraat.a
但我收到了与以前类似的错误消息。 我在构建大型项目或库方面经验不足,因此我不知道如何才能使其工作。 如果有人能解释导致我遇到的错误的原因以及如何修复它,我将不胜感激。
让我们仔细看看用于查找对象文件的命令:
find num glpk audio stat LPC FFNet dwtools artsynth fon
stat dwsys GSL kar FLAC mp3 library -name "*.o"
请注意,stat
出现两次。 别这样。
相关文章:
- g++ -O3 为 loop 创建了奇怪的指令 - 两个具有相同 asm 的版本
- 创建 OpenCV 非自由版本 v4.3 时出错,可折叠.cpp错误 C2039、2605
- 更新到 2020 年 5 月版本后,无法在 Visual Studio 2019 中创建.exe文件
- 如何在C++中创建自己的循环版本?
- 如何在运行时对程序创建的.sys文件设置文件版本
- 如何创建一个版本的 boost::range::transform,该版本具有用于捕获上下文的额外参数
- 如何创建从版本继承的CMAKE配置类型
- 创建 "no-op" DLL 版本?
- 无法使用 Visual Studio 2010 和 Qt 版本 4.8.0 创建"Qt Gui Application"
- 当模板参数为std::vector时,如何创建此方法的模板版本
- 如何创建受版本控制的 DLL
- C++ 是在每个实例化上创建的模板类中每个方法的新版本
- 如何解决LDCONFIG创建带有版本号的链接
- 使用 #define 和 clang 为 info.plist 创建版本号变体
- C/C++ 尝试创建共享库时出错.创建库的静态版本时不会发生错误
- 如何创建可移植版本的应用程序
- 如何使用Qt的静态构建为Windows创建静态链接版本
- 在c#、c++和java中创建python弱类型结构的强类型版本
- 创建我的.exe的批处理版本,它接受命令行参数(ParamCount(), ParamStr()和BCB 4.0中的Fi
- 如何使用Xregister和CertEnroll创建"Certificate Signing Request"在所有版本的窗口上运行?