¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

build problem with cppclient


 

Building sources unzipped from twsapi_macunix.1019.01.zip yields the following error:

:: make
g++ -pthread -Wall -Wno-switch -Wno-unused-function -std=c++11 -shared? -I. ./*.cpp lib/libbid.so -olibTwsSocketClient.so
/usr/bin/ld: lib/libbid.so:cygming-crtbeg:(.data+0x0): multiple definition of `__dso_handle'; /usr/lib/gcc/x86_64-linux-gnu/12/crtbeginS.o:(.data.rel.local+0x0): first defined here
/usr/bin/ld: libTwsSocketClient.so: unable to sort relocs - they are of an unknown size
collect2: error: ld returned 1 exit status
make: *** [makefile:9: libTwsSocketClient.so] Error 1

I'm building on ubuntu lunar lobster with g++ 12.2.0

Has anyone compiled the cppclient successfully?

Bill Rees


 

Yes, I just tried building the TestCppClient in a KVM running Ubuntu 23.04 w/ g++ 12.2.0 and was able to get ./TestCppClientStatic built successfully without any errors. I ran it and watched it complain that it couldn't connect to TWS/IBGW, but that's it. I didn't do any testing beyond that.

HOWEVER... I was getting the dreaded dangerous relocation: collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped error until I remembered this.

So... I needed to apt install libintelrdfpmath-dev and change the makefile to use -lbidgcc000 instead of the library IB provides (libbid).

For whatever reason, IB is distributing their own version of the big decimal library and apparently it's not compatible with the ld provided by lunar lobster. I don't know any more details and would love to hear from those who do.

Anyway, I understand the error you're getting isn't the exact same so all I can say is "works for me; partially". They both look like relocation errors though... perhaps you can run with this information.

All this aside, trying to stay so close to the bleeding edge may be asking for trouble. The reason IB distributes their own version of big decimal may actually effect things; perhaps they've patched it somehow. And, there could also be incompatibilities with lunar lobster (which is not an LTS, but interim release).

If you are comfortable playing with this kind of fire, be my guest... you're a braver (or perhaps more hardworking) developer than I. I'm not sure that it's wise though.

?°À³å(¥Ä)³å/?


 

Btw, searching around revealed where the same failed binutils assertion yielded a dangerous relocation and linker core dump. It certainly seems the problem is due to linking intermediate object files created with different binutils. I agree with the github comment that says:

This is not worth anyone's time. Just compile both sides for the same target triple and avoid the whole thing.

Fwiw, IDK why the IB SDK is distributing a pre-built library (either .a or .so). The only reason I can fathom is that they've modified the reference implementation but this strikes me as unlikely. Anyway...

This is not best practice as far as I know, C/C++ is not "write once run anywhere". IMHO they should include the source (but this would complicate the makefile a bit). Or they should instruct the user to use either... their own system packages or build the stuff from Intel.

Maybe they'll do this in the future but beware for now.


 

On Wed, Jun 14, 2023 at 08:51 AM, buddy wrote:

with different binutils

Sorry... this should read different compilers, not binutils.


 

Thank you all for your help and information.

I tried the mods to compilation, packages, makefiles mentioned without any change in the outcome.

In fact it looks like the library is not a shared object at all

??? :: file !$
??? file lib/libbid.so
??? lib/libbid.so: PE32+ executable (DLL) (console) x86-64, for MS Windows, 18 sections


:: ldd lib/libbid.so
?? ?not a dynamic executable

Looking at the elf file header shows there is no header
??? :: elfedit --input-mach x86_64 --output-mach x86_64 --input-type dyn --output-type dyn lib/libbid.so
??? elfedit: Error: lib/libbid.so: Failed to read ELF header


I'm now at best confused because lib/libbid.so seems to be a windows dll according to the file command. Certainly it is not a linkable shared object.


So, if anyone has successfully compiled and run the cppclient would you please examine your lib/libbid.so and see if you see the same data?


 

Yes, that's right. I'm guessing you didn't change what you thought you changed. Here's a step by step if you want to try again:

  • install the system package via sudo apt install libintelrdfpmath-dev
  • cd to the sample directory... IBJts/samples/Cpp/TestCppClient
  • in there edit the makefile so that it's using /usr/lib/x86_64-linux-gnu/libbidgcc000.a instead of libbid.a. That is, you should replace the option for libbid.a with -lbidgcc000. If you don't feel like taking chances with your typing use this patch:

    --- makefile.~1~	2022-10-03 11:50:16.000000000 +0000
    +++ makefile	2023-06-17 01:41:46.332638125 +0000
    @@ -8,7 +8,7 @@
    TARGET=TestCppClient
     
    $(TARGET)Static:
    -	$(CXX) $(CXXFLAGS) $(INCLUDES) $(BASE_SRC_DIR)/*.cpp ./*.cpp $(BASE_SRC_DIR)/lib/libbid.a -o$(TARGET)Static
    +	$(CXX) $(CXXFLAGS) $(INCLUDES) $(BASE_SRC_DIR)/*.cpp ./*.cpp -lbidgcc000 -o$(TARGET)Static
     
    $(TARGET):
    	$(CXX) $(CXXFLAGS) $(INCLUDES) ./*.cpp $(BASE_SRC_DIR)/lib/libbid.so $(SHARED_LIB_DIRS)/$(SHARD_LIBS) -o$(TARGET)
    
  • then insure everything's clean with make clean

  • finally build the static version of the sample with make

  • view the docs? zcat /usr/share/doc/libintelrdfpmath-dev/README.gz

Or, as someone else suggested in the other thread, you can build the Intel sources directly (I won't outline that process).

That should get you started. Are you using Windows System for Linux or something? Not sure what to say then... I don't use it. Maybe someone else can help you troubleshoot if that's the case.

Good luck.


 

Sorry, the previous patch got malformed during copy & paste... assuming the groups.io preview function works, the one below should be used with instead.

--- makefile.~1~	2022-10-03 11:50:16.000000000 +0000
+++ makefile	2023-06-17 02:37:00.264457603 +0000
@@ -8,7 +8,7 @@
 TARGET=TestCppClient
 
 $(TARGET)Static:
-	$(CXX) $(CXXFLAGS) $(INCLUDES) $(BASE_SRC_DIR)/*.cpp ./*.cpp $(BASE_SRC_DIR)/lib/libbid.a -o$(TARGET)Static
+	$(CXX) $(CXXFLAGS) $(INCLUDES) $(BASE_SRC_DIR)/*.cpp ./*.cpp -lbidgcc000 -o$(TARGET)Static
 
 $(TARGET):
 	$(CXX) $(CXXFLAGS) $(INCLUDES) ./*.cpp $(BASE_SRC_DIR)/lib/libbid.so $(SHARED_LIB_DIRS)/$(SHARD_LIBS) -o$(TARGET)


 

Thank you buddy;

??? I had messed up your first set of instructions because I wasn't paying attention.

??? I am able to build and run TestCppClientStatic

??? I've also placed these files into a repo of mine: redorca/tws-api-public branch CompilesOnLinux

Bill