def:
LIBRARY Cmpnt.dll
DESCRIPTION 'Chapter 7 Example COM Component (c)1996-1997 Dale E. Rogerson'
EXPORTS
DllGetClassObject @2 PRIVATE
DllCanUnloadNow @3 PRIVATE
DllRegisterServer @4 PRIVATE
DllUnregisterServer @5 PRIVATE
MAKEFILE:
#
# Chapter 7 - Makefile
#
#
# Flags - Always compiles debug.
#
CPP_FLAGS=/c /MTd /Zi /Od /D_DEBUG
EXE_LINK_FLAGS=/DEBUG
DLL_LINK_FLAGS=/DLL /DEBUG
LIBS=UUID.lib Advapi32.lib Ole32.lib
#################################################
#
# Targets
#
all : client component
client : Client.exe
component : Cmpnt.dll
#################################################
#
# Shared source files
#
GUIDs.obj : GUIDs.cpp
cl $(CPP_FLAGS) GUIDs.cpp
Registry.obj : Registry.cpp Registry.h
cl $(CPP_FLAGS) Registry.cpp
#################################################
#
# component source files
#
Cmpnt.obj : Cmpnt.cpp Iface.h Registry.h
cl $(CPP_FLAGS) Cmpnt.cpp
#################################################
#
# Client source files
#
Client.obj : Client.cpp Iface.h
cl $(CPP_FLAGS) Client.cpp
#################################################
#
# Link component and automatically register component.
#
Cmpnt.dll : Cmpnt.obj GUIDs.obj Registry.obj Cmpnt.def
link $(DLL_LINK_FLAGS) Cmpnt.obj GUIDs.obj Registry.obj $(LIBS) /DEF:Cmpnt.def
regsvr32 -s Cmpnt.dll
#################################################
#
# Link client.
#
Client.exe : Client.obj GUIDs.obj
link $(EXE_LINK_FLAGS) Client.obj GUIDs.obj $(LIBS)
用 nmake 编译运行没问题, 可是如果用VS2008 编译的话, DLL组件编译可以通过, CLIENT.EXE 编译就抱错:
1>------ 已启动全部重新生成: 项目: CMPNT, 配置: Debug Win32 ------
1>正在删除项目“CMPNT”(配置“Debug|Win32”)的中间文件和输出文件
1>正在编译...
1>CMPNT.CPP
1>REGISTRY.CPP
1>d:\c\com\comclient\compnt\registry.cpp(64) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string.h(74) : 参见“strcpy”的声明
1>d:\c\com\comclient\compnt\registry.cpp(65) : warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string.h(79) : 参见“strcat”的声明
1>d:\c\com\comclient\compnt\registry.cpp(105) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string.h(74) : 参见“strcpy”的声明
1>d:\c\com\comclient\compnt\registry.cpp(106) : warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string.h(79) : 参见“strcat”的声明
1>d:\c\com\comclient\compnt\registry.cpp(143) : warning C4996: 'wcstombs': This function or variable may be unsafe. Consider using wcstombs_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdlib.h(534) : 参见“wcstombs”的声明
1>d:\c\com\comclient\compnt\registry.cpp(202) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string.h(74) : 参见“strcpy”的声明
1>d:\c\com\comclient\compnt\registry.cpp(207) : warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string.h(79) : 参见“strcat”的声明
1>d:\c\com\comclient\compnt\registry.cpp(208) : warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string.h(79) : 参见“strcat”的声明
1>GUIDS.CPP
1>d:\c\com\comclient\compnt\guids.cpp(6) : warning C4005: “INITGUID”: 宏重定义
1> 命令行参数: 参见前面的“INITGUID”定义
1>正在生成代码...
1>正在编译资源清单...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>正在链接...
1>LINK : 没有找到 D:\C\com\COMCLIENT\Debug\CMPNT.dll 或上一个增量链接没有生成它;正在执行完全链接
1>CMPNT.DEF(2) : warning LNK4017: DESCRIPTION 语句不支持目标平台;已忽略
1>CMPNT.DEF : warning LNK4222: 不应为导出符号“DllGetClassObject”分配序号
1>CMPNT.DEF : warning LNK4222: 不应为导出符号“DllCanUnloadNow”分配序号
1>CMPNT.DEF : warning LNK4222: 不应为导出符号“DllRegisterServer”分配序号
1>CMPNT.DEF : warning LNK4222: 不应为导出符号“DllUnregisterServer”分配序号
1> 正在创建库 D:\C\com\COMCLIENT\Debug\CMPNT.lib 和对象 D:\C\com\COMCLIENT\Debug\CMPNT.exp
1>正在嵌入清单...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>生成日志保存在“file://d:\C\com\COMCLIENT\COMPNT\Debug\BuildLog.htm”
1>CMPNT - 0 个错误,14 个警告
2>------ 已启动全部重新生成: 项目: COMCLIENT, 配置: Debug Win32 ------
2>正在删除项目“COMCLIENT”(配置“Debug|Win32”)的中间文件和输出文件
2>正在编译...
2>CLIENT.CPP
2>正在编译资源清单...
2>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
2>Copyright (C) Microsoft Corporation. All rights reserved.
2>正在链接...
2>CLIENT.obj : error LNK2001: 无法解析的外部符号 _IID_IZ
2>CLIENT.obj : error LNK2001: 无法解析的外部符号 _IID_IY
2>CLIENT.obj : error LNK2001: 无法解析的外部符号 _CLSID_Component1
2>CLIENT.obj : error LNK2001: 无法解析的外部符号 _IID_IX
2>D:\C\com\COMCLIENT\Debug\COMCLIENT.exe : fatal error LNK1120: 4 个无法解析的外部命令
2>生成日志保存在“file://d:\C\com\COMCLIENT\COMCLIENT\Debug\BuildLog.htm”
2>COMCLIENT - 5 个错误,0 个警告
========== 全部重新生成: 成功 1 个,失败 1 个,跳过 0 个 ==========
设置了项目倚赖,问了DEEPSEEK仍然无法解决