dlsym 命令可以从 .h 文件生成吗?
Can dlsym commands be generated from a .h file?
已经解决了! 在此处查看结果。
不确定我是否在正确的地方询问,但是有谁知道基于 .h 文件生成 dlopen 和 dlsym 命令的正确方法?
我正在尝试动态加载 SDL2 - 这是一个用 C 编写的库 - 但所有提取函数列表及其带有 ctag 的参数的方法似乎都是徒劳的(必须手动更正 240 个函数中的 3500 个函数的参数列表并不好玩(。
ctags -R -x --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ -f sdl /usr/include/SDL2/
ctags 的结果如下所示:
extern DECLSPEC int SDLCALL SDL_SetTextureColorMod (SDL_Texture * texture,
extern DECLSPEC int SDLCALL SDL_SetThreadPriority (SDL_ThreadPriority priority);
extern DECLSPEC void SDLCALL SDL_SetWindowBordered (SDL_Window * window,
这:
ctags -R -x --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ -f sdl /usr/include/SDL2/ | grep "SDL_AddTimer"
产生这种结果:
SDL_AddTimer prototype 93 /usr/include/SDL2/SDL_timer.h extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval,
请注意间隔后缺少的参数。它坏了。
我也看到这是一件事情,它显然是自动生成的,而不是手工制作的。
那么......有谁知道有什么方法可以自动生成类似的东西?特别是对于 SDL2?
还是我应该只使用 SDL 函数,然后手动 dlsym?不要问为什么我不愿意只链接而不是使用 dlopen 和 dlsym。
我通过使用decltype解决了这个问题。
typedef decltype(SDL_RenderDrawRects)* PF_SDL_RenderDrawRects;
这样,我将不需要函数的参数列表。包装器可在此处找到。
相关文章:
- 如何使 windows 命令提示符在C++可执行文件上显示返回值?
- g++ -I 和 -L 命令来查找不起作用的 .hpp 文件
- 使用 Powershell 命令将 cpp 文件的文件夹编译为 GNU 的 g++
- 通过命令行在Visual Studio中编译单个独立文件
- 如何使用命令提示符、记事本和 MinGW 使用主文件、头文件和实现文件编译C++程序?
- 是否可以在命令行中将输入参数传递给可执行文件
- CMake 错误:链接器命令失败,退出代码为 1 和 cpp.o 文件
- 如何从命令行使用 cmake 为有根的安卓设备制作可执行文件?
- 使用 MinGW 在 Windows 上的命令行编译C++文件
- 程序运行,但文件无法打开.C++中的命令行
- 是否有正确的方法对生成文件中的对象文件使用模板命令?(C++)
- make 命令创建 .file,但不创建应用程序文件
- 如何在 vscode 扩展名中检索 C/C++ 文件的编译命令
- clang 交叉编译命令找不到头文件
- 使用重定向命令从 stdin 读入的字符串"<"输入文件未正确附加
- 为什么文件命令声明可执行文件包含"debug_info"
- 使用提升程序选项通过配置文件/命令行解析自定义对象
- 将 -m32 参数添加到生成文件命令
- MSI 文件命令行参数解析
- C++中的批处理文件命令