使用vala中的sqlite而不依赖于glib
我需要使用 Sqlite vapi,而不依赖于 GLib。 SQlite 是非 gobject 库,因此应该可以做到这一点。
但是,当我尝试使用 --profile posix
编译以下文件时 选项,
using Sqlite;
void main() {
stdout.printf("Hello, World!");
}
我收到错误消息:
sqlite3.vapi:357.56-357.59: error: The symbol `GLib' could not be found
public int bind_blob (int index, void* value, int n,
GLib.DestroyNotify destroy_notify);
^^^^
sqlite3.vapi:362.68-362.71: error: The symbol `GLib' could not be found
public int bind_text (int index, owned string value, int n = -1,
GLib.DestroyNotify destroy_notify = GLib.g_free);
^^^^
sqlite3.vapi:411.42-411.45: error: The symbol `GLib' could not be found
public void result_blob (uint8[] data, GLib.DestroyNotify?
destroy_notify = GLib.g_free);
^^^^
sqlite3.vapi:420.59-420.62: error: The symbol `GLib' could not be found
public void result_text (string value, int length = -1,
GLib.DestroyNotify? destroy_notify = GLib.g_free);
^^^^
Compilation failed: 4 error(s), 0 warning(s)
似乎 sqlite vapi 中定义的几个函数引用了 GLib.g_free 和 GLib.DestroyNotify 符号。有没有 posix 的替代品?
I need to use the Sqlite vapi without any depedence on GLib. SQlite is non-gobject library, so it should be possible to do that.
However, when I try to compile the following file with the --profile posix
option,
using Sqlite;
void main() {
stdout.printf("Hello, World!");
}
I get am error messages:
sqlite3.vapi:357.56-357.59: error: The symbol `GLib' could not be found
public int bind_blob (int index, void* value, int n,
GLib.DestroyNotify destroy_notify);
^^^^
sqlite3.vapi:362.68-362.71: error: The symbol `GLib' could not be found
public int bind_text (int index, owned string value, int n = -1,
GLib.DestroyNotify destroy_notify = GLib.g_free);
^^^^
sqlite3.vapi:411.42-411.45: error: The symbol `GLib' could not be found
public void result_blob (uint8[] data, GLib.DestroyNotify?
destroy_notify = GLib.g_free);
^^^^
sqlite3.vapi:420.59-420.62: error: The symbol `GLib' could not be found
public void result_text (string value, int length = -1,
GLib.DestroyNotify? destroy_notify = GLib.g_free);
^^^^
Compilation failed: 4 error(s), 0 warning(s)
It seems that several of the functions defined in the sqlite vapi make references to the GLib.g_free
and GLib.DestroyNotify
symbols. Are there any posix alternatives to those?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这应该很容易解决,我可以想象几种解决方案。
它归结为声明一个不同的委托 void DestroyNotify (void* data) (在 posix.vapi 或 sqlite3.vapi 中)并在 posix.vapi 中绑定 free() 。
问题在于命名空间,您可能需要提交错误并与开发人员讨论。如果您想避免此问题并准备好采用解决方法,只需创建一个迷你 glib.vapi GLib 命名空间,在其中仅绑定 DestroyNotify() 和 g_free() (绑定到 libc/posix free)。
我认为 sqlite3 不应该使用 GLib,而应该使用 libc/posix,所以你应该只修改 posix.vapi 和 sqlite3.vapi 并用你的补丁提交一个错误(太棒了,一个贡献!)。
That should be fairly simple to solve, and I can imagine several solutions.
It boils down to declaring a different delegate void DestroyNotify (void* data) (either in the posix.vapi or sqlite3.vapi) and bind free() in posix.vapi.
The problem is the namespace, and you might need to file a bug and discuss it with the developers. If you want to avoid this problem and are ready to go with a workaround, just create a mini glib.vapi GLib namespace, where you bind only the DestroyNotify() and g_free() (binding to libc/posix free).
I would think that sqlite3 should not use GLib, but rather libc/posix, so you should be fine by modifying only posix.vapi and sqlite3.vapi and filing a bug with your patch (awesome, a contrib!).
请注意,类在 POSIX 配置文件下不可用,因为 Vala 需要支持库(即 GLib、Dova)来支持这些功能。 Jürg Billeter 承认对 POSIX 配置文件的支持是实验性的且有限:
https://bugzilla。 gnome.org/show_bug.cgi?id=618348
Note that classes are unavailable under the POSIX profile, as Vala requires a support library (i.e. GLib, Dova) to support those features. Jürg Billeter has acknowledged that support for the POSIX profile is experimental and limited:
https://bugzilla.gnome.org/show_bug.cgi?id=618348
你唯一的方法是重写 sqlite VAPI(或者只是你需要的类/方法),使它们对 posix 友好(但我想你不能以这种方式使用类)。
The only way you have is re-writing the sqlite VAPI (or just the classes/methods you need) making them posix friendly (but I guess you can't use classes in that way).
如果 sqlite 的 vapi 依赖于 glib,您可以编写自己的代码或使用 sqlite c 代码与 c 并为您需要的函数创建一些 extern 语句。例如,我制作了一个工具,混合了用于linux的vala和c、用于win32的纯c以及用于mac的objective c和c
https://github.com/boscowitch/wadoku-notify
我刚刚在我的vala应用程序的开头添加了我需要的2个功能,如下所示:
我添加了整个sqlite源代码,因为我需要激活全文索引并在代码中进行一些更改,并且在vala的开头没有sqlite vapi
if the vapi for sqlite depends on glib you could just write your own or use the sqlite c code with c and just make some extern statements for the functions you need. for example i made a tool wich mixes vala and c for linux pure c for win32 and objective c and c for mac
https://github.com/boscowitch/wadoku-notify
i just added the 2 functions i need at the beginning of my vala app like this:
i added the whole sqlite source cause i needed to activate full text indexing and change a bit in the code and in the beginning of vala there was no sqlite vapi