依赖VS2010中静态编译的库时未定义的符号
Undefined symbols when depending on a statically compiled library from VS2010
我在Visual Stuio 2012学习版中有一个项目,我想包括一个静态库,用gcc
从MinGW
编译。我把图书馆包括在项目的选项中。
不工作。接下来,我尝试了一个最小库的模型。
test.c
int foo(){return 5;}
cmd:
gcc -c test.c
ar rcs libtest.a test.o
objdump:
C:ARM_Workpsace - LegacyHardwareEmulationbuild>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:UsersuserAppDataRoamingRackAFXPlugInsReverbTwo.lib and object C:UsersuserAppDataRoamingRackAFXPlugInsReverbTwo.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:UsersuserAppDataRoamingRackAFXPlugInsReverbTwo.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
相关文章:
- vscode g++链路故障:体系结构x86_64的未定义符号
- 体系结构x86_64的未定义符号:std:terminate(),typeinfo,运算符delete[],运算符new
- C++ 中 dlsym 的未定义符号
- 仅在 MacOS 上析构函数的未定义符号
- OSX clang++:用于 cpp 文件中显式实例化模板的体系结构x86_64的未定义符号
- PCL 出错:体系结构x86_64 @pcl的未定义符号
- clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用) - 体系结构的未定义符号 x86_64:
- 体系结构x86_64的未定义符号:链接器错误
- C++ std::vector<int> 体系结构的未定义符号 x86_64:
- 生成文件:体系结构x86_64的未定义符号
- libc++abi未定义符号:_ZTVN10__cxxabif120__si-class_type_infoE
- Xcode"体系结构x86_64的未定义符号"
- 体系结构x86_64的未定义符号:找不到原因
- SWIG链接器:未定义符号:_ZN2cv8fastFreeEPv(cv::fastFree(void*))
- 如何修复架构x86_64的未定义符号,Boost Asio 1.58
- 在Qt5上去静态库:架构的未定义符号x86_64:
- 体系结构x86_64的未定义符号:c++/ h 文件和 cpp 文件
- 监视 SDK 下的未定义符号"__Unwind_SjLj_Unregister"
- 使用 Boost/Python 的未定义符号 - 复杂
- 建筑x86_64的未定义符号:"vtkDebugLeaksManager::vtkDebugLeaksManager()",引用自: