其實起初想干脆使用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.
