Visual C++ Project setting



 
Create a new project with the File®New... command of  "Win32 Console" type. Let's name this project: SimpleOPCClient.

Add the following two folders to your project (in the FileView click on "SimpleOPCClient" with the right mouse button): 
  • Source files, to put .cpp files
  • Header files, to put .h files
  • IDL files, to put .idl files

With the File Explorer add subfolders Source files, Include and IDL files to the folder of your project. 
Add OPC.idl file in the "IDL files" file system folder. 
Add OPC.idl in the "IDL files" project folder (in the FileView click on "IDL files" with the right mouse button) .
 

Now we have to adjust the project setting. Go in Project setting (menu Project®Setting...). 
  • Select SimpleOPCClient in the left part of the frame.
  • Select the tab "C/C++".
  • Select the Category General.
  • In the "Preprocessor definitions", replace _MBSTR by _UNICODE and add _WIN32_DCOM .
  • In "Additional include directorie(s)" box add:
    • .\Include

  • Still in Project setting dialog box, select OPC.idl in the left part of the frame.
  • Select Custom Build tab.
  • insert the following command line in the Build command(s) box:
    • midl /Oicf /h "OPC.h"  /out .\Include ".\IDL files\OPC.idl"
    This is the command to compile OPC.idl. The resulting files are OPC.h and OPC_i.c. 
  • add the following file names into the Output file(s) box:
    • .\Include\OPC.h 
      .\Include\OPC_i.c


The project setting is now finished. You can build your program. The building should  work.