gpt4 book ai didi

c++ - 依赖于 VS2010 的静态编译库时的 undefined symbol

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:19:19 26 4
gpt4 key购买 nike

我在 Visual Stuio 2012 Express 中有一个项目,我想包含一个静态库,使用 MinGWgcc 编译。我将库包含在项目的项目选项中。

不工作。接下来我尝试使用模型最小库。

测试.c

int foo(){return 5;}

指令:

gcc -c test.c
ar rcs libtest.a test.o

对象转储:

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 库的说明:

http://www.mingw.org/wiki/MSVC_and_MinGW_DLLs

不同编译器提供的库不一定兼容的原因,参见:

http://www.mingw.org/wiki/Interoperability_of_Libraries_Created_by_Different_Compiler_Brands

关于c++ - 依赖于 VS2010 的静态编译库时的 undefined symbol ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28860483/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com