This document describes how to quickly integrate the Tencent Cloud IM SDK into your projects. Follow these steps to integrate the SDK easily.
The following describes how to integrate the SDK into a Visual Studio 2015 project by creating a simple MFC project.
Download the Windows IM SDK from GitHub.
Download and decompress the IM SDK file folder, which contains the following:
Directory Name | Description |
---|---|
includes | API header files |
lib\Win32\Debug | 32-bit Debug mode, using /MTd to link to library files |
lib\Win32\Release | 32-bit Release mode, using /MT to link to library files |
lib\Win64\Debug | 64-bit Debug mode, using /MTd to link to library files |
lib\Win64\Release | 64-bit Release mode, using /MT to link to library files |
Open Visual Studio and create an MFC application named IMDemo.
For quick integration, on the Application Type page of the wizard, select the simple Dialog-based type. Do not change the defaults of other configuration items.
Copy the IM SDK files to the directory where IMDemo.vcxproj
is located.
The IM SDK provides two compiled static libraries, Debug and Release, which require some special configurations. To do this, go to the IMDemo property page by clicking Solution Resource Manager > Right-Click Menu of the IMDemo Project > Properties.
Using 32-bit Debug mode as an example, configure the project as follows:
$(ProjectDir)ImSDK\includes
.$(ProjectDir)ImSDK\lib\Win32\Debug
. imsdk.lib
.xcopy /E /Y "$(ProjectDir)ImSDK\lib\Win32\Debug" "$(OutDir)"
to copy the dynamic library file imsdk.dll
to the application generation directory./source-charset:.65001
.Configure the Release mode as follows:
$(ProjectDir)ImSDK\lib\Win32\Release
.xcopy /E /Y "$(ProjectDir)ImSDK\lib\Win32\Release" "$(OutDir)"
to copy the dynamic library file imsdk.dll
to the application generation directory.The settings for 64-bit Debug/Release and 32-bit are similar, but their library directories of the IM SDK are different, as shown below:
$(ProjectDir)ImSDK\lib\Win64\Debug
.$(ProjectDir)ImSDK\lib\Win64\Release
.xcopy /E /Y "$(ProjectDir)ImSDK\lib\Win64\Debug" "$(OutDir)"
to copy the dynamic library file imsdk.dll
to the application generation directory.xcopy /E /Y "$(ProjectDir)ImSDK\lib\Win64\Release" "$(OutDir)"
to copy the dynamic library file imsdk.dll
to the application generation directory.In the file IMDemo.cpp
, add the header file:
#include "TIMCloud.h"
In the function CIMDemoDlg::OnInitDialog
, add the following test code:
std::string version = TIMGetSDKVersion();
CString szText;
szText.Format(L"SDK version: %hs", version.c_str());
CWnd* pStatic = GetDlgItem(IDC_STATIC);
pStatic->SetWindowTextW(szText);
Press F5 to run the code and print the IM SDK version number.
If the following error occurs, check whether the directory of the IM SDK header file has been correctly added according to the preceding project configuration:
fatal error C1083: unable to open the header file: "TIMCloud.h": No such file or directory
If the following error occurs, check whether the IM SDK library directory and library file have been correctly added according to the preceding project configuration:
LINK : fatal error LNK1104: unable to open the file "imsdk.lib"
error LNK2019: unable to parse the external symbol `__imp__TIMGetSDKVersion`; this symbol is referenced in `protected: virtual int __thiscall CIMDemoDlg::OnInitDialog(void)" (?OnInitDialog@CIMDemoDlg@@MAEHXZ)`
If the following error occurs, check whether the DLL file of the IM SDK has been copied to the execution directory according to the preceding project configuration.
Was this page helpful?