error LNK2001: 无法解析的外部符号 “unsigned int __cdecl upx_adler32(void const *,unsigned int,unsigned int)”

本文详细介绍了如何解决在将UPX源码转换为动态链接库后,编译过程中出现的无法解析外部符号错误。通过具体实例分析了错误原因,并提供了有效的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转自VC错误:http://www.vcerror.com/?p=1413

问题描述:

把upx源码的exe工程改造成了一个lib库文件,编译了一个exe调用lib库文件中的函数,结果exe编译出现如以下错误

1>upxlib.lib(p_unix.obj) : error LNK2001: 无法解析的外部符号 “unsigned int __cdecl upx_adler32(void const *,unsigned int,unsigned int)” (?upx_adler32@@YAIPBXII@Z)
1>upxlib.lib(p_lx_interp.obj) : error LNK2001: 无法解析的外部符号 “unsigned int __cdecl upx_adler32(void const *,unsigned int,unsigned int)” (?upx_adler32@@YAIPBXII@Z)
1>upxlib.lib(p_ps1.obj) : error LNK2001: 无法解析的外部符号 “unsigned int __cdecl upx_adler32(void const *,unsigned int,unsigned int)” (?upx_adler32@@YAIPBXII@Z)
1>upxlib.lib(p_mach.obj) : error LNK2019: 无法解析的外部符号 “unsigned int __cdecl upx_adler32(void const *,unsigned int,unsigned int)” (?upx_adler32@@YAIPBXII@Z),该符号在函数 “public: __thiscall PackMachBase<struct N_Mach::MachClass_64<struct N_BELE_CTP::LEPolicy> >::PackMachBase<struct N_Mach::MachClass_64<struct N_BELE_CTP::LEPolicy> >(class InputFile *,unsigned int,unsigned int,unsigned int,unsigned int,unsigned int)” (??0?$PackMachBase@U?$MachClass_64@ULEPolicy@N_BELE_CTP@@@N_Mach@@@@QAE@PAVInputFile@@IIIII@Z) 中被引用
1>upxlib.lib(filter.obj) : error LNK2001: 无法解析的外部符号 “unsigned int __cdecl upx_adler32(void const *,unsigned int,unsigned int)” (?upx_adler32@@YAIPBXII@Z)
1>upxlib.lib(main.obj) : error LNK2001: 无法解析的外部符号 “unsigned int __cdecl upx_adler32(void const *,unsigned int,unsigned int)” (?upx_adler32@@YAIPBXII@Z)
1>upxlib.lib(packer.obj) : error LNK2001: 无法解析的外部符号 “unsigned int __cdecl upx_adler32(void const *,unsigned int,unsigned int)” (?upx_adler32@@YAIPBXII@Z)
1>upxlib.lib(p_lx_exc.obj) : error LNK2001: 无法解析的外部符号 “unsigned int __cdecl upx_adler32(void const *,unsigned int,unsigned int)” (?upx_adler32@@YAIPBXII@Z)
1>upxlib.lib(p_lx_elf.obj) : error LNK2001: 无法解析的外部符号 “unsigned int __cdecl upx_adler32(void const *,unsigned int,unsigned int)” (?upx_adler32@@YAIPBXII@Z)
1>upxlib.lib(p_ps1.obj) : error LNK2001: 无法解析的外部符号 “int __cdecl upx_compress(unsigned char const *,unsigned int,unsigned char *,unsigned int *,struct upx_callback_t *,int,int,struct upx_compress_config_t const *,struct upx_compress_result_t *)” (?upx_compress@@YAHPBEIPAEPAIPAUupx_callback_t@@HHPBUupx_compress_config_t@@PAUupx_compress_result_t@@@Z)
1>upxlib.lib(p_mach.obj) : error LNK2001: 无法解析的外部符号 “int __cdecl upx_compress(unsigned char const *,unsigned int,unsigned char *,unsigned int *,struct upx_callback_t *,int,int,struct upx_compress_config_t const *,struct upx_compress_result_t *)” (?upx_compress@@YAHPBEIPAEPAIPAUupx_callback_t@@HHPBUupx_compress_config_t@@PAUupx_compress_result_t@@@Z)
1>upxlib.lib(p_unix.obj) : error LNK2001: 无法解析的外部符号 “int __cdecl upx_compress(unsigned char const *,unsigned int,unsigned char *,unsigned int *,struct upx_callback_t *,int,int,struct upx_compress_config_t const *,struct upx_compress_result_t *)” (?upx_compress@@YAHPBEIPAEPAIPAUupx_callback_t@@HHPBUupx_compress_config_t@@PAUupx_compress_result_t@@@Z)
1>upxlib.lib(packer.obj) : error LNK2019: 无法解析的外部符号 “int __cdecl upx_compress(unsigned char const *,unsigned int,unsigned char *,unsigned int *,struct upx_callback_t *,int,int,struct upx_compress_config_t const *,struct upx_compress_result_t *)” (?upx_compress@@YAHPBEIPAEPAIPAUupx_callback_t@@HHPBUupx_compress_config_t@@PAUupx_compress_result_t@@@Z),该符号在函数 “protected: virtual bool __thiscall Packer::compress(unsigned char *,unsigned int,unsigned char *,struct upx_compress_config_t const *)” (?compress@Packer@@MAE_NPAEI0PBUupx_compress_config_t@@@Z) 中被引用
1>upxlib.lib(p_exe.obj) : error LNK2001: 无法解析的外部符号 “int __cdecl upx_compress(unsigned char const *,unsigned int,unsigned char *,unsigned int *,struct upx_callback_t *,int,int,struct upx_compress_config_t const *,struct upx_compress_result_t *)” (?upx_compress@@YAHPBEIPAEPAIPAUupx_callback_t@@HHPBUupx_compress_config_t@@PAUupx_compress_result_t@@@Z)
1>upxlib.lib(p_lx_elf.obj) : error LNK2001: 无法解析的外部符号 “int __cdecl upx_compress(unsigned char const *,unsigned int,unsigned char *,unsigned int *,struct upx_callback_t *,int,int,struct upx_compress_config_t const *,struct upx_compress_result_t *)” (?upx_compress@@YAHPBEIPAEPAIPAUupx_callback_t@@HHPBUupx_compress_config_t@@PAUupx_compress_result_t@@@Z)
1>upxlib.lib(p_vmlinx.obj) : error LNK2001: 无法解析的外部符号 “int __cdecl upx_compress(unsigned char const *,unsigned int,unsigned char *,unsigned int *,struct upx_callback_t *,int,int,struct upx_compress_config_t const *,struct upx_compress_result_t *)” (?upx_compress@@YAHPBEIPAEPAIPAUupx_callback_t@@HHPBUupx_compress_config_t@@PAUupx_compress_result_t@@@Z)
1>upxlib.lib(packer.obj) : error LNK2019: 无法解析的外部符号 “int __cdecl upx_decompress(unsigned char const *,unsigned int,unsigned char *,unsigned int *,int,struct upx_compress_result_t const *)” (?upx_decompress@@YAHPBEIPAEPAIHPBUupx_compress_result_t@@@Z),该符号在函数 “protected: virtual bool __thiscall Packer::compress(unsigned char *,unsigned int,unsigned char *,struct upx_compress_config_t const *)” (?compress@Packer@@MAE_NPAEI0PBUupx_compress_config_t@@@Z) 中被引用
1>upxlib.lib(p_ps1.obj) : error LNK2001: 无法解析的外部符号 “int __cdecl upx_decompress(unsigned char const *,unsigned int,unsigned char *,unsigned int *,int,struct upx_compress_result_t const *)” (?upx_decompress@@YAHPBEIPAEPAIHPBUupx_compress_result_t@@@Z)
1>upxlib.lib(linker.obj) : error LNK2001: 无法解析的外部符号 “int __cdecl upx_decompress(unsigned char const *,unsigned int,unsigned char *,unsigned int *,int,struct upx_compress_result_t const *)” (?upx_decompress@@YAHPBEIPAEPAIHPBUupx_compress_result_t@@@Z)
1>upxlib.lib(packer.obj) : error LNK2019: 无法解析的外部符号 “int __cdecl upx_test_overlap(unsigned char const *,unsigned char const *,unsigned int,unsigned int,unsigned int *,int,struct upx_compress_result_t const *)” (?upx_test_overlap@@YAHPBE0IIPAIHPBUupx_compress_result_t@@@Z),该符号在函数 “bool __cdecl ph_testOverlappingDecompression(class PackHeader const &,unsigned char const *,unsigned char const *,unsigned int)” (?ph_testOverlappingDecompression@@YA_NABVPackHeader@@PBE1I@Z) 中被引用


解决方法:

具体的解决方法参考文章:http://www.vcerror.com/?p=1413
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值