0

I am on IBM AIX-7.2 and have this sample C++ code:

#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
#include <QtCore/QDateTime>
#include <cstring>
int main(int argc, char *argv[]) {
 QCoreApplication app(argc, argv);
 char const* utf8Str = "Logging output using Qt5Core";
 QString logMe = QString::fromUtf8(utf8Str, std::strlen(utf8Str));
 // Get the current date and time
 QDateTime currentDateTime = QDateTime::currentDateTime();
 // Format the date and time as a string
 QString timeStamp = currentDateTime.toString("yyyy-MM-dd hh:mm:ss.zzz");
 // Output the log message with the time stamp
 qDebug() << "[" << timeStamp << "]" << logMe;
 app.exit();
 return 0;
}

to test with Qt5. However, I always get a run-time error:

 0509-187 The local-exec model was used for thread-local
 storage, but the module is not the main program.
 0509-193 Examine the .loader section header with the
 'dump -Hv' command.

no matter which tls-model option is use for that application. I am using gcc-11 on AIX (unfortunately, I cannot use gnu-ld, but the IBM ld only), and I also tried the different tls-models when compiling QT5 itself from source.

For reference, I checked the manual page of gcc-11, as well as the following hints: about thread local storage IBM guide on tls

I would appreciate any more pointers or hints, as I am out of ideas right now ...

I tried the following (always with -maix64, so 64bit-mode):

  1. provide TLS models via -ftls-model= to the compilation of the app
  2. same for building Qt5 itself
  3. different combinations of -f[no-]pic, -fpie, -fPIC, -f[no-]extern-tls-init
  4. -D_THREAD_SAFE yes/no
  5. -Wl,-bbigtls or -Wl,-bbigtoc
asked Jul 10, 2024 at 8:51
5
  • Please quote the messages before these too, where it states the name of the problematic shared object. Commented Jul 10, 2024 at 9:13
  • ./qlogging exec(): 0509-036 Cannot load program ./qlogging because of the following errors: 0509-150 Dependent module libQt5Cored.so could not be loaded. 0509-187 The local-exec model was used for thread-local storage, but the module is not the main program. (FYI: I stripped the path to libQt5Cored.so) Commented Jul 10, 2024 at 9:42
  • Where does this Qt come from? Have you compiled it from source? Commented Jul 10, 2024 at 13:07
  • Yes, I compiled it from source, also trying different thread-local-storage models along the way, and tried with each of these versions, but without any success, unfortunately. Commented Jul 10, 2024 at 13:20
  • When building QT (or any shared object) use compiler options -DPIC -fPIC -pthread. Commented Jul 18, 2024 at 14:42

1 Answer 1

0

This problem occurs if you compile shared objects without compiler-flags -fPIC -DPIC. Also -pthread flag should be used at every compilation and linkage step.

answered Sep 4, 2024 at 4:19
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.