Call Function from Dynamic Library

后端 未结 1 1278
不思量自难忘°
不思量自难忘° 2021-01-12 18:53

What would be the best way to, if possible, load a dynamic library and call one of it\'s functions, when we don\'t know the name of the function during compile-time?

1条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-12 19:37

    There is an example on Wikipedia of all places showing how to use the LoadLibrary() function at runtime. You will see that the function name is specified as a string. You would need to write the code to search for the function name and pass it to similar code.

    On Linux you can do this with dlopen() and dlsym() functions.

    0 讨论(0)
提交回复
热议问题