我致力于将 Linux C++ 项目移植到 Windows。构建系统是 cmake (2.8)。我使用 nmake 生成器(Visual C++ 10)成功构建了它,但它的调试版本没有启动(参见问题 12215163),然后我想在 Visual Studio 下尝试它,但这里构建在链接时失败,没有找到模板实例化从一个DLL。
您会在下面找到 nmake 和 Visual Studio 构建的输出 请注意,我尝试了显式模板实例化,但没有任何区别。
CMake 和 nmake 生成器 (Visual C++ 10, x64, build type = Debug):它编译
c:\PROGRA~2\MICROS~2.0\VC\bin\amd64\cl.exe /Zc:wchar_t- /EHsc /GR /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1 -IE:\Projets\Amose\Sources\lima_linguisticprocessing\src -IC:\Qt\v4.8.2\include -IC:\Qt\v4.8.2\include\QtXmlPatterns -IC:\Qt\v4.8.2\include\QtXml -IC:\Qt\v4.8.2\include\QtCore -IC:\PROGRA~1\boost\BOOST_~1\include -Ic:\amose-debug\include -D WIN32 -Dlima_lp_analysisdict_EXPORTS -DQT_DLL -DQT_XMLPATTERNS_LIB -DQT_XML_LIB -DQT_CORE_LIB -DBOOST_ALL_DYN_LINK -DLIMA_ANALYSISDICT_EXPORTING -DQT_DEBUG /TP /FoCMakeFiles\lima-lp-analysisdict.dir\FsaAccessResource.cpp.obj /FdC:\amose-vcbuild\lima-lp-debug\src\linguisticProcessing\core\AnalysisDict\lima-lp-analysisdictd.pdb -c E:\Projets\Amose\Sources\lima_linguisticprocessing\src\linguisticProcessing\core\AnalysisDict\FsaAccessResource.cpp
"C:\Program Files (x86)\CMake 2.8\bin\cmake.exe" -E vs_link_dll c:\PROGRA~2\MICROS~2.0\VC\bin\amd64\link.exe @CMakeFiles\lima-lp-analysisdict.dir\objects1.rsp /out:lima-lp-analysisdictd.dll /implib:lima-lp-analysisdictd.lib /pdb:C:\amose-vcbuild\lima-lp-debug\src\linguisticProcessing\core\AnalysisDict\lima-lp-analysisdictd.pdb /dll /version:1.0 /STACK:10000000 /machine:x64 /debug /INCREMENTAL -LIBPATH:C:\PROGRA~1\boost\BOOST_~1\lib -LIBPATH:c:\amose-debug\lib lima-common-factory.lib lima-common-misc.lib lima-common-data.lib lima-common-fsaaccess.lib lima-common-mediaticdata.lib lima-common-time.lib lima-common-xmlconfigurationfiles.lib lima-common-processunitframework.lib lima-common-mediaprocessors.lib ..\LinguisticProcessors\lima-lp-linguisticprocessorsd.lib ..\LinguisticResources\lima-lp-linguisticresourcesd.lib "C:\Program Files\boost\boost_1_50\lib\boost_regex-vc100-mt-gd-1_50.lib" "C:\Program Files\boost\boost_1_50\lib\boost_filesystem-vc100-mt-gd-1_50.lib" "C:\Program Files\boost\boost_1_50\lib\boost_program_options-vc100-mt-gd-1_50.lib" "C:\Program Files\boost\boost_1_50\lib\boost_system-vc100-mt-gd-1_50.lib" "C:\Program Files\boost\boost_1_50\lib\boost_thread-vc100-mt-gd-1_50.lib" "C:\Program Files\boost\boost_1_50\lib\boost_unit_test_framework-vc100-mt-gd-1_50.lib" C:\Qt\v4.8.2\lib\QtXmlPatternsd4.lib C:\Qt\v4.8.2\lib\QtXmld4.lib C:\Qt\v4.8.2\lib\QtNetworkd4.lib C:\Qt\v4.8.2\lib\QtCored4.lib lima-common-misc.lib lima-common-data.lib lima-common-mediaticdata.lib ..\LinguisticProcessors\lima-lp-linguisticprocessorsd.lib lima-common-factory.lib lima-common-time.lib lima-common-xmlconfigurationfiles.lib lima-common-processunitframework.lib lima-common-mediaprocessors.lib lima-common-qslog.lib "C:\Program Files\boost\boost_1_50\lib\boost_regex-vc100-mt-gd-1_50.lib" "C:\Program Files\boost\boost_1_50\lib\boost_filesystem-vc100-mt-gd-1_50.lib" "C:\Program Files\boost\boost_1_50\lib\boost_program_options-vc100-mt-gd-1_50.lib" "C:\Program Files\boost\boost_1_50\lib\boost_system-vc100-mt-gd-1_50.lib" "C:\Program Files\boost\boost_1_50\lib\boost_thread-vc100-mt-gd-1_50.lib" "C:\Program Files\boost\boost_1_50\lib\boost_unit_test_framework-vc100-mt-gd-1_50.lib" C:\Qt\v4.8.2\lib\QtXmlPatternsd4.lib C:\Qt\v4.8.2\lib\QtXmld4.lib C:\Qt\v4.8.2\lib\QtNetworkd4.lib C:\Qt\v4.8.2\lib\QtCored4.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib
CMake 和 Visual Studio 生成器(Visual C++ 10、x64、调试):链接失败
cl /c /IE:/Projets/Amose/Sources/lima_linguisticprocessing/src /IC:/Qt/v4.8.2/include /IC:/Qt/v4.8.2/include/QtXmlPatterns /IC:/Qt/v4.8.2/include/QtXml /IC:/Qt/v4.8.2/include/QtCore /I"C:/Program Files/boost/boost_1_50/include" /IC:/Program /IE:/Projets/Amose/Sources/lima_linguisticprocessing/Files/amosecommon/include /I"C:/amose-vc/include" /Zi /W1 /WX- /Od /Ob0 /D _DEBUG /D WIN32 /D QT_DLL /D QT_XMLPATTERNS_LIB /D QT_XML_LIB /D QT_CORE_LIB /D BOOST_ALL_DYN_LINK /D LIMA_ANALYSISDICT_EXPORTING /D QT_DEBUG /D "CMAKE_INTDIR=\"Debug\"" /D lima_lp_analysisdict_EXPORTS /D _WINDLL /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t- /Zc:forScope /GR /Fo"lima-lp-analysisdict.dir\Debug\\" /Fd"C:/amose-vcbuild/lima-lp-vc/src/linguisticProcessing/core/AnalysisDict/Debug/lima-lp-analysisdictd.pdb" /Gd /TP /errorReport:prompt E:\Projets\Amose\Sources\lima_linguisticprocessing\src\linguisticProcessing\core\AnalysisDict\FsaAccessResource.cpp
(Visual Studio 中不显示链接命令行)
Création de la bibliothèque C:/amose-vcbuild/lima-lp-vc/src/linguisticProcessing/core/AnalysisDict/Debug/lima-lp-analysisdictd.lib et de l'objet C:/amose-vcbuild/lima-lp-vc/src/linguisticProcessing/core/AnalysisDict/Debug/lima-lp-analysisdictd.exp
2>FsaAccessResource.obj : error LNK2019: symbole externe non résolu "__declspec(dllimport) public: void __cdecl Lima::Common::FsaAccess::FsaAccessReader16<class boost::adjacency_list<struct boost::vecS,struct boost::vecS,struct boost::bidirectionalS,struct boost::property<enum vertex_count_t,class std::vector<int,class std::allocator<int> >,struct boost::property<enum boost::vertex_name_t,unsigned long,struct boost::property<enum vertex_text_t,class QString,struct boost::no_property> > >,struct boost::no_property,struct boost::no_property,struct boost::listS> >::read(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_?read@?$FsaAccessReader16@V?$adjacency_list@UvecS@boost@@U12@UbidirectionalS@2@U?$property@W4vertex_count_t@@V?$vector@HV?$allocator@H@std@@@std@@U?$property@W4vertex_name_t@boost@@KU?$property@W4vertex_text_t@@VQString@@Uno_property@boost@@@2@@boost@@@2@Uno_property@2@U52@UlistS@2@@boost@@@FsaAccess@Common@Lima@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) référencé dans la fonction "public: virtual void __cdecl Lima::LinguisticProcessing::AnalysisDict::FsaAccessResource::init(class Lima::Common::XMLConfigurationFiles::GroupConfigurationStructure &,class Lima::InitializableObjectManager<class Lima::LinguisticProcessing::AbstractResource,struct Lima::LinguisticProcessing::ResourceInitializationParameters> *)" (?init@FsaAccessResource@AnalysisDict@LinguisticProcessing@Lima@@UEAAXAEAVGroupConfigurationStructure@XMLConfigurationFiles@Common@4@PEAV?$InitializableObjectManager@VAbstractResource@LinguisticProcessing@Lima@@UResourceInitializationParameters@23@@4@@Z)