SCons、Boost::ASIO、Windows 预编译头和链接器错误
当我们为多个平台开发 C++ 时,我正在研究在构建过程中使用 SCons。 我在构建配置中已经完成了 99% 的工作,但是我在 Windows 上遇到了一个与预编译头文件有关的非常奇怪的错误。 更奇怪的是,这种情况只发生在一个项目上。
在该项目的 SConscript 文件中,我使用以下内容在 Windows 上编译 PCH:
if env['PLATFORM'] == 'win32':
env['PCH'] = env.PCH('MyPCH-LSCommon.pch', 'Common/src/MyPCH.h')[0]
env['PCHSTOP'] = '"MyPCH.h"'
我还设置了一个编译器标志,以强制在项目中的所有文件上包含 MyPCH.h:
if env['PLATFORM'] == 'win32':
cxxflags = [ '/FI"MyPCH.h"' ]
一切顺利并且编译绝对正常。 直到最后的 DLL 链接阶段,我才收到一页又一页的链接器错误,如下所示:
error LNK2001: unresolved external symbol "private: static class
boost::asio::detail::tss_ptr<class boost::asio::detail::call_stack<class
boost::asio::detail::win_iocp_io_service>::context> boost::asio::detail::call_stack<class
boost::asio::detail::win_iocp_io_service>::top_"
(?top_@?$call_stack@Vwin_iocp_io_service@detail@asio@boost@@@detail@asio@boost@@0V?$tss_ptr@
Vcontext@?$call_stack@Vwin_iocp_io_service@detail@asio@boost@@@detail@asio@boost@@@234@A)
和:
error LNK2001: unresolved external symbol "private: static class
boost::asio::detail::winsock_init<2,0> boost::asio::detail::winsock_init<2,0>::instance_"
(?instance_@?$winsock_init@$01$0A@@detail@asio@boost@@0V1234@A)
这很令人费解,因为我收到链接警告的类都没有使用 boost:: asio,尽管它包含在预编译头文件中并在一些 #include 中包含在链上。
更令人费解的是,如果我禁用预编译头文件的编译,但仍然强制包含它,则所有内容都可以正常编译和链接。 这只是需要永远的疯狂。
有谁知道可能导致这些链接器错误的原因吗?
提前致谢。
--- 编辑 ---
这是 SCons 为构建 PCH 而吐出的命令行(减去包含路径):
cl /nologo /W4 /Od /RTC1 /MDd /TP /EHsc /FD /RTC1 /RTCc /Gy /openmp /TP
/Fd"\vc80.pdb" /nologo /Wp64 /wd4231 /wd4616 /errorReport:prompt /Zm256 /MDd /Od
/FI"CedrusPCH.h" /DOS_WINDOWS=OS_WINDOWS /D_WIN32 /DWIN32 /D_WIN32_WINNT=0X500 /D_WINDOWS
/D_UNICODE /DBOOST_ALL_DYN_LINK /DBOOST_REGEX_DYN_LINK /DBOOST_LIB_DIAGNOSTIC
/D_VC80_UPGRADE=0x710 /DUNICODE /DWXUSINGDLL /DwxUSE_SERVICE_DISCOVERY=1 /D_DEBUG /D_DEBUG
/DSL_ENABLE_NETWORKING=1 /DWXMAKINGDLL_LSCOMMON /DSLSDK_USEDLL
/c C:\Projects\licenser\Common\src\CedrusPCH.h /Foscons-out\dbg\obj\CedrusPCH-LSCommon.obj
/Yc"CedrusPCH.h" /Fpscons-out\dbg\obj\CedrusPCH-LSCommon.pch /ZI CedrusPCH.h
这是正在编译的文件的命令行(再次减去包含路径):
cl /Foscons-out\dbg\obj\Licenser\src\secure\windows_crypto
\PlatformCryptoKeyProvider_wincrypt.obj /c C:\Projects\licenser\Licenser\src\secure
\windows_crypto\PlatformCryptoKeyProvider_wincrypt.cpp /nologo /W4 /Od /RTC1 /MDd /TP
/EHsc /FD /RTC1 /RTCc /Gy /openmp /TP /Fd"\vc80.pdb" /nologo /Wp64 /wd4231 /wd4616
/errorReport:prompt /Zm256 /MDd /Od /FI"CedrusPCH.h" /nologo /W4 /Od /RTC1 /MDd
/DOS_WINDOWS=OS_WINDOWS /D_WIN32 /DWIN32 /D_WIN32_WINNT=0X500 /D_WINDOWS /D_UNICODE
/DBOOST_ALL_DYN_LINK /DBOOST_REGEX_DYN_LINK /DBOOST_LIB_DIAGNOSTIC /D_VC80_UPGRADE=0x710
/DUNICODE /DWXUSINGDLL /DwxUSE_SERVICE_DISCOVERY=1 /D_DEBUG /D_DEBUG
/DSL_ENABLE_NETWORKING=1 /DWXMAKINGDLL_LSCOMMON /DSLSDK_USEDLL /D_USRDLL /D_WINDLL
/Yu"CedrusPCH.h" /Fpscons-out\dbg\obj\CedrusPCH-LSCommon.pch /ZI
PlatformCryptoKeyProvider_wincrypt.cpp
最后,这是链接命令行:
link /nologo /MACHINE:X86 /DEBUG -manifest /dll /out:scons-out\dbg\obj\LSCommon.dll
/implib:scons-out\dbg\obj\LSCommon.lib /LIBPATH:scons-out\dbg\lib
/LIBPATH:C:\Projects\licenser\scons-out\dbg\lib /LIBPATH:scons-out\dbg\obj
/LIBPATH:. /LIBPATH:C:\Projects\licenser /LIBPATH:C:\Projects\licenser\scons-out\dbg\obj
/LIBPATH:C:\Projects\wxWidgets\lib\vc_dll_vc8 /LIBPATH:C:\Projects\boost\install\lib
"/LIBPATH:C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib"
"/LIBPATH:C:\Program Files\Bonjour SDK\lib\win32" unicows.lib winmm.lib comctl32.lib
rpcrt4.lib ws2_32.lib oleacc.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib oleacc.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib boost_signals-vc80-mt-gd-1_39.lib boost_system-vc80-mt-gd-1_39.lib
boost_date_time-vc80-mt-gd-1_39.lib boost_regex-vc80-mt-gd-1_39.lib
boost_wserialization-vc80-mt-gd-1_39.lib boost_serialization-vc80-mt-gd-1_39.lib
boost_thread-vc80-mt-gd-1_39.lib wxbase28ud.lib wxbase28ud_net.lib wxbase28ud_xml.lib
wxmsw28ud_adv.lib wxmsw28ud_aui.lib wxmsw28ud_core.lib wxmsw28ud_html.lib wxmsw28ud_qa.lib
wxmsw28ud_richtext.lib wxmsw28ud_xrc.lib LSBase.lib disphelper.lib Crypt32.lib
/PDB:scons-out\dbg\obj\LSCommon.pdb /DEBUG
scons-out\dbg\obj\Licenser\src\dll_template_instantiation_export_LSCommon.obj
scons-out\dbg\obj\Licenser\src\secure\ConcreteMessageSigningAlgorithm_DSA_with_SHA1.obj
scons-out\dbg\obj\Licenser\src\secure\CryptoObjectFactory.obj
scons-out\dbg\obj\Licenser\src\secure\EntropyCalculation.obj
scons-out\dbg\obj\Licenser\src\data\LSAccount.obj
scons-out\dbg\obj\Licenser\src\data\LSAccountHistory.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSAccountHistoryRequestPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSAccountRequestPacket.obj
scons-out\dbg\obj\Licenser\src\data\LSActivation.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSActivationRequestPacket.obj
scons-out\dbg\obj\Licenser\src\data\LSBlob.obj
scons-out\dbg\obj\Licenser\src\data\LSCompositePrimaryKey.obj
scons-out\dbg\obj\Licenser\src\data\LSDatabaseElementBase.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSDoActivateReplyPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSDoActivateRequestPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSDoManualActivateReplyPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSDoManualActivateRequestPacket.obj
scons-out\dbg\obj\Licenser\src\data\LSLicense.obj
scons-out\dbg\obj\Licenser\src\data\LSLicenseHistory.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSLicenseHistoryRequestPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSLicenseRequestPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSLoginReplyPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSLoginRequestPacket.obj
scons-out\dbg\obj\Licenser\src\data\LSMachine.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSMachineRequestPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSNet.obj
scons-out\dbg\obj\Licenser\src\data\LSPhyActivation.obj
scons-out\dbg\obj\Licenser\src\data\deprecated_streamables\LSPhyActivation_LegacyStreamingHelper.obj
scons-out\dbg\obj\Licenser\src\data\LSPrimaryKey.obj
scons-out\dbg\obj\Licenser\src\data\LSPrimaryKeyDefinitions.obj
scons-out\dbg\obj\Licenser\src\data\LSProduct.obj
scons-out\dbg\obj\Licenser\src\data\LSProductHistory.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSProductHistoryRequestPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSProductRequestPacket.obj
scons-out\dbg\obj\Licenser\src\data\LSSimplePrimaryKey.obj
scons-out\dbg\obj\Licenser\src\data\LSUser.obj
scons-out\dbg\obj\Licenser\src\data\LSUserHistory.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSUserHistoryRequestPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSUserRequestPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\streaming_versioning\StreamableClassInfoVersionTranslator.obj
scons-out\dbg\obj\Licenser\src\data\deprecated_streamables\LSProduct_deprecated_v_2.obj
scons-out\dbg\obj\Licenser\src\secure\deprecated_streamables\DSA.obj
scons-out\dbg\obj\Licenser\src\secure\deprecated_streamables\DSAKeyPair.obj
scons-out\dbg\obj\Licenser\src\secure\deprecated_streamables\DSAPublicKey.obj
scons-out\dbg\obj\Licenser\src\secure\deprecated_streamables\Hash.obj
scons-out\dbg\obj\Licenser\src\secure\deprecated_streamables\SHA1.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSActivationApprovalStrategy.obj
scons-out\dbg\obj\Licenser\src\data\LSDatabaseElementT.obj
scons-out\dbg\obj\Licenser\src\data\LSPairPrimaryKeyT.obj
scons-out\dbg\obj\Licenser\src\data\LSSimplePrimaryKeyT.obj
scons-out\dbg\obj\Licenser\src\secure\windows_crypto\PlatformCryptoKeyProvider_wincrypt.obj
scons-out\dbg\obj\Licenser\src\secure\windows_crypto\Scoped_RAII_AutoReleaseWincryptHandleFactory.obj
此外,每个单独的文件并未明确包含 PCH 标头,但在命令行选项中,我有 /FI 强制在项目中编译的每个文件上包含 PCH。
I'm investigating using SCons for our build process as we develop C++ for multiple platforms. I'm 99% of the way there in the build configuration, but I'm running into a VERY strange error on Windows having to do with the precompiled header file. Even stranger still is that it only happens on one project.
In the SConscript file for this project, I have the following to compile the PCH on windows:
if env['PLATFORM'] == 'win32':
env['PCH'] = env.PCH('MyPCH-LSCommon.pch', 'Common/src/MyPCH.h')[0]
env['PCHSTOP'] = '"MyPCH.h"'
I also have a compiler flag set to force include MyPCH.h on all files in the project:
if env['PLATFORM'] == 'win32':
cxxflags = [ '/FI"MyPCH.h"' ]
Everything goes along and compiles absolutely fine. It isn't until the final DLL link stage that I get pages and pages of linker errors such as the following:
error LNK2001: unresolved external symbol "private: static class
boost::asio::detail::tss_ptr<class boost::asio::detail::call_stack<class
boost::asio::detail::win_iocp_io_service>::context> boost::asio::detail::call_stack<class
boost::asio::detail::win_iocp_io_service>::top_"
(?top_@?$call_stack@Vwin_iocp_io_service@detail@asio@boost@@@detail@asio@boost@@0V?$tss_ptr@
Vcontext@?$call_stack@Vwin_iocp_io_service@detail@asio@boost@@@detail@asio@boost@@@234@A)
and:
error LNK2001: unresolved external symbol "private: static class
boost::asio::detail::winsock_init<2,0> boost::asio::detail::winsock_init<2,0>::instance_"
(?instance_@?$winsock_init@$01$0A@@detail@asio@boost@@0V1234@A)
This is puzzling because none of the classes that I'm getting link warnings from don't even use boost::asio, although it is included in the precompiled header file and up the chain in some #includes.
Even more puzzling is that if I disable compilation of the precompiled header file, yet still force it's include, everything compiles and links just fine. It just takes freaking forever.
Does anyone have a clue as to what could be causing these linker errors?
Thanks in advance.
--- EDIT ---
Here's the command line that SCons is spitting out for building the PCH (Minus Include Paths):
cl /nologo /W4 /Od /RTC1 /MDd /TP /EHsc /FD /RTC1 /RTCc /Gy /openmp /TP
/Fd"\vc80.pdb" /nologo /Wp64 /wd4231 /wd4616 /errorReport:prompt /Zm256 /MDd /Od
/FI"CedrusPCH.h" /DOS_WINDOWS=OS_WINDOWS /D_WIN32 /DWIN32 /D_WIN32_WINNT=0X500 /D_WINDOWS
/D_UNICODE /DBOOST_ALL_DYN_LINK /DBOOST_REGEX_DYN_LINK /DBOOST_LIB_DIAGNOSTIC
/D_VC80_UPGRADE=0x710 /DUNICODE /DWXUSINGDLL /DwxUSE_SERVICE_DISCOVERY=1 /D_DEBUG /D_DEBUG
/DSL_ENABLE_NETWORKING=1 /DWXMAKINGDLL_LSCOMMON /DSLSDK_USEDLL
/c C:\Projects\licenser\Common\src\CedrusPCH.h /Foscons-out\dbg\obj\CedrusPCH-LSCommon.obj
/Yc"CedrusPCH.h" /Fpscons-out\dbg\obj\CedrusPCH-LSCommon.pch /ZI CedrusPCH.h
Here's the command line for a file being compiled (again minus include paths):
cl /Foscons-out\dbg\obj\Licenser\src\secure\windows_crypto
\PlatformCryptoKeyProvider_wincrypt.obj /c C:\Projects\licenser\Licenser\src\secure
\windows_crypto\PlatformCryptoKeyProvider_wincrypt.cpp /nologo /W4 /Od /RTC1 /MDd /TP
/EHsc /FD /RTC1 /RTCc /Gy /openmp /TP /Fd"\vc80.pdb" /nologo /Wp64 /wd4231 /wd4616
/errorReport:prompt /Zm256 /MDd /Od /FI"CedrusPCH.h" /nologo /W4 /Od /RTC1 /MDd
/DOS_WINDOWS=OS_WINDOWS /D_WIN32 /DWIN32 /D_WIN32_WINNT=0X500 /D_WINDOWS /D_UNICODE
/DBOOST_ALL_DYN_LINK /DBOOST_REGEX_DYN_LINK /DBOOST_LIB_DIAGNOSTIC /D_VC80_UPGRADE=0x710
/DUNICODE /DWXUSINGDLL /DwxUSE_SERVICE_DISCOVERY=1 /D_DEBUG /D_DEBUG
/DSL_ENABLE_NETWORKING=1 /DWXMAKINGDLL_LSCOMMON /DSLSDK_USEDLL /D_USRDLL /D_WINDLL
/Yu"CedrusPCH.h" /Fpscons-out\dbg\obj\CedrusPCH-LSCommon.pch /ZI
PlatformCryptoKeyProvider_wincrypt.cpp
And finally, here's the link command line:
link /nologo /MACHINE:X86 /DEBUG -manifest /dll /out:scons-out\dbg\obj\LSCommon.dll
/implib:scons-out\dbg\obj\LSCommon.lib /LIBPATH:scons-out\dbg\lib
/LIBPATH:C:\Projects\licenser\scons-out\dbg\lib /LIBPATH:scons-out\dbg\obj
/LIBPATH:. /LIBPATH:C:\Projects\licenser /LIBPATH:C:\Projects\licenser\scons-out\dbg\obj
/LIBPATH:C:\Projects\wxWidgets\lib\vc_dll_vc8 /LIBPATH:C:\Projects\boost\install\lib
"/LIBPATH:C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib"
"/LIBPATH:C:\Program Files\Bonjour SDK\lib\win32" unicows.lib winmm.lib comctl32.lib
rpcrt4.lib ws2_32.lib oleacc.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib oleacc.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib boost_signals-vc80-mt-gd-1_39.lib boost_system-vc80-mt-gd-1_39.lib
boost_date_time-vc80-mt-gd-1_39.lib boost_regex-vc80-mt-gd-1_39.lib
boost_wserialization-vc80-mt-gd-1_39.lib boost_serialization-vc80-mt-gd-1_39.lib
boost_thread-vc80-mt-gd-1_39.lib wxbase28ud.lib wxbase28ud_net.lib wxbase28ud_xml.lib
wxmsw28ud_adv.lib wxmsw28ud_aui.lib wxmsw28ud_core.lib wxmsw28ud_html.lib wxmsw28ud_qa.lib
wxmsw28ud_richtext.lib wxmsw28ud_xrc.lib LSBase.lib disphelper.lib Crypt32.lib
/PDB:scons-out\dbg\obj\LSCommon.pdb /DEBUG
scons-out\dbg\obj\Licenser\src\dll_template_instantiation_export_LSCommon.obj
scons-out\dbg\obj\Licenser\src\secure\ConcreteMessageSigningAlgorithm_DSA_with_SHA1.obj
scons-out\dbg\obj\Licenser\src\secure\CryptoObjectFactory.obj
scons-out\dbg\obj\Licenser\src\secure\EntropyCalculation.obj
scons-out\dbg\obj\Licenser\src\data\LSAccount.obj
scons-out\dbg\obj\Licenser\src\data\LSAccountHistory.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSAccountHistoryRequestPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSAccountRequestPacket.obj
scons-out\dbg\obj\Licenser\src\data\LSActivation.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSActivationRequestPacket.obj
scons-out\dbg\obj\Licenser\src\data\LSBlob.obj
scons-out\dbg\obj\Licenser\src\data\LSCompositePrimaryKey.obj
scons-out\dbg\obj\Licenser\src\data\LSDatabaseElementBase.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSDoActivateReplyPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSDoActivateRequestPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSDoManualActivateReplyPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSDoManualActivateRequestPacket.obj
scons-out\dbg\obj\Licenser\src\data\LSLicense.obj
scons-out\dbg\obj\Licenser\src\data\LSLicenseHistory.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSLicenseHistoryRequestPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSLicenseRequestPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSLoginReplyPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSLoginRequestPacket.obj
scons-out\dbg\obj\Licenser\src\data\LSMachine.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSMachineRequestPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSNet.obj
scons-out\dbg\obj\Licenser\src\data\LSPhyActivation.obj
scons-out\dbg\obj\Licenser\src\data\deprecated_streamables\LSPhyActivation_LegacyStreamingHelper.obj
scons-out\dbg\obj\Licenser\src\data\LSPrimaryKey.obj
scons-out\dbg\obj\Licenser\src\data\LSPrimaryKeyDefinitions.obj
scons-out\dbg\obj\Licenser\src\data\LSProduct.obj
scons-out\dbg\obj\Licenser\src\data\LSProductHistory.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSProductHistoryRequestPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSProductRequestPacket.obj
scons-out\dbg\obj\Licenser\src\data\LSSimplePrimaryKey.obj
scons-out\dbg\obj\Licenser\src\data\LSUser.obj
scons-out\dbg\obj\Licenser\src\data\LSUserHistory.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSUserHistoryRequestPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSUserRequestPacket.obj
scons-out\dbg\obj\Licenser\src\server_daemon\streaming_versioning\StreamableClassInfoVersionTranslator.obj
scons-out\dbg\obj\Licenser\src\data\deprecated_streamables\LSProduct_deprecated_v_2.obj
scons-out\dbg\obj\Licenser\src\secure\deprecated_streamables\DSA.obj
scons-out\dbg\obj\Licenser\src\secure\deprecated_streamables\DSAKeyPair.obj
scons-out\dbg\obj\Licenser\src\secure\deprecated_streamables\DSAPublicKey.obj
scons-out\dbg\obj\Licenser\src\secure\deprecated_streamables\Hash.obj
scons-out\dbg\obj\Licenser\src\secure\deprecated_streamables\SHA1.obj
scons-out\dbg\obj\Licenser\src\server_daemon\LSActivationApprovalStrategy.obj
scons-out\dbg\obj\Licenser\src\data\LSDatabaseElementT.obj
scons-out\dbg\obj\Licenser\src\data\LSPairPrimaryKeyT.obj
scons-out\dbg\obj\Licenser\src\data\LSSimplePrimaryKeyT.obj
scons-out\dbg\obj\Licenser\src\secure\windows_crypto\PlatformCryptoKeyProvider_wincrypt.obj
scons-out\dbg\obj\Licenser\src\secure\windows_crypto\Scoped_RAII_AutoReleaseWincryptHandleFactory.obj
Also, the PCH header isn't explicitly included by each individual file, but on the command line options, I have /FI that force includes the PCH on every file compiled in the project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我似乎已经解决了我自己的问题。 预编译头文件时,cl.exe 生成一个 .obj 文件。 因为我们使用 boost 的内部魔法来自动链接到 Windows 上所需的库,并且我们的 boost 标头 #includes 也在预编译标头中,所以这些链接也包含在 .obj 文件中。 不幸的是,这个 .obj 文件没有添加到需要链接的 .obj 文件列表中(在本例中为生成 .dll)。
它的工作原理是手动将 PCH 编译期间生成的 .obj 文件附加到 LINKFLAGS 参数。 这样做100%完全解决了我一直遇到的问题。 也许是时候更新 msvc.py 工具并向 SCons 发送补丁了!
I seem to have solved my own problem. When precompiling the header file, cl.exe generates a .obj file. Because we're using boost's internal magic to automatically link to needed libraries on Windows and our boost header #includes are also in the precompiled header, those links are also included in the .obj file. Unfortunately, this .obj file is not added to the list of .obj files that need to be linked (to make a .dll in this case).
What got it working was manually appending the .obj file generated during compilation of the PCH to the LINKFLAGS argument. Doing this 100% completely solves the problem I've been having. Maybe it's time to update the msvc.py tool and send a patch into SCons!
编译时有 2 个定义,它们在构建预编译头时存在:
据我所知,这些是 MFC 遗留物。 我对它们一无所知,但如果 wxWidgets 对它们有一些依赖性,我不会感到惊讶。 我怀疑 Boost 确实如此(但我也没有看过)。
There are 2 defines when compiling that are there when building the pre-compiled headers:
As far as I know, these are MFC relics. I don't really know anything about them, but I wouldn't be surprised if wxWidgets had some dependencies on them. I doubt that Boost does (but I havn't looked, either).