Thu 11 Apr 2013 03:11:22 AM UTC, comment #1: I plan to push the following fix, soon as svn lets me ...
Index: src/guile-dbi.c
===================================================================
--- src/guile-dbi.c (revision 141)
+++ src/guile-dbi.c (working copy)
@@ -40,6 +40,7 @@
#define FUNC_NAME s_make_g_db_handle
{
char* sodbd = NULL;
+ size_t sodbd_len;
gdbi_db_handle_t *g_db_handle = NULL;
void (connect)(gdbi_db_handle_t );
@@ -58,16 +59,23 @@
g_db_handle->bcknd_str = scm_to_locale_string (bcknd);
g_db_handle->bcknd_strlen = strlen(g_db_handle->bcknd_str);
- sodbd = (char) malloc (sizeof(char) (strlen("libguile-dbd-") +
- g_db_handle->bcknd_strlen + 10));
+ /* The +20 allos for .so or .dylib on MacOS */
+ sodbd_len = sizeof(char) * (strlen("libguile-dbd-") +
+ g_db_handle->bcknd_strlen + 20);
+ sodbd = (char*) malloc (sodbd_len);
if (sodbd == NULL)
{
g_db_handle->status = scm_cons(scm_from_int(errno),
scm_makfrom0str(strerror(errno)));
SCM_RETURN_NEWSMOB (g_db_handle_tag, g_db_handle);
}
- sprintf(sodbd, "libguile-dbd-%s.so", g_db_handle->bcknd_str);
+#ifdef _APPLE_
+ snprintf(sodbd, sodbd_len, "libguile-dbd-%s.dylib", g_db_handle->bcknd_str);
+#else
+ snprintf(sodbd, sodbd_len, "libguile-dbd-%s.so", g_db_handle->bcknd_str);
+#endif
+
g_db_handle->handle = dlopen(sodbd, RTLD_NOW);
if (g_db_handle->handle == NULL)
{
Tue 21 Feb 2012 04:38:06 PM UTC, original submission: Using guile-dbi 2.1.4 and guile-dbd-sqlite3 2.1.4 I get the following error whenever I try to run the script "test-guile-dbd-sqlite3.scm" provided with guile-dbd-sqlite3:
The apparent reason is that in guile-dbi 2.1.4 the file src/guile-dbi.c contains the line
which hardcodes the extension ".so" while under Mac OS X the standard extension for dynamic libraries is ".dylib". Modifying the call to "sprintf" makes the code work (but probably one would modify the call to "malloc" which allocates room for "sodbd" in order to take into account the different length of the two extensions).