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

Linking external C library #62

Open
arjunmenon opened this issue Jun 26, 2018 · 1 comment
Open

Linking external C library #62

arjunmenon opened this issue Jun 26, 2018 · 1 comment

Comments

@arjunmenon
Copy link
Contributor

arjunmenon commented Jun 26, 2018

Hey
I am trying to understand correct way to create bindings to any external C libs.

C lib - https://github.com/wooorm/levenshtein.c

rubex file

lib "<levenshtein.h>"
	unsigned int levenshtein(char *a, char *b)
end

class Lev
	def self.distance(a, b)
		return levenshtein(a, b)
	end
end

Error

>:~/Desktop/c/levenshtein.c$ rubex lev.rubex 
creating Makefile

>:~/Desktop/c/levenshtein.c$ cd lev/

>:~/Desktop/c/levenshtein.c/lev$ ruby extconf.rb // added all lib files
creating Makefile

>:~/Desktop/c/levenshtein.c/lev$ make
compiling lev.c
compiling __rubex__common_utils_.c
linking shared-object /home/arjun/Desktop/c/levenshtein.c/lev/lev.so

>:~/Desktop/c/levenshtein.c/lev$ ruby rb_lev.rb 
#<Lev:0x0055a47eb7f868>
ruby: symbol lookup error: /home/arjun/Desktop/c/levenshtein.c/lev/lev.so: undefined symbol: levenshtein

>:~/Desktop/c/levenshtein.c/lev$ ls
extconf.rb  levenshtein.c  lev.h  lev.so    rb_lev.rb                 __rubex__common_utils_.h
lev.c       levenshtein.h  lev.o  Makefile  __rubex__common_utils_.c  __rubex__common_utils_.o

Why am I getting this error?

Rubex - 0.1.2
Ruby 2.3.3

@arjunmenon
Copy link
Contributor Author

Hi
Any updates on this?
Is there any condition on the type of C libs we can link with Rubex?

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

1 participant