moai / luamongo

Lua driver for mongodb
https://github.com/moai/luamongo
MIT License
170 stars 58 forks source link

Error using mongo.so #12

Closed GuillaumeMar closed 12 years ago

GuillaumeMar commented 12 years ago

Hi all,

I am a newbie in lua language and I'm trying to install this lua driver for mongodb, but I got some problems once its compiled.

http://pastebin.com/2Yh03jzQ

Did I missed sth?

Thx in advance Guillaume.

larubbio commented 12 years ago

There might be an issue with one of the pull requests I recently integrated. Can you try this revision f46815e2e7db899ec75754370f57babc8c61843d if you are stuck. I'll look into fixing or reverting this shortly

Also I notice you are using Mongo1.8. I've compiled and used the driver with Mongo2.0. If you are just starting out can you try it with that version.

neomantra commented 12 years ago

Guillaume,

The latest tip works for me with 1.8. Can you paste your build log?

That symbol is the vtable for the DBClientConnection class. $ echo _ZTVN5mongo18DBClientConnectionE | c++filt vtable for mongo::DBClientConnection

I actually see that symbol as undefined in my libmongoclient.a, but I'm able to load it just fine. BTW, a quick test is this, which starts the Lua shell with the 'mongo' library already required. $ lua -l mongo

What does "ldd /usr/lib/lua/5.1/mongo.so" return?

GuillaumeMar commented 12 years ago

Thx for your reply :)

I recompile but have the same error : http://pastebin.com/GRxqWedC

I am using mongodb-src-r2.0.2 and this C client module : https://github.com/mongodb/mongo-c-driver

neomantra commented 12 years ago

OK, that's very curious... did you go into the Makefile and change -lmongoclient to -lmongoc? [In general, when looking for help you should note what you've changed.]

Those are two totally different libraries with different interfaces. One is mongodb's C++ client library (libmongoclient) and the other is the C library. luamongo wraps the C++ library. When you built luamongo, it was finding the headers for the C++ library, but linking against the C library. This will never work.

So, if you were having problems building and linking against the mongodb C++ library, that's a whole different matter.

If you want to use the C client module for whatever reason and are into LuaJIT, check out mongolua (which I wrote). It is a different approach to interfacing Lua to mongo. However, I think I'm the only person in the world who uses it :P https://bitbucket.org/neomantra/mongolua

GuillaumeMar commented 12 years ago

All my fault sorry... I thought it was using the C library... Now it's works fine.

Thank you guys, maybe I will use your mongolua in C :)