Solution to USB programming Link error in vc6 Environment

Source: Internet
Author: User

Vc6Solution to USB programming Link error in Environment

Background:

Programming Environment: Visual C ++ 6.0 + SP6

Operating System: Windows XP Service Pack 3

Raise questions:

The following error occurs when you reference the classic USB view source code in an MFC application:

USB. OBJ: Error lnk2001: unresolved external symbol "unsigned long _ stdcall cm_get_parent (unsigned long *, unsigned long, unsigned long )"(? Cm_get_parent @ ygkpakkk @ Z)

USB. OBJ: Error lnk2001: unresolved external symbol "unsigned long _ stdcall cm_get_sibling (unsigned long *, unsigned long, unsigned long )"(? Cm_get_sibling @ ygkpakkk @ Z)

USB. OBJ: Error lnk2001: unresolved external symbol "unsigned long _ stdcall cm_get_child (unsigned long *, unsigned long, unsigned long )"(? Cm_get_child @ ygkpakkk @ Z)

USB. OBJ: Error lnk2001: unresolved external symbol "unsigned long _ stdcall equals (unsigned long, unsigned long *, unsigned long *, void *, unsigned long *, unsigned long )"(? Cm_get_devnode_registry_propertya @ ygkkkpakpax0k @

Z)

USB. OBJ: Error lnk2001: unresolved external symbol "unsigned long _ stdcall cm_locate_devnodea (unsigned long *, char *, unsigned long )"(? Cm_locate_devnodea @ ygkpakpadk @ Z)

../Bin/debug/atsync.exe: Fatal error lnk1120: 5 unresolved externals

Analyze the problem:

Cm_locate_devnode

Cm_get_devnode_registry_property

Cm_get_sibling

Cm_get_child

Cm_get_parent

These functions are all from the same cfgmgr32.lib static Link Library,

The cfgmgr32.lib library should be compiled in C language. Therefore, when using C ++ for programming, you cannot simply use include When referencing the cfgmgr32.h header file, that is, # include "cfgmgr32.h ", the extern "C" statement must be added.

Solution:

# Ifdef _ cplusplus

Extern "C "{

# Include "cfgmgr32.h"

}

# Endif

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.