Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling issue on Ubuntu 12.10 #9

Closed
s-l-teichmann opened this issue Oct 28, 2012 · 3 comments
Closed

Compiling issue on Ubuntu 12.10 #9

s-l-teichmann opened this issue Oct 28, 2012 · 3 comments

Comments

@s-l-teichmann
Copy link

Hi!

I'm ran into a compiling issue on Ubuntu 12.10

$ go get github.com/jmhodges/levigo 2

github.com/jmhodges/levigo

1: error: 'leveldb_free' undeclared (first use in this function)
1: note: each undeclared identifier is reported only once for each function it appears in

Package libleveldb-dev is installed (Version: 0+20120530.gitdd0d562-2).
I've got it compiling with the following patch (Don't know if its wise to map leveldb_free() to free()):

diff --git a/db.go b/db.go
index 619582f..9ef217a 100644
--- a/db.go
+++ b/db.go
@@ -5,6 +5,10 @@ package levigo
#include <stdlib.h>
#include "leveldb/c.h"

+#ifndef leveldb_free

  • #define leveldb_free free
    +#endif

// This function exists only to clean up lack-of-const warnings when
// leveldb_approximate_sizes is called from Go-land.
void levigo_leveldb_approximate_sizes(
diff --git a/iterator.go b/iterator.go
index 1b61a38..cb5e246 100644
--- a/iterator.go
+++ b/iterator.go
@@ -1,8 +1,15 @@
package levigo

-// #cgo LDFLAGS: -lleveldb
-// #include <stdlib.h>
-// #include "leveldb/c.h"
+/*
+#cgo LDFLAGS: -lleveldb
+#include <stdlib.h>
+#include "leveldb/c.h"
+
+#ifndef leveldb_free

  • #define leveldb_free free
    +#endif

+*/
import "C"

import (

@jmhodges
Copy link
Owner

Hum, I didn't realize ubuntu 12.10 was still shipping with that old of a leveldb. I'll hack this in and update the README.

@jmhodges
Copy link
Owner

Oh, to explain: LevelDB shipped with a new API that wraps free for better windows support in 1.6.

Also, in the future, I'm not sure that levigo will be supporting these older versions as LevelDB is moving quickly, but I can make it happen for a good while.

@jmhodges
Copy link
Owner

Looks like that patch won't work for more recent users as leveldb_free is not a macro. However, I've made a fork of this repo at https://github.com/jmhodges/levigo_leveldb_1.4 that will support your older leveldb.

Since LevelDB moves so fast, prefer upgrading that, but considering that's more of a high cost for experimentation than I'm willing to impose right now, this fork will be fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants