dlopen on new binary with same name returns old handle
I'm using dlopen to load dynamically generated code. The program calls the compiler on the code and generates a .so file which is then loaded by the program to extend itself. The problem is that if I use the same name for the generated code, the dlopen returns a handle to the old object, not the new one. The code looks like: …generate code into test.cpp system("gcc <args> test.cpp -o test.so"); void *handle = dlopen("test.so"); void *sym = dlsym(handle, "run"); (*sym)(); dlclose(handle); …Do other work …generate different code to test.cpp system("gcc <args> test.cpp -o test.so"); void *handle