I am having many difficulties with the C++ API in Linux. Most of this probably due to my lack of knowledge with the new DLL files.
Using my old setup: g++ -o test test.cpp -lokFrontPanel -lusb
The following code segfaults:
okCUsbFrontPanel* target = new okCUsbFrontPanel;
This code also segfaults;
The errors seemed to point to improper initialization and cleanup (using an invalid pointer to free memory).
I looked in the documentation and found a C++ example (pg 23) similar to that above and found another example (pg 27) that uses the following (which does in fact work):
xem = okUsbFrontPanel_Construct();
Digging around in the DLL files I find that the standard constructor okCUsbFrontPanel() calls the okUsbFrontPanel_Construct() so I am assuming either way should work?
Now, if I compile the DLL files into an object file and include this in my project, leaving out the okFrontPanel.so library (and adding libdl), everything seems to work just fine (assuming you have the okFrontPanel.so in the local directory and load/unload the library as needed).
So can someone tell me, what is the proper method for writing a C++ application to communicate with the FPGA? I don’t like the _Construct() _Destruct() stuff because I typically use smart pointers to handle allocation and this requires writing my own which defeats the purpose of using one in the first place.