Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
2 ratings:
 5 out of 5     Rate this Document

Can I Use the MFC Library as a Statically Linked Library With a Measurement Studio Project in Visual C++?

Primary Software: Measurement Studio>>Visual C++ Support
Primary Software Version: 6.0
Primary Software Fixed Version: N/A
Secondary Software: N/A

Problem:
I used the Microsoft Foundation Classes (MFC) AppWizard to create a Measurement Studio 6.0 project, and I selected the option to use the MFC as a statically linked library. I was able to create the project, but when I built the project the following error was generated:
Common UI component does not support linking to static MFC.

Now I cannot run the application. Can I build a Measurement Studio project using the MFC library as a statically linked library?

Solution:
Your application includes a Measurement Studio User Interface component or 3D Graph component. These components contain ActiveX controls that link to the MFC DLL. It is not valid to link to both static MFC and the MFC DLL in an application. You therefore cannot link to static MFC in an application that uses the User Interface component or 3D Graph component. When using the User Interface or 3D Graph component, select As a shared DLL (refer to the attached image below of the NI Measurement Studio AppWizard dialog box.)
Alternatively, in previous versions of Measurement Studio, the Measurement Studio AppWizard added the mfcs42.lib and mfcs42d.lib files to projects to work around the linker limitation discussed in Microsoft's knowledge base article, Q148652.
Projects that are statically linked to MFC do not use these library files and thus, produce linker errors upon compiling when the library files are included. To prevent these linker errors, you must remove mfcs42.lib and mfcs42d.lib from your project. Complete the steps below to remove the files.

  1. In the Visual C++ environment, click Project»Settings»Link.
  2. Select the appropriate option in Settings For, then clear the mfcs42.lib and mfcs42d.lib entries from the Object/library modules field.
  3. Click OK.
Note: If you are using a C module in your project, refer to KnowledgeBase 35SD8G00 for information about how to handle using C source files while linking to MFC.



Related Links:
Microsoft KB#Q148652. PRB: LNK2005 Errors When Link C Run-Time Libraries Are Linked Before MFC Libraries
KnowledgeBase 35SD8G00: Linker Errors when Compiling with C-based Instrument Drivers

Attachments:


AppWizard.gif


Report Date: 04/16/2003
Last Updated: 11/12/2008
Document ID: 2WFDHR8O

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit