Keyboard Shortcuts
Likes
Search
g++ command for including the proper libraries
I have been trying to use the TWS API directly. I am not looking to use any wrapper that someone has created on GitHub in C++. Can someone direct me to a link on what g++ command to use to include the proper libraries?
Any help is appreciated. Here is my current batch file I have been running unsuccessfully. I get the same thing when trying the -m32 or -m64 flag. I also, have tried linking to TwsSocketClient.dll in the same fashion instead of biddll.dll via the directory "C:\IB_TWS\api\source\CppClient\client\Release" and/or "C:\IB_TWS\api\source\CppClient\lib" for TwsClientSocket.lib and get the same results. The docs say use TwsClientSocket.dll, but my way of doing that does not work. I am on windows here. set twsFull=C:\IB_TWS\api\source\CppClient\client
set twsLib=C:\IB_TWS\api\source\CppClient\client\lib
set twsBid=biddll
set headers=C:\Users\blydo\Repos\Cpp\IBMachLearn\headers
set src=C:\Users\blydo\Repos\Cpp\IBMachLearn\src
set exes=C:\Users\blydo\Repos\Cpp\IBMachLearn\exe
g++ -o %exes%\main.exe %src%\main.cpp -I%headers% -I%twsFull% -I%twsLib% -L%twsLib% -l%twsBid%
Output: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\IB_TWS\api\source\CppClient\client\lib/biddll.lib when searching for -lbiddll C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\IB_TWS\api\source\CppClient\client\lib/biddll.dll when searching for -lbiddll C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\IB_TWS\api\source\CppClient\client\lib/biddll.lib when searching for -lbiddll C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\IB_TWS\api\source\CppClient\client\lib/biddll.dll when searching for -lbiddll C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\IB_TWS\api\source\CppClient\client\lib\biddll.lib when searching for -lbiddll C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lbiddll: No such file or directory C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\IB_TWS\api\source\CppClient\client\lib/biddll.lib when searching for -lbiddll C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\IB_TWS\api\source\CppClient\client\lib/biddll.dll when searching for -lbiddll collect2.exe: error: ld returned 1 exit status |
On Wed, Aug 9, 2023 at 04:32 PM, blydon12@... wrote:
You don't want a fuss but decided against using the de facto standard compiler for your platform? That sounds awfully silly to me... may I suggest you brace for some impact or, perhaps use the MSFT tools. |
I've had no problems using g++ on windows for C++. I am just trying to see if anyone else has tried doing this successfully rather than using TwsApiL0 because I imagine the API was written in C++ to be used directly regardless of compiler or system. Otherwise, what are they doing over at Interactive Brokers? It doesn't make sense to me that I have to use some derivation of the API, and it is strange that everyone on here seems to be settling for that. With that being said, do you have any advice on how to link directly to the TWS API via g++ on windows? Any technical advice would be appreciated.
|
On Wed, Aug 9, 2023 at 06:31 PM, blydon12@... wrote:
Sorry, I haven't used Windows since the early 2000s. |
I am not following your logic here. TWS API is a language independent request/response message protocol that serializes requests made by your client into messages that are sent through a network socket socket to TWS/IBGW and de-serializes any response messages. IBKR provides implementations of this protocol for several programming languages, including C++. So there are no derivatives and I have no idea what you think we are all settling for. All IBKR client facing software (TWS, IBGW, the Client Portal API gateway) is implemented in Java. In V10 of TWS/IBGW and TWS API, the data type for various size/quantity fields was changed from double to a more stable Decimal type. Java, and many other languages, have a built-in Decimal datatype, but C++ does not. IBKR opted to base the C++ TWS API adapter implementation of Decimal on the "Intel? Decimal Floating-Point Math Library", as you probably have read in the . The TWS API release ships with various binary versions of that library, but not all versions for all environments. As your error log suggests, your g++ environment is not happy with the ones it finds. So you have to locate or compile a compatible version yourselves, or use a compile environment that is happy with one of the provided versions. If you search for C++ in our archives, you will find several posts that talk about where you can find a suitable binary version or which open-source version you can use to make your own library.. ´³¨¹°ù²µ±ð²Ô On Wed, Aug 9, 2023 at 01:31 PM, <blydon12@...> wrote: I've had no problems using g++ on windows for C++. I am just trying to see if anyone else has tried doing this successfully rather than using TwsApiL0 because I imagine the API was written in C++ to be used directly regardless of compiler or system. Otherwise, what are they doing over at Interactive Brokers? It doesn't make sense to me that I have to use some derivation of the API, and it is strange that everyone on here seems to be settling for that. With that being said, do you have any advice on how to link directly to the TWS API via g++ on windows? Any technical advice would be appreciated. |
I concur with Jurgen |
Thanks Gordon and Jurgen. I figured out the problem. My mingw64 compiler was using a target architecture of x64, but the TwsSocketClient.dll was built using a x86 or 32-bit architecture. The reason I have chose to go this route is I like using visual studio code rather than visual studio because I find it clunky and I like working from the command line. Makes me feel good about myself. However, all it took in the end was opening up the TestCppClient.sln in Visual Studio and running main.cpp using win32 and magically a command window appeared trying to connect to TWS. It's as if someone recommended that all along...Lol. But, now I think I know the problem for g++, and which library to link. So, I will be installing a mingw32 version with a C++ compiler. I will post the full .bat file I come up that hopefully works based on everyone's recommendations and my own meddling for correctly linking the TwsSocketClient.dll to my project with the proper Client Class inheriting from EWrapper. Hopefully, it could help someone facing the same issues.
Thanks again, Brendan? |