TWS API Linux – Segmentierungsfehler – __bid64_to_stringC++

Programme in C++. Entwicklerforum
Guest
 TWS API Linux – Segmentierungsfehler – __bid64_to_string

Post by Guest »

Cpp-Beispielclient wird sofort ausgeführt.
Ich erhalte einen Segmentierungsfehler.

Code: Select all

0x00005555555efba6 in __bid64_to_string ()
Diese Funktion wurde in die Client-Datei in Decimal.h verschoben

Code: Select all

extern "C" void __bid64_to_string(char*, Decimal, unsigned int*);
Dies hat möglicherweise etwas mit der Gleitkommabibliothek zu tun, die in der API-Dokumentation erwähnt wird: Intel® Decimal Floating-Point Math Library
https://interactivebrokers.github.io/tw ... ction.html
Ich habe mit WSL Ubuntu 20.04.05 überprüft, ob dies auf meiner Ubuntu-Version installiert ist

Code: Select all

libintelrdfpmath-dev/now 2.0u2-4 amd64 [installed,local]

root@flare9x:~# dpkg -s libintelrdfpmath-dev
Package: libintelrdfpmath-dev
Status: install ok installed
Priority: optional
Section: libdevel
Installed-Size: 72286
Maintainer: Ubuntu Developers 
Architecture: amd64
Source: intelrdfpmath
Version: 2.0u2-4
Description: Intel Decimal Floating-Point Math Library
Software implementation of the IEEE 754-2008 Decimal Floating-Point
Arithmetic specification, aimed at financial applications, especially
in cases where legal requirements make it necessary to use decimal, and
not binary floating-point arithmetic (as computation performed with
binary floating-point operations may introduce small, but unacceptable
errors).
Original-Maintainer: Christian Stalp 
Homepage: https://software.intel.com/en-us/articles/intel-decimal-floating-point-math-library

Ein Blick auf das Makefile:

Code: Select all

CXXFLAGS=-pthread -Wall -Wno-switch -Wpedantic -Wno-unused-function -std=c++11
ROOT_DIR=../../../source/cppclient
BASE_SRC_DIR=${ROOT_DIR}/client
INCLUDES=-I${BASE_SRC_DIR} -I${ROOT_DIR}
SHARED_LIB_DIRS=${BASE_SRC_DIR}
SHARD_LIBS=libTwsSocketClient.so
TARGET=TestCppClient

$(TARGET)Static:
$(CXX) $(CXXFLAGS) $(INCLUDES) $(BASE_SRC_DIR)/*.cpp ./*.cpp $(BASE_SRC_DIR)/lib/libbid.a -o$(TARGET)Static

$(TARGET):
$(CXX) $(CXXFLAGS) $(INCLUDES) ./*.cpp $(BASE_SRC_DIR)/lib/libbid.so $(SHARED_LIB_DIRS)/$(SHARD_LIBS) -o$(TARGET)

clean:
rm -f $(TARGET) $(TARGET)Static *.o

Der interessante Teil – ich kann genau den gleichen Code unter Windows kompilieren, VScode in Win32.
Ich habe versucht, 32bit mit gcc zu erzwingen. Hinzufügen von -m32.
Dabei zeigt der Compiler zahlreiche Beschwerden:

Code: Select all

 1974 |  printf("Soft dollar tiers (%lu):", tiers.size());
|                             ~~^     ~~~~~~~~~~~~
|                               |               |
|                               |               std::vector::size_type {aka unsigned int}
|                               long unsigned int
|                             %u
Ich habe diese Funktionen, die %lu enthalten, auskommentiert, da sie in der Hauptanwendung nicht benötigt werden.
Erneut kompilieren, dieses Mal haben wir Fehler mit Bibliotheken, die mit der TWS-API gepackt sind – der Intel-Bibliothek für dezimale Gleitkomma-Mathematik. Diese Bibliotheken werden mit der ursprünglichen TWS-Installation geliefert und finden sich unter:

Code: Select all

/source/cppclient/client/lib/libbid.a

Code: Select all

/usr/bin/ld: i386:x86-64 architecture of input file `../../../source/cppclient/client/lib/libbid.a(bid64_string.o)' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `../../../source/cppclient/client/lib/libbid.a(bid128_2_str_tables.o)' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `../../../source/cppclient/client/lib/libbid.a(bid_decimal_data.o)' is incompatible with i386 output
Win32 führt diesen vscode einwandfrei aus.
läuft mit „gcc -m64“
Seg-Fehler erneut abrufen:

Code: Select all

Thread 1 "TestCppClientSt" received signal SIGSEGV, Segmentation fault.
0x00005555555efba6 in __bid64_to_string ()
(gdb) bt
#0  0x00005555555efba6 in __bid64_to_string ()
#1  0x00007fffffffd940 in ?? ()
#2  0x00007fffffffd940 in ?? ()
#3  0x00007fffffffd940 in ?? ()
#4  0x00007fffffffd941 in ?? ()
#5  0x00007fffffffd940 in ?? ()
#6  0x00007fffffffd820 in ?? ()
#7  0x000055555555d5ff in std::iterator_traits::difference_type std::distance(char*, char*) ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Sie sind sich zu diesem Zeitpunkt nicht sicher, was es sein könnte – WSL und die Ausführung von Ubuntu unter Windows – dieser Prozess verwaltet den Speicher? Kommt es zu Konflikten zwischen Ubuntu und Windows?
Was kann ich an dieser Stelle noch überprüfen/Fehler beheben?
Vielen Dank

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post