How to include Qt libraries

Hello,

I have successfully compiled Cling on Windows using MinGW. I can run standard C++ code in the interpreter, no problem.

Now lets say I would also like to use the Qt libraries in the interpreter. How can I add them to Cling?

I have added the corresponding header files using the .I command and I have added the shared libraries (dll) using the .L command.

Still when try something like:

[cling]$ QString test;

I get a bunch of:

IncrementalExecutor::executeFunction: symbol ‘__gxx_personality_seh0’ unresolved
while linking function ‘_GLOBAL__sub_I_cling_module_10’!
You are probably missing the definition of __gxx_personality_seh0
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘__imp__ZN7QString11shared_nullE’ u
nresolved while linking function ‘_GLOBAL__sub_I_cling_module_10’!
You are probably missing the definition of __imp__ZN7QString11shared_nullE
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '__imp__ZN7QString4freeEPNS_4DataE’
unresolved while linking function ‘_GLOBAL__sub_I_cling_module_10’!
You are probably missing the definition of __imp__ZN7QString4freeEPNS_4DataE
Maybe you need to load the corresponding shared library?

Any help would be appreciated,

Thnx on advance.

Hi,

Maybe this is what you need: github.com/cptG/qling

Cheers, Bertrand.

Hi,

Thanks for the link. I have found it before and went though its code but it appears that app has been made for quite an old version of both Cling and Qt.

Furthermore I am not looking for embedding Cling in a Qt application, what I want to do is more simple, just use Qt´s classes in the Cling command line interpreter.

J.

Hi,

This is an issue with cling on MingW; it’s not using the right exception handling mechanism.

You’ll have to play with the options for exception handling; either LangOptions or more likely CodegenOptions. I do not have any experience with MingW and exception handling.

Alternatively you might be able to switch exceptions off in the language options.

Cheers, Axel.

Hi,

Thanks for the reply. Why do you think it is due to exception handling? From the output of Cling is seems to be something related to not being able to find symbols. Of course you guys are the experts, but in my limited knowledge I don’t understad what would exceptions have to do with symbols missing.

Or in your experience what would the message “Maybe you need to load the corresponding shared library?” be an indication of?

Thanks for your help.

J.

Hi,

__gxx_personality_seh0 is used by exception handling code. Then again there’s also

sourceforge.net/p/mingw-w64/mail … /31682889/
mail-archive.com/gcc-bugs@g … 15957.html

which point to setup / configuration issues. Hard to tell…

You could start with finding out

  • whether MingW programs should really request this symbol
  • where it’s supposed to be found (libstdc++.so)
  • why cling cannot resolve it (it’s using dlsym through the RuntimeDyLd etc).

Cheers, Axel.

Hi Axel,

Now I understand better, thanks for the links. I will dig into that, will let you know if I find something.

Best,

J.

Hi all,

I managed to solve the issue I was having with my MinGW build. The problem was that initially I was not able to make cling work properly, so I had to apply the patches proposed in:

[url]Cling on windows with VS2013

So Cling original mechanism for looking for symbols did not work form the beginning but only though the patch’s solution of browsing though the nm´s generated table of symbols.

The way I solved it was to compile Cling by linking also the Qt’s libraries *.lib files and passing the ‘whole archive’ flags to the linker, e.g.

-Wl,–whole-archive -lmylib1, -lmylib2, -lmyib2 … -Wl,–no-whole-archive

Now I have no missing symbols!

Nevertheless, there is now a new problem, whenever I include some Qt library classes there is a bunch of warnings releated ot the use of ‘inline’. And as soon as I execute some Qt related code, the app crashes.

I believe this issue is related to this other one:

[url]Cling inline assembly support

My question is if the most recent Cling already supports the inline stuff, or if I need to patch Qt to avoid the use of inline as proposed in other posts?

Thanks you again for your help,

J.

Hi,

First question: what are the error messages you see (all, please)?

Second question: where does cling crash - do you have a backtrace?

Cheers, Axel.