Technical Document #35

Technical Document #35
When trying to build my WinDriver application from MS Visual Studio, I get the following error:
int_io.obj : error LNK2001: unresolved external symbol __beginthreadex
How can I resolve this?

You should enable multi-threading from your project, by adding the relevant flag to the project settings.

The Microsoft flag, when compiling with MS Visual Studio (Visual C++) is -MT. Therefore, be sure to add: /MT to the Project Settings. (Add this option in 'Project' --> 'Settings...', under the 'C/C++' tab, 'Category: General', in the 'Project Options' box.)

For other compilers, verify that the compiler-specific multi-threading flag is used. For example, the Borland C++ Builder flag is -tWM.

NOTE that the -MT and -tWM flags are already part of the WinDriver samples and generated DriverWizard projects for MS Visual Studio and Borland C++ Builder (respectively).

In addition, beginning with v6.0.0 of WinDriver, in order to use WinDriver's thread functions (ThreadStart() and ThreadStop() — implemented in WinDriver/src/utils.c) from a C/C++ application, you should verify that your project includes an _MT precompiler definition. This definition is also an integrated part of the WinDriver samples and generated code.
For MS Visual Studio 5.0 and above, this definition is part of the samples/generated code beginning with v6.0.0 of WinDriver; for MS Visual Studio 4.0, beginning with v6.0.2.
For Borland C++ Builder (4.0–6.0) this definition is part of the samples/generated code beginning with version 6.0.3 of WinDriver.

MS Visual Studio 4.0–6.0 and Borland C++ Builder were supported until version 11.1.0 of WinDriver.

When creating your own project or when using a version of WinDriver that doesn't, add the definition for your IDE, you can add it to the project yourself:

In MS Visual Studio, do either of the following:

  • Open the project in the MS Visual Studio IDE, select Project --> Settings ... --> C/C++, and add _MT in the Preprocessor Definitions text box, under either the Preprocessor or General Category.

  • Modify the project file (*.vcproj/*.dsp) or makefile (in MS Visual Studio 4.0) by adding /D "_MT" under the # ADD CPP section.

In Borland C++ Builder do either of the following:
  • Add the _MT precompiler definition from within the Borland C++ Builder IDE:
    Project --> Options ... --> Directories/Conditionals --> Conditionals --> Conditional Defines

  • Modify your project (*.bpr) file directly and set the USDERDEFINES section to the following:
    <USERDEFINES value="_MT"/>     (for Borland C++ Builder 5.0.0–6.00).
    USERDEFINES = _MT (for Borland C++ Builder 4.0).