Instaling C++ OptoMMP Software Development Kit for SNAP PAC for visual studio


#1

Hi everyone, im trying to use the C++ libraries for OptoMMP on visual studio express 2013. I tried to follow the instructions on page 64 and 66 on the optoMMP manual but i cant find the exe file to install it inside the download I got at opto22 website: http://www.opto22.com/site/downloads/dl_drilldown.aspx?aid=4420

The name of the file missing is : SnapENETDTK_R20a.exe (i guess the version will differ)

Therefore I tried to link the library manually but Im getting a ton of linking errors. (added them at the end)

Here is what I did to manually link the library:

  1. Add #include statements necessary files with declarations/interfaces, e.g.:
    #include"library.h"2) Add an include directory for the compiler to look into
    -> Configuration Properties/VC++ Directories/Include Directories (click and edit, add a new entry)
  2. Add a library directory for *.lib files, I think I did it wrong since the only .lib i can find is inside the output file of the dev kit download called OptoMMPToolkit-Debug.lib
    -> Configuration Properties/VC++ Directories/Library Directories (click and edit, add a new entry)
  3. Link the lib’s *.lib files
    -> Configuration Properties/Linker/Input/Additional Dependencies (e.g.: library.lib;
  4. Place *.dll files either:
    I couldnt find any dll files at the dev kit download.

Thank you very much for the help!

Here is the errors im getting :


Warning    1    warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:LBR' specification    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest\optoTest\OptoMMPToolkit-Debug.lib(O22SIOMM.obj)    optoTest

Error    14    error LNK2019: unresolved external symbol __imp__WSAStartup@8 referenced in function "protected: int __thiscall O22SnapIoMemMap::OpenSockets(char *,int,int)" (?OpenSockets@O22SnapIoMemMap@@IAEHPADHH@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest\optoTest\OptoMMPToolkit-Debug.lib(O22SIOMM.obj)    optoTest

Error    16    error LNK2019: unresolved external symbol __imp__WSAGetLastError@0 referenced in function "protected: int __thiscall O22SnapIoMemMap::CloseSockets(void)" (?CloseSockets@O22SnapIoMemMap@@IAEHXZ)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest\optoTest\OptoMMPToolkit-Debug.lib(O22SIOMM.obj)    optoTest

Error    15    error LNK2019: unresolved external symbol __imp__WSACleanup@0 referenced in function "public: __thiscall O22SnapIoMemMap::~O22SnapIoMemMap(void)" (??1O22SnapIoMemMap@@QAE@XZ)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest\optoTest\OptoMMPToolkit-Debug.lib(O22SIOMM.obj)    optoTest

Error    12    error LNK2019: unresolved external symbol __imp__socket@12 referenced in function "protected: int __thiscall O22SnapIoMemMap::OpenSockets(char *,int,int)" (?OpenSockets@O22SnapIoMemMap@@IAEHPADHH@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest\optoTest\OptoMMPToolkit-Debug.lib(O22SIOMM.obj)    optoTest

Error    11    error LNK2019: unresolved external symbol __imp__send@16 referenced in function "private: int __thiscall O22SnapIoMemMap::ReadBlockEthernet(unsigned int,unsigned short,unsigned char *)" (?ReadBlockEthernet@O22SnapIoMemMap@@AAEHIGPAE@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest\optoTest\OptoMMPToolkit-Debug.lib(O22SIOMM.obj)    optoTest

Error    10    error LNK2019: unresolved external symbol __imp__select@20 referenced in function "public: int __thiscall O22SnapIoMemMap::IsOpenDone(void)" (?IsOpenDone@O22SnapIoMemMap@@QAEHXZ)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest\optoTest\OptoMMPToolkit-
Debug.lib(O22SIOMM.obj)    optoTest

Error    9    error LNK2019: unresolved external symbol __imp__recv@16 referenced in function "private: int __thiscall O22SnapIoMemMap::ReadBlockEthernet(unsigned int,unsigned short,unsigned char *)" (?ReadBlockEthernet@O22SnapIoMemMap@@AAEHIGPAE@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest\optoTest\OptoMMPToolkit-Debug.lib(O22SIOMM.obj)    optoTest

Error    8    error LNK2019: unresolved external symbol __imp__ntohs@4 referenced in function "private: int __thiscall O22SnapIoMemMap::ReadBlockSerial(unsigned int,unsigned short,unsigned char *)" (?ReadBlockSerial@O22SnapIoMemMap@@AAEHIGPAE@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest\optoTest\OptoMMPToolkit-Debug.lib(O22SIOMM.obj)    optoTest

Error    4    error LNK2019: unresolved external symbol __imp__ioctlsocket@12 referenced in function "protected: int __thiscall O22SnapIoMemMap::OpenSockets(char *,int,int)" (?OpenSockets@O22SnapIoMemMap@@IAEHPADHH@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest\optoTest\OptoMMPToolkit-Debug.lib(O22SIOMM.obj)    optoTest

Error    7    error LNK2019: unresolved external symbol __imp__inet_addr@4 referenced in function "protected: int __thiscall O22SnapIoMemMap::OpenSockets(char *,int,int)" (?OpenSockets@O22SnapIoMemMap@@IAEHPADHH@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest\optoTest\OptoMMPToolkit-Debug.lib(O22SIOMM.obj)    optoTest

Error    6    error LNK2019: unresolved external symbol __imp__htons@4 referenced in function "protected: int __thiscall O22SnapIoMemMap::OpenSockets(char *,int,int)" (?OpenSockets@O22SnapIoMemMap@@IAEHPADHH@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest\optoTest\OptoMMPToolkit-Debug.lib(O22SIOMM.obj)    optoTest

Error    5    error LNK2019: unresolved external symbol __imp__htonl@4 referenced in function "private: int __thiscall O22SnapIoMemMap::ReadBlockPassThru(unsigned int,unsigned short,unsigned char *)" (?ReadBlockPassThru@O22SnapIoMemMap@@AAEHIGPAE@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest\optoTest\OptoMMPToolkit-Debug.lib(O22SIOMM.obj)    optoTest

Error    13    error LNK2019: unresolved external symbol __imp__gethostbyname@4 referenced in function "protected: int __thiscall O22SnapIoMemMap::OpenSockets(char *,int,int)" (?OpenSockets@O22SnapIoMemMap@@IAEHPADHH@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest\optoTest\OptoMMPToolkit-Debug.lib(O22SIOMM.obj)    optoTest

Error    3    error LNK2019: unresolved external symbol __imp__connect@12 referenced in function "protected: int __thiscall O22SnapIoMemMap::OpenSockets(char *,int,int)" (?OpenSockets@O22SnapIoMemMap@@IAEHPADHH@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest\optoTest\OptoMMPToolkit-Debug.lib(O22SIOMM.obj)    optoTest

Error    2    error LNK2019: unresolved external symbol __imp__closesocket@4 referenced in function "protected: int __thiscall O22SnapIoMemMap::CloseSockets(void)" (?CloseSockets@O22SnapIoMemMap@@IAEHXZ)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest\optoTest\OptoMMPToolkit-Debug.lib(O22SIOMM.obj)    optoTest

Error    17    error LNK1120: 15 unresolved externals    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest\Debug\optoTest.exe    optoTest





#2

I guess writing this question made me find the first error I was doing, I found the file SnapENETDTK_R20a.exe on the OptoMMP Communication Toolkit on opto22.com I installed that and followed the instructions on page 66 to add the reference to visual studio (these are instruction for visual basic but it allowed me to add it the same way in C++).

Finally I added the C++ OptoMMP Software Development Kit files to the project by doing this:

  1. Add #include “O22SIOMM.h”
  2. Add an include directory for the compiler to look into
    -> Configuration Properties/VC++ Directories/Include Directories (I added the source directory of the c++ optommp soft dev kit)

This allowed me to make an instance of objects from the optoMMP library but when I build the project I get a new set of errors related to linking now the 2028 error instead the 2019:

Error    7    error LNK2028: unresolved token (0A00003A) "public: int __thiscall O22SnapIoMemMap::Close(void)" (?Close@O22SnapIoMemMap@@$$FQAEHXZ) referenced in function "void __cdecl cleanUp(class O22SnapIoMemMap *)" (?cleanUp@@$$FYAXPAVO22SnapIoMemMap@@@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest2\optoTest2\optoTest2.obj    optoTest2
Error    6    error LNK2028: unresolved token (0A000038) "public: int __thiscall O22SnapIoMemMap::SetDigPtState(int,int)" (?SetDigPtState@O22SnapIoMemMap@@$$FQAEHHH@Z) referenced in function "void __cdecl `anonymous namespace'::SetDigitalPointState(class O22SnapIoMemMap &,int,int,char const *)" (?SetDigitalPointState@?A0x5a1bb5f3@@$$FYAXAAVO22SnapIoMemMap@@HHPBD@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest2\optoTest2\optoTest2.obj    optoTest2

Error    5    error LNK2028: unresolved token (0A000035) "public: __thiscall O22SnapIoMemMap::O22SnapIoMemMap(void)" (??0O22SnapIoMemMap@@$$FQAE@XZ) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest2\optoTest2\optoTest2.obj    optoTest2

Error    4    error LNK2028: unresolved token (0A000034) "public: __thiscall O22SnapIoMemMap::~O22SnapIoMemMap(void)" (??1O22SnapIoMemMap@@$$FQAE@XZ) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest2\optoTest2\optoTest2.obj    optoTest2

Error    3    error LNK2028: unresolved token (0A000031) "public: int __thiscall O22SnapIoMemMap::OpenEnet2(char *,int,int,int,int)" (?OpenEnet2@O22SnapIoMemMap@@$$FQAEHPADHHHH@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest2\optoTest2\optoTest2.obj    
optoTest2

Error    2    error LNK2028: unresolved token (0A00002F) "public: int __thiscall O22SnapIoMemMap::IsOpenDone(void)" (?IsOpenDone@O22SnapIoMemMap@@$$FQAEHXZ) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest2\optoTest2\optoTest2.obj    optoTest2

Error    1    error LNK2028: unresolved token (0A00002E) "public: int __thiscall O22SnapIoMemMap::ConfigurePoint(int,int)" (?ConfigurePoint@O22SnapIoMemMap@@$$FQAEHHH@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest2\optoTest2\optoTest2.obj    optoTest2

Error    9    error LNK2019: unresolved external symbol "public: int __thiscall O22SnapIoMemMap::SetDigPtState(int,int)" (?SetDigPtState@O22SnapIoMemMap@@$$FQAEHHH@Z) referenced in function "void __cdecl `anonymous namespace'::SetDigitalPointState(class O22SnapIoMemMap &,int,int,char const *)" (?SetDigitalPointState@?A0x5a1bb5f3@@$$FYAXAAVO22SnapIoMemMap@@HHPBD@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest2\optoTest2\optoTest2.obj    optoTest2

Error    11    error LNK2019: unresolved external symbol "public: int __thiscall O22SnapIoMemMap::OpenEnet2(char *,int,int,int,int)" (?OpenEnet2@O22SnapIoMemMap@@$$FQAEHPADHHHH@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest2\optoTest2\optoTest2.obj    optoTest2

Error    12    error LNK2019: unresolved external symbol "public: int __thiscall O22SnapIoMemMap::IsOpenDone(void)" (?IsOpenDone@O22SnapIoMemMap@@$$FQAEHXZ) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest2\optoTest2\optoTest2.obj    optoTest2

Error    13    error LNK2019: unresolved external symbol "public: int __thiscall O22SnapIoMemMap::ConfigurePoint(int,int)" (?ConfigurePoint@O22SnapIoMemMap@@$$FQAEHHH@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest2\optoTest2\optoTest2.obj    optoTest2

Error    8    error LNK2019: unresolved external symbol "public: int __thiscall O22SnapIoMemMap::Close(void)" (?Close@O22SnapIoMemMap@@$$FQAEHXZ) referenced in function "void __cdecl cleanUp(class O22SnapIoMemMap *)" (?cleanUp@@$$FYAXPAVO22SnapIoMemMap@@@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest2\optoTest2\optoTest2.obj    optoTest2

Error    10    error LNK2019: unresolved external symbol "public: __thiscall O22SnapIoMemMap::O22SnapIoMemMap(void)" (??0O22SnapIoMemMap@@$$FQAE@XZ) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest2\optoTest2\optoTest2.obj    optoTest2

Error    14    error LNK2019: unresolved external symbol "public: __thiscall O22SnapIoMemMap::~O22SnapIoMemMap(void)" (??1O22SnapIoMemMap@@$$FQAE@XZ) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest2\optoTest2\optoTest2.obj    optoTest2

Error    15    error LNK1120: 14 unresolved externals    C:\Dropbox (Perez Larios)\AutomaticInspection\Pruebas\optoPruebas\optoTest2\Debug\optoTest2.exe    optoTest2




#4

I would like to use C++ to communicate with Opto22.
But, I cannot even make cpp, vba, samples from the kit to work.
Could anyone post simplest working C++ code to read and write to scratch-pad?


#5

I finally got C++ Learningcenter.exe SDK to work.
After editing some target path settings on visual studio 2015.

But, what I want to actually do is, add code to read scratch pad integer table.
I do not know exactly how to do that yet.

I saw the following code on documentation. I do not know if this is the right one.

int O22SnapIoMemMap::GetScratchPadIntegerArea	(int 	nStartIndex,
                                                 int 	nLength,
                                                 int * 	pnData 
)

#6

Yes, you can use that to read the scratch pad area. Don’t forget our support is free, best to email your questions to: support@opto22.com