C++ 依赖VS2010静态编译库时未定义的符号
我在Visual Stuio 2012 Express中有一个项目,我想包括一个静态库,使用C++ 依赖VS2010静态编译库时未定义的符号,c++,visual-studio-2010,gcc,static-libraries,C++,Visual Studio 2010,Gcc,Static Libraries,我在Visual Stuio 2012 Express中有一个项目,我想包括一个静态库,使用gcc从MinGW编译。我将库包含在项目的项目选项中 不工作。接下来,我尝试了一个模型库 测试c int foo(){return 5;} 命令: objdump: C:\ARM_Workpsace - Legacy\HardwareEmulation\build>objdump -t test.o test.o: file format pe-i386 SYMBOL TABLE: [
gcc
从MinGW
编译。我将库包含在项目的项目选项中
不工作。接下来,我尝试了一个模型库
测试c
int foo(){return 5;}
命令:
objdump:
C:\ARM_Workpsace - Legacy\HardwareEmulation\build>objdump -t test.o
test.o: file format pe-i386
SYMBOL TABLE:
[ 0](sec -2)(fl 0x00)(ty 0)(scl 103) (nx 1) 0x00000000 test.c
File
[ 2](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 1) 0x00000000 _testfun2
AUX tagndx 0 ttlsiz 0x0 lnnos 0 next 0
[ 4](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .text
AUX scnlen 0xa nreloc 0 nlnno 0
[ 6](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .data
AUX scnlen 0x0 nreloc 0 nlnno 0
[ 8](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .bss
AUX scnlen 0x0 nreloc 0 nlnno 0
[ 10](sec 4)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .rdata$zzz
AUX scnlen 0x11 nreloc 0 nlnno 0
[ 12](sec 5)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .eh_frame
AUX scnlen 0x38 nreloc 1 nlnno 0
但是VS2010仍然返回相同的错误:
1>------ Rebuild All started: Project: ReverbTwo, Configuration: Debug Win32 ------
1> ReverbTwo.cpp
1> RackAFXDLL.cpp
1> pluginobjects.cpp
1> plugin.cpp
1> Generating Code...
1>plugin.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
1> Creating library C:\Users\user\AppData\Roaming\RackAFX\PlugIns\ReverbTwo.lib and object C:\Users\user\AppData\Roaming\RackAFX\PlugIns\ReverbTwo.exp
1>ReverbTwo.obj : error LNK2019: unresolved external symbol "int __cdecl testfun2(void)" (?testfun2@@YAHXZ) referenced in function "public: __thiscall CReverbTwo::CReverbTwo(void)" (??0CReverbTwo@@QAE@XZ)
1>C:\Users\user\AppData\Roaming\RackAFX\PlugIns\ReverbTwo.dll : fatal error LNK1120: 1 unresolved externals
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
MinGW提供了有关在visual studio项目中使用MinGW库的说明: 有关不同编译器提供的库不一定兼容的原因,请参阅:
读起来好像您没有为您在项目中创建的AudioProcessor子类实现析构函数。@iheanyi,嗯,它的抽象基类
virtual~AudioProcessor()=0
`调用另一个编译器编译的代码充满了麻烦。这里最明显的错误是MSVC++看不到这是一个C函数,缺少extern“C”
属性。谢谢,@HansPassant。我创建了一个空的.c
项目并导入了libtest.a
;这个符号被找到了。所以现在我有一个工作和一个问题的设置,需要弥合差距。只需编写.h文件,这样C++编译器也可以使用它。感谢这些有价值的链接(在此期间,我以艰难的方式发现了其中的一些要点)。不幸的是,目前我只能依赖纯C静态库。只要我在任何函数实现中引入一个类,符号就不能再解析了。所有内容都包装在extern“C”
中。
1>------ Rebuild All started: Project: ReverbTwo, Configuration: Debug Win32 ------
1> ReverbTwo.cpp
1> RackAFXDLL.cpp
1> pluginobjects.cpp
1> plugin.cpp
1> Generating Code...
1>plugin.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
1> Creating library C:\Users\user\AppData\Roaming\RackAFX\PlugIns\ReverbTwo.lib and object C:\Users\user\AppData\Roaming\RackAFX\PlugIns\ReverbTwo.exp
1>ReverbTwo.obj : error LNK2019: unresolved external symbol "int __cdecl testfun2(void)" (?testfun2@@YAHXZ) referenced in function "public: __thiscall CReverbTwo::CReverbTwo(void)" (??0CReverbTwo@@QAE@XZ)
1>C:\Users\user\AppData\Roaming\RackAFX\PlugIns\ReverbTwo.dll : fatal error LNK1120: 1 unresolved externals
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========