其实起初想干脆使用CMake作为Build System,但怕步子迈的太大,扯的蛋疼,所以干脆先全面Move到VS2010之后,免得在Build System花太多时间。
至于CMake或者Scons,乃至于Continus Build,日后再说吧。
>> 如何转换
说白了,就是在VS2010中打开VS2008的工程,Build一把,没有问题之后再运行一把TestServer,看看基于TUT的iTest/iTry有没有什么不对劲。
因为基于VS2008所做的一些东西大部分是可用的,有一定的参考意义,所以保留SolidMCP.sln,并去掉一些没有必要再维护的MFC工程,所以为VS2010专门拷贝了一个SolidMCPLiteVC10,这样的
话,可以保证两个系统都可以用。
>> VS2010相关的文件
*.sln
*.vcxproj
This file stores SccProjectName, SccLocalPath and SccProvider as global property elements.
*.vcxproj.filter
Alongside each project which appear to contain a description of the folder structure (\Source Files, \Header Files, etc.).
the build information is separated from the solution explorer display information and incremental build will not be affected by an exclusive-UI settings change.
*.suo file.
It's similar to *.ncb and it is the per solution user setting file and it is used to store the SccAuxPath property.
在Sync代码到Bitbucket的时候, *.sln/*.vcxproj/*.vcxproj.filter都必须保留。
>> STL Iterator defininitions
Symptom:
1>OAuth\OAuthClient.cpp(233): error C2039: 'back_inserter' : is not a member of 'std'
1>OAuth\OAuthClient.cpp(233): error C3861: 'back_inserter': identifier not found
BedRock::StringTokenizer<BedRock::NarrowString>::Tokens::const_iterator token_iter = tokens.begin();
for( ; token_iter != tokens.end(); ++ token_iter)
{
BedRock::StringTokenizer<BedRock::NarrowString> sub_tokenizer(*token_iter, "=");
BedRock::StringTokenizer<BedRock::NarrowString>::Tokens sub_tokens = sub_tokenizer.GetTokens();
if(sub_tokens.size() < 2) continue;
std::copy(sub_tokens.begin(), sub_tokens.end(), std::back_inserter(param_vector));
}
Solution:
Adding header
// VS2010 Migration
// error C3861: 'back_inserter': identifier not found
#if defined(_MSC_VER) && (_MSC_VER >= 1600)
#include <iterator>
#endif
Visual Studio 2010中的VC++对C++0x提供了很多支持,很多标准也与C++0x接轨。这样做的好处是很多的,但同时也会导致以前一些不符合C++0x规范的代码无法像原来那样工作。
VC9 SP1下,include﹤algorithm﹥顺带的就包括了﹤iterator﹥,但在VC10 下需要单独写明。
其他:
error C2039: 'inserter' : is not a member of 'std'
error C3861: 'inserter': identifier not found
>> TR1 Support
Symptom:
error C2440: 'initializing' : cannot convert from 'int' to 'Node*'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
nodeMap.insert(NodeMap::value_type(nodeId, NULL));
Solution:
Using nullptr instead
#if defined(_MSC_VER) && (_MSC_VER >= 1600)
# define SMCP_TR1_SUPPORTED
#endif
#if defined(SMCP_TR1_SUPPORTED)
nodeMap.insert(NodeMap::value_type(nodeId, nullptr));
#else
nodeMap.insert(NodeMap::value_type(nodeId, NULL));
#endif
>> "AlwaysCreate" was specified.
Symptom:
-----------------------------------------------------------------------
1>_PrepareForClean:
1> Deleting file "s:\Intermediate\Debug_X64\Framework\Framework.lastbuildstate".
1>InitializeBuildStatus:
1> Creating "s:\Intermediate\Debug_X64\Framework\Framework.unsuccessfulbuild" because "AlwaysCreate" was specified.
-----------------------------------------------------------------------
Solution:
暂时还没有什么解决方案,不过在MSDN上找到了一些东西。
this property is specific to deployment projects. It specifies whether to create a folder or registry key as part of every installation, even if the folder or registry key is empty.
http://msdn.microsoft.com/en-us/library/e1t11k72.aspx
>> TargetPath/TargetName does not match the Linker's OutputFile property value
Symptom:
-----------------------------------------------------------------------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(s:\Lib\Debug_X64\Framework.dll) does not match the Linker's OutputFile property value (s:\Lib\Debug_x64\SolidMCP_Framework.dll). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(992,5): warning MSB8012: TargetName(Framework) does not match the Linker's OutputFile property value (SolidMCP_Framework). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
-----------------------------------------------------------------------
Solution:
默认情况下,TargetNanme等于$(ProjectName),而Piaoger则为每个工程的输出添加了SolidMCP_。也就是说,需要设置一下Project Settings -- General -- TargetName
--------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------
>> Qt derived class: No relevant classes found
Symptom:
warning : No relevant classes found. No output generated.
Solution:
This means that you listed some header files in your .pro file that do not need moc'ing."Regular" C++ classes (without Q_OBJECT and such) do not need to be added to the HEADERS section.
选中该头文件,Properties中把Item Type从Qt Moc Tool改成C/C++ Header就好了。
>> duplicate resource. type:ICON, name:1, language:0x0409
1>CVTRES : fatal error CVT1100: duplicate resource. type:ICON, name:1, language:0x0409
1>LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
>> Default Directories
For the last several releases, the default Include and Library search paths were found under Tools/Options. Now they are on the General page of the project Properties, under "VC++ Directories."
This is all managed from the Property Manager, so you can override the default directories for a single solution by replacing Microsoft.Cpp.Win32.User (or Microsoft.Cpp.x64.User) with your own custom page. This is a big win over earlier versions of Visual Studio, where the default directories were a global setting that couldn't be overridden.
>> Platform Toolset
You can use the Visual Studio 2008 compiler/linker under the VS2010 IDE, which allows you to get the improved user experience without having to port your code. However, if you are still stuck on VS2003 or VS2005, this won't help you.
>> 32Bit --> 64 Bit
>> *.lib名字也不要乱取
参照.net framework中的namespace,一激动就给某个library取名System.lib,结果有时候会发现Link error, 说System.lib中的某个方法找不到。激动之余,改名System2.lib,过了。再一好奇,就在VC目录想找了一把,还真发现 System.lib兄台。
>> OpenSSL "Ordinal Not Found"
Symptom:
从一个纯洁的程序开始启动,结果发现下面这个错误:
"The ordinal 4445 could not be located in the dynamic link library LIBEAY32.dll"
Solution:
用Process Explorer看了看导入的DLL,发现居然是CPython目录下的那位,难怪,他本该与LibCurl同在在SolidMCP的3P之下的:
说白了,还是Dll有冲突啊。
>> *.lib名字也不要乱取
参照.net framework中的namespace,一激动就给某个library取名System.lib,结果有时候会发现Link error, 说System.lib中的某个方法找不到。激动之余,改名System2.lib,过了。再一好奇,就在VC目录想找了一把,还真发现 System.lib兄台。
>> error MSB8013: This project doesn't contain the Configuration and Platform combination of Debug|Win32
you have a project that's referenced by another project, but only the referencing project is in the solution. The solution stores what configuration each project should be built in for a specific solution configuration. When a project is not listed in the solutoin, we guess at Debug by default. therefore this must be defined in the project.
The correct fix
here is to include the referenced projects in the solution so that you
have control over the configuration used for each project.