Debugging: errors and fixes

Install

Error code: S1023 when trying to install DirectX

Solve [1]:

  1. Uninstall Microsoft Visual C++ 2010 x86 Redistributable and Microsoft Visual C++ 2010 x64 Redistributable.
  2. Install DirectX again. Should be OK.
  3. Install back Microsoft Visual C++ 2010 x86 Redistributable and Microsoft Visual C++ 2010 x64 Redistributable.

Error Code: S1023 when trying to install DirectX SDK (June 2010)

cc: http://blogs.msdn.com/b/chuckw/archive/2011/12/09/known-issue-directx-sdk-june-2010-setup-and-the-s1023-error.aspx

  1. Remove the Visual C++ 2010 Redistributable Package version 10.0.40219 (Service Pack 1) from the system (both x86 and x64 if applicable). This can be easily done via a command-line with administrator rights:

    1
    2
    MsiExec.exe /passive /X{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}
    MsiExec.exe /passive /X{1D8E6291-B0D5-35EC-8441-6616F567A0F7}
  2. Install the DirectX SDK (June 2010).
  3. Reinstall the Visual C++ 2010 Redistributable Package version 10.0.40219 (Service Pack 1). On an x64 system, you should install both the x86 and x64 versions of the C++ REDIST. Be sure to install the most current version available.

Compile

Can not find dxtrans.h in DirectX programming

cc: http://blog.csdn.net/clever101/article/details/5617982

  1. Remove #include "dxtrans.h" where causing errors (e.g. qedit.h).
  2. Add the following macro definition to the beginning of code #include <qedit.h>

    1
    2
    3
    4
    #define __IDxtCompositor_INTERFACE_DEFINED__
    #define __IDxtAlphaSetter_INTERFACE_DEFINED__
    #define __IDxtJpeg_INTERFACE_DEFINED__
    #define __IDxtKey_INTERFACE_DEFINED__

error C2143: syntax error : missing ‘)’ before ‘constant’

E.g. after defining a constant: #define A 1, but in program, we mistaken using int A; and so on.

Solve: use A directly, not int A.

error C2146: syntax error : missing ‘;’ before identifier ‘PVOID64’

In winnt.h, add the following line

1
#define POINTER_64 __ptr64

before

1
2
typedef void *PVOID;
typedef void * POINTER_64 PVOID64;

error C2471: cannot update program database —-vc90.pdb

Project –> Properties –> C/C++ –> General –> Debug Information Format –> 'Disabled'.

error C2664: ‘CWnd::MessageBoxW’ : cannot convert parameter 1 from ‘const char [12]’ to ‘LPCTSTR’

Two ways to fix it:

  1. Project –> Properties –> General –> Character Set –> "Use Multi-Byte Character Set".
  2. Indicate that the string literal, in this case "Hello world!" is of a specific encoding. This can be done through either prefixing it with L, such as L"Hello world!", or surrounding it with the generic _T("Hello world!") macro. The latter will expand to the L prefix if you are compiling for unicode, and nothing (indicating multi-byte) otherwise.

error C2665: ‘std::_Copy_impl’ : none of the 2 overloads could convert all the argument types (xutility)

Based on: https://svn.boost.org/trac/boost/ticket/4874
This is a bug of boost library (before version 1_52_0) when using VC2010 in Debug mode (note: the problem also exists in boost-1_52_0 for VC2012 in Debug mode, but still cannot be solved with this method). It can be solved by modifying BOOST_PATH/boost/multi_array/view.hpp to something like

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
multi_array_view& operator=(const multi_array_view& other) {
if (&other != this) {
// make sure the dimensions agree
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
BOOST_ASSERT(std::equal(other.shape(),
other.shape()+this->num_dimensions(),
this->shape()));

#if _MSC_VER >= 1600
auto
iterThis = begin();
auto
iterOther = other.begin();
for (; iterThis != end(); ++iterThis, ++iterOther)
*iterThis = *iterOther;
#else
// iterator-based copy
std::copy(other.begin(),other.end(),begin());
#endif
}
return *this;
}

This source file has changed. It no longer matches the version of the file used to build the application being debugged

  1. Check if code contains illegal characters, e.g. copied from QQ.
  2. Build your project before you debug.

Link

error LNK1000: Internal error during IncrBuildImage

This is common in VS2008, VS2010 fix this. Two ways to fix it:

  1. Install patch VS90-KB948127.exe.
  2. Two steps:
    1. Project –> Properties –> Linker –> General –> Enable Incremental Linking –> 'No'.
    2. Project –> Properties –> C/C++ –> General –> Debug Information Format –> 'Program Database (/Zi)'.

error LNK1104: cannot open file ‘cxcore.lib’

Project –> Properties –> Configuration properties –> Linker – > Input –> Additional Dependence –> Check whether all libs here are consistent with current PC (e.g. after installing OpenCV2.0, should be cxcore200.lib).

error LNK2001: unresolved external symbol __imp___CrtDbgReportW

This will happen when compiling code under vc10 + Debug.

Solve: Project –> Properties –> C/C++ –> Code Generation –> Runtime Library –> Multi-threaded Debug DLL (/MDd)'.

error LNK2001: unresolved external symbol

Reason: not use class:: before the types/names we defined ourselves.

Solve: try to add these all class:: needed.

Run

Entry Point Not Found in DLLs

This means the related dlls CAN be found, but the versions (e.g., x64 vs. x86, built by different versions of MSVCs) of the found Dlls are not correct.

  • To check which exact dlls are linking, use tools like Dependencies to check (click $ \rhd$ to see nested dependent dlls).
  • To resolve this, make sure all the dependent DLLs are all correct.

Note: In some cases, it’s caused by the settings of PATH environment variables, where dlls are found in earlier included paths rather the correct ones. Also keep in mind that System PATH will be included earlier than User PATH.

Misc.

Visual Studio Bug: This platform could not be created because a solution platform of the same name already exists

This will happen when you want to create a solution platform for a single project in a big solution, which one of other projects in the solution has already has this solution platform.
Solve [1]:

  1. Close Visual Studio
  2. Find the project’s (the one that you want to create platform) .vcproject file and open it with e.g. notepad… other than VS.
  3. Inside the <ItemGroup Label="ProjectConfigurations"> node you will find a series of Configuration nodes. Copy (and paste underneath) one which has a name attribute beginning with Debug| and replace the text at the end with your desired platform (i.e. Change Debug|Win32 to Debug|x64).
  4. Repeat the above step for a Release configuration.