2 miscellaneous faq – Measurement Computing CB-7000 Utilities User Manual

Page 39

Advertising
background image

35

Note: System message processing lets the OS process other tasks. This may affect the
performance of this program.

4.2

MISCELLANEOUS FAQ

Q: Error message "[LinkerError] Unresolved external 'xxxx_xxxx __stdcall' referenced from
xxxxxxxxxx “ with Borland C++ Builder
Q: Error message "xxxx.obj : error LNK2001: unresolved external symbol "xxxxxxxxxxx"
(?xxxxx@@xxxxx)” with Microsoft Visual C++

A:

Code will generate this error message if it references something (like a function, variable, or

label) that the linker can't find in all the libraries and object files it searches. In general, there are
two reasons this error occurs:
1. What the code asks for doesn't exist (the symbol is spelled incorrectly or uses the wrong case)
2. What the code asks for the wrong thing (e.g., the user is using mixed versions of the libraries—
some from one version of the product, others from another version).

Otherwise, the naming conventions are different between C and C++, because of C++ decoration
of external symbols. The different naming conventions may also cause the error message occurs.
By causing C++ to drop name decoration, the extern "C" syntax makes it p ossible for a C ++
module to share data and routines with other languages.

The most of the DLL files of our products are written in Microsoft Visual C++ 4.0/5.0, and uses
the C naming conventions. Thus, if the user’s program is in C++ syntax, the header file must be
as follows:

#define EXPORTS extern "C" __declspec (dllimport)
EXPORTS WORD CALLBACK xxxxx_GetDriverVersion(WORD *wDriverVersion);

These declarations force the compiler to use the C naming conventions to refer to these functions.

The user must not change the naming convention if the code is in C syntax. Thus, the header file
must be like the following:

#define EXPORTS
EXPORTS WORD CALLBACK xxxxx_GetDriverVersion(WORD *wDriverVersion);

A few of the DLL files of our products use the C++ naming conventions. Thus, the user’s
program must use the C++ syntax and the user must not change the naming conventions. Thus,
the header file must be as follows:

#define EXPORTS
EXPORTS WORD CALLBACK xxxxx_GetDriverVersion(WORD *wDriverVersion);

We will unify the naming conventions of overall DLL files of o ur products by C nam ing
conventions to reduce these problems.

Advertising