<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Calls from shared object to main app fail if I build with QtCreator]]></title><description><![CDATA[<p dir="auto">Hello to everybody,<br />
something rather strange is happening when I build my c project with QtCreator.<br />
I have this application which links dynamically to a shared library, using ldopen and friends. The library uses some functionality inside the main application. Everything works fine if I build the project from the terminal, while, if I build it with QtCreator,  calling from the library fails, and it fails only if the library's function calls a function inside the main application. If I remove this call, it works as it should.<br />
This is the error I get:<br />
<strong>/Programming/C/emme_1/emme_1: symbol lookup error: ./modtest/libtest_add.so: undefined symbol: pop</strong><br />
This is my .pro file:</p>
<pre><code>TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
QMAKE_CFLAGS += -DTRACE_ASM
QMAKE_CFLAGS += -rdynamic -lm -L/-dl
</code></pre>
<p dir="auto">Thanks for helping.</p>
<p dir="auto">Edit:<br />
System Ubuntu 16.04 QtCreator 3.5.1 based on Qt 5.5.1</p>
]]></description><link>https://forum.qt.io/topic/104445/calls-from-shared-object-to-main-app-fail-if-i-build-with-qtcreator</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Apr 2026 20:26:08 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/104445.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 29 Jun 2019 12:14:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Calls from shared object to main app fail if I build with QtCreator on Sun, 30 Jun 2019 12:34:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/robdanet">@<bdi>RobDaNet</bdi></a><br />
Ok, I solved my problem (actually I got help on SO). Nevertheless, this was a good occasion to register on QtForum ;)</p>
<p dir="auto">This line:</p>
<pre><code>QMAKE_CFLAGS += -rdynamic -lm -L/-dl
</code></pre>
<p dir="auto">should be</p>
<pre><code>QMAKE_LFLAGS += -rdynamic -lm -L/-dl
</code></pre>
]]></description><link>https://forum.qt.io/post/538266</link><guid isPermaLink="true">https://forum.qt.io/post/538266</guid><dc:creator><![CDATA[RobDaNet]]></dc:creator><pubDate>Sun, 30 Jun 2019 12:34:18 GMT</pubDate></item><item><title><![CDATA[Reply to Calls from shared object to main app fail if I build with QtCreator on Sat, 29 Jun 2019 23:25:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> Hi,</p>
<p dir="auto">I call the function via pointer to function, like this:</p>
<pre><code>typedef void (*native_fn)(eVm*);

native_fn load_so(const char* libname, const char* symname)
{
    void* so_library = dlopen(libname, RTLD_LAZY);
    if (so_library == NULL)
    {
        fprintf(stderr, "Error loading %s\n:%s", libname, dlerror());
    }
    else
    {
        void* initializer = dlsym(so_library, symname);
        if (initializer == NULL)
        {
            fprintf(stderr, "Error loading %s.%s:\n%s", libname, symname, dlerror());
        }
        else
        {
            fprintf(stdout, "Loading %s:%s\n", libname, symname);
            native_fn sobj = (native_fn)initializer;
            return sobj;
        }
    }
    return NULL;
}
</code></pre>
<p dir="auto">The function is then stored inside an object's metatable like this:</p>
<pre><code>    ...
    eObject name = eobj_string("addtest");
    eFunction* f = efunction_new(OBJ_AS_CSTR(name), NULL);
    f-&gt;fp = load_so("./modtest/libtest_add.so", "wr_add_test");
    f-&gt;is_native = true;
    eObject func = ((eObject){ EFUNCTION, .value.object=f });
    edict_insert(&amp;vm-&gt;globals,  OBJ_AS_CSTR(name), func);
    ...
</code></pre>
<p dir="auto"><strong>addtest</strong> is the named used to search the function and call it.<br />
Thanks a lot for your help.</p>
]]></description><link>https://forum.qt.io/post/538235</link><guid isPermaLink="true">https://forum.qt.io/post/538235</guid><dc:creator><![CDATA[RobDaNet]]></dc:creator><pubDate>Sat, 29 Jun 2019 23:25:39 GMT</pubDate></item><item><title><![CDATA[Reply to Calls from shared object to main app fail if I build with QtCreator on Sat, 29 Jun 2019 20:47:36 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">That sounds a bit strange. How do you make your library call that function from your main application ?</p>
]]></description><link>https://forum.qt.io/post/538225</link><guid isPermaLink="true">https://forum.qt.io/post/538225</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sat, 29 Jun 2019 20:47:36 GMT</pubDate></item></channel></rss>