IB API C++ topic has several answers, but I haven't been able to identify the needed one. I am struggling to get connected to TWS through C++ API via console. I need no interface, just to get linked on the simplest level.
I am trying the following code:
#include "EWrapper.h"
#include "EClientSocket.h"
#include "textbook_classes_.h"
//in textbook_classes_.h/.cpp I have EWrapper inheritance with
//required funcs overriding,
//those I keep empty (ie:
// void test_EWrapper::tickPrice( TickerId tickerId, TickType field,
// double price, int canAutoExecute) {}
int main()
{
IB::test_EWrapper client;
IB::test_EWrapper* ptr_client = new IB::test_EWrapper(client);
EClientSocket test_socket(ptr_client);
test_socket.eConnect( "", 7497, 0, false); //my port is 7497
delete ptr_client;
ptr_client = nullptr;
return 0;
}
The errors I got compiling:
CMakeFiles\tws_san_.dir/objects.a(main.cpp.obj): In function `main':
C:/Users/solovyev.an/Documents/Cpp/tws_san_/main.cpp:15: undefined
reference to `EClientSocket::EClientSocket(EWrapper*)'
C:/Users/solovyev.an/Documents/Cpp/tws_san_/main.cpp:17: undefined
reference to `EClientSocket::eConnect(char const*, unsigned int, int, bool)'
C:/Users/solovyev.an/Documents/Cpp/tws_san_/main.cpp:15: undefined
reference to `EClientSocket::~EClientSocket()'
C:/Users/solovyev.an/Documents/Cpp/tws_san_/main.cpp:15: undefined
reference to `EClientSocket::~EClientSocket()'
CMakeFiles\tws_san_.dir/objects.a(textbook_classes_.cpp.obj):
In function `ZN2IB13test_EWrapperC2Ev':
C:/Users/solovyev.an/Documents/Cpp/tws_san_/textbook_classes_.cpp:26:
undefined reference to `EClientSocket::EClientSocket(EWrapper*)'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\tws_san_.dir\build.make:123: recipe for target 'tws_san_.exe' failed
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/tws_san_.dir/all' failed
mingw32-make.exe[3]: *** [tws_san_.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles/tws_san_.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/tws_san_.dir/rule] Error 2
CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/tws_san_.dir/rule' failed
Makefile:117: recipe for target 'tws_san_' failed
mingw32-make.exe: *** [tws_san_] Error 2
I appreciate an advise on this very basic thing.
PS
I know there are two quite popular user-developed options for C++ API:
https://github.com/rudimeier/twsapi
https://github.com/JanBoonen/TwsApiCpp
But they don't fly on my Win-machine as well.