How to dynamically load often re-generated c code quickly?

前端 未结 4 1858
遥遥无期
遥遥无期 2020-12-01 17:00

I want to be able to generate C code dynamically and re-load it quickly into my running C program.

I am on Linux, how could this be done?

Can a library .so f

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-01 18:02

    If you want to reload a library dynamically, you can use dlopen function (see mans). It opens a library .so file and returns a void* pointer to it, then you can get a pointer to any function/variable of your library with dlsym.

    To compile your libraries in-memory, well, the best thing I think you can do is creating memory filesystem as described here.

提交回复
热议问题