JIT and libraries

It is still not clear to me whether you are talking about the statically linked lib or the shared object case here.

Yes, the symbol is present in (the function is called from) the offline compiled part, but as it is a statically linked lib, i do not see how that can help the JIT-ed part to find the symbol. To make the example more concrete:

sc.hint inc();

sc.cc[code]
static int i = 0;

int inc()
{
return ++i;
}[/code]

main.cc[code]#include “sc.h”
#include “cling.h”
#include <stdio.h>

int main()
{
printf(“static inc %d\n”, inc());
char const src =
#include "sc.h"\n”
“int dinc() { return inc(); }\n”;
typedef int dinc(void);
jit::DynamicCompiler* dc = jit::new_compiler(“libtest”); // pass -L. and -lsc to cling::Interpreter
dinc* dip = reinterpret_cast<dinc*>(jit::compile(*dc, src, “dinc”));
printf(“compiled\n”);
if (dip) {
printf(“dynamic inc %d\n”, (*dip)());
printf(“static inc %d\n”, inc());
printf(“dynamic inc %d\n”, (*dip)());
}
delete dc;
}
[/code]

$ gcc -c -o sc.o sc.cc
$ ar rcs libsc.a sc.o
$ g++ ... main.cc cling.cc ... -L. -lsc && ./a.out

static inc 1
compiled
IncrementalExecutor: calling unresolved symbol, see previous error message!
dynamic inc 47754048
static inc 2
IncrementalExecutor: calling unresolved symbol, see previous error message!
dynamic inc 47754048

Previously i had a problem for which this might be the solution: Missing std::string::operator=(std::string&&) – do you mean that referencing e.g. the the std::string move constructor in symbol_requester() would make it available for the JIT-ed code? I’d try it myself, but i can’t wrap my head around what’s going on in that function.