MIDL COM库中未解决的外部符号
Unresolved external symbol in MIDL COM library
我的系统是Windows 10 64位Fall Creator Edition,带有Visual Studio 2010 Professional。
我具有以下IDL(isomeinterface.idl(的com接口:
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(61E246F6-3F22-404B-8EA8-E4D13F3206D6),
pointer_default(unique)
]
interface ISomeInterface : IUnknown
{
HRESULT DoSomething();
}
[
uuid(7EF22D33-5C29-4D32-BFBC-0B276C5F7427),
version(1.0),
helpstring("ISomeInterface 1.0 Type Library")
]
library ISomeInterfaceLib
{
importlib("stdole2.tlb");
[
uuid(BC91D238-B0E1-4FA2-AAC8-195D761DF9DC),
version(1.0),
helpstring("ISomeInterface Class")
]
coclass ISomeInterfaceImpl
{
[default] interface ISomeInterface;
};
};
我用此命令编译的:
midl /iid "ISomeInterface_i.c" /env win32 /h "ISomeInterface.h" /W1 /char signed /tlb "ReleaseISomeInterface.tlb" /Oicf /D "NDEBUG" /robust /nologo /proxy "ISomeInterface_p.c" ISomeInterface.idl
然后我创建一个模块定义文件(isOmeInterface.def(:
LIBRARY "ISomeInterface"
EXPORTS
DllGetClassObject PRIVATE
DllCanUnloadNow PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
IID_ISomeInterface DATA
LIBID_ISomeInterfaceLib DATA
我使用以下命令构建接口DLL:
cl /c /Zi /W1 /WX- /O2 /Oy- /D WIN32 /D REGISTER_PROXY_DLL /D NDEBUG /D _WINDLL /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Release\" /Fd"Releasevc100.pdb" /Gd /TC /analyze- /errorReport:prompt dlldata.c ISomeInterface_i.c ISomeInterface_p.c
link "/OUT:ReleaseISomeInterface.dll" rpcns4.lib rpcrt4.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "/DEF:ISomeInterface.def" /MANIFEST "/ManifestFile:ReleaseISomeInterface.dll.intermediate.manifest" "/MANIFESTUAC:level='asInvoker' uiAccess='false'" "/PDB:ReleaseISomeInterface.pdb" /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE /NXCOMPAT "/IMPLIB:ReleaseISomeInterface.lib" /MACHINE:X86 /DLL Releasedlldata.obj ReleaseISomeInterface_i.obj ReleaseISomeInterface_p.obj
我的问题是,当我创建我的ATL可执行文件时,它一直无法链接给我:
SomeApp.obj : error LNK2001: unresolved external symbol _LIBID_ISomeInterfaceLib
我正在使用#include "ISomeInterface.h"
,并已将ISomeInterface.lib
添加到Linker->输入中。
运行dumpbin.exe /exports ReleaseISomeInterface.dll
提供以下内容:
Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file ReleaseISomeInterface.dll
File Type: DLL
Section contains the following exports for ISomeInterface.dll
00000000 characteristics
5ABD61A2 time date stamp Thu Mar 29 17:58:58 2018
0.00 version
1 ordinal base
6 number of functions
6 number of names
ordinal hint RVA name
1 0 00001040 DllCanUnloadNow
2 1 00001000 DllGetClassObject
3 2 000010A0 DllRegisterServer
4 3 000010E0 DllUnregisterServer
5 4 000030E8 IID_ISomeInterface
6 5 000030F8 LIBID_ISomeInterfaceLib
Summary
1000 .data
1000 .orpc
1000 .rdata
1000 .reloc
1000 .text
运行dumpbin.exe -headers ReleaseISomeInterface.lib | findstr /c:" Symbol name :"
显示LIB文件中的符号:
Symbol name : _IID_ISomeInterface
Symbol name : _LIBID_ISomeInterfaceLib
如果我在项目中使用ISomeInterface_i.c
并删除LIB,则可以很好地编译,但是我试图摆脱...
因此,如果我从模块定义文件中删除数据,则符号链接似乎正确。新文件:
LIBRARY "ISomeInterface"
EXPORTS
DllGetClassObject PRIVATE
DllCanUnloadNow PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
IID_ISomeInterface
LIBID_ISomeInterfaceLib
相关文章:
- C++:Application.cpp中抛出了未解析的外部符号(解决方案在问题的末尾,供未来的读者参考)
- 未解析的外部符号_MsiLocateComponentW@12.
- 在C++中使用 gRPC 时未解析的外部符号
- LibPrivoxy: 未解析的外部符号 __declspec(dllimport) int __stdcall Sta
- 尝试从 XamlApplication 编译 C++/WinRT 空白应用程序时,我收到未解析的外部符号 winrt_make_*
- 我收到错误LNK2001:未解析的外部符号(C++代码)
- 可视抽象类 c++(错误 LNK 2001:未解析的外部符号)
- 如何摆脱C++中未解析的外部符号"private: static char"错误?
- 当 lib 已添加到其他依赖项时,如何在 VS 中调试未解析的外部符号错误
- 仅在少数方法(静态或共享库)中解析的外部符号
- 未解析的外部符号"__declspec(dllimport)与 Spdlog c++ 库
- 函数 _main (OPENGL C++) 中引用的未解析的外部符号 ________
- 错误LNK2019未解析的外部符号"public: __thiscall SLinkList<char>::SLinkList<char>(void)"
- 使用静态 constexpr 成员的未解析外部符号
- 引入参数化构造函数后显示 LNK 2019 未解析外部符号的代码错误
- Dlib LNK2001未解析的外部符号USER_ERROR__consistent_build_configurati
- 矛盾的未解决的外部符号+未使用的库与VS2017和FFMPEG 4
- 链接器错误:切换到unicode生成给出:未解析的外部符号WinMain
- 类模板上一个特定函数的未解析外部符号
- LNK2001:未解析的外部符号public:static类std::vector