ScottPJones / LibBSON.jl

libbson bindings for the Julia programming language
Other
9 stars 16 forks source link

Add a build process under Windows #3

Open jebej opened 9 years ago

jebej commented 9 years ago

Would it be possible to add support for Windows?

I am not sure how to go about this but am willing to help.

jebej commented 9 years ago

Note: It seems that building the mongo-c-driver should build the libbson dlls too, maybe that would be a simpler path since the goal is really to get Mongo.jl working on Windows.

ghost commented 9 years ago

Hi, yes it would be nice to have support for Windows. If you have patches to make it work I would be happy to merge them in!

jebej commented 9 years ago

I tried looking at BinDeps but am still not sure exactly what is required to get the compilation to work on Windows, could you point me to some references?

ghost commented 9 years ago

To be honest I haven't explored the Windows side of things at all -- I'm on OS X myself. I would start by exploring the code in some of the other Julia packages that already work on Windows that are using external libraries, the source is available to all of them!

ivborissov commented 6 years ago

Hi, I have manually installed C-driver (with libbson dll) on my Windows machine but how can I use it with the package?

jebej commented 6 years ago

Go in the deps.jl file and manually enter the DLL location.

ivborissov commented 6 years ago

Thanks. I have added deps file with the following content for libBSON and Mongo but Julia can't load the library.

libBSON deps:

# This is an auto-generated file; do not edit
# Pre-hooks
# Macro to load a library
macro checked_lib(libname, path)
    ((VERSION >= v"0.4.0-dev+3844" ? Base.Libdl.dlopen_e : Base.dlopen_e)(path) == C_NULL) && error("Unable to load \n\n$libname ($path)\n\nPlease re-run Pkg.build(package), and restart Julia.")
    quote const $(esc(libname)) = $path end
end
# Load dependencies
@checked_lib libbson "C:\\Julia\\v0.6\\LibBSON\\mongo-c-driver\\bin\\libbson-1.0.dll"
# Load-hooks

Mongo deps:

# This is an auto-generated file; do not edit
# Pre-hooks
# Macro to load a library
macro checked_lib(libname, path)
    ((VERSION >= v"0.4.0-dev+3844" ? Base.Libdl.dlopen_e : Base.dlopen_e)(path) == C_NULL) && error("Unable to load \n\n$libname ($path)\n\nPlease re-run Pkg.build(package), and restart Julia.")
    quote const $(esc(libname)) = $path end
end
# Load dependencies
@checked_lib libmongoc "C:\\Julia\\v0.6\\Mongo\\mongo-c-driver\\bin\\libmongoc-1.0.dll"
# Load-hooks
julia> using Mongo, libBSON
ERROR: LoadError: LoadError: Unable to load
libmongoc (C:\Julia\v0.6\Mongo\mongo-c-driver\bin\libmongoc-1.0.dll)
Please re-run Pkg.build(package), and restart Julia.
ivborissov commented 6 years ago

@jebej Have you successfully used this package in Windows?

jebej commented 6 years ago

I have. What did you compile the DLLs with? Did the tests pass? You might be missing a Windows runtime DLL.

What I would try would be to copy the test executables in your mongo-c-driver\bin and executing them from there to see if they work. This will tell you if you are missing DLLs. If you are missing DLLs, copy them in that folder.

Once that's done, if it still doesn't work, you can add that bin folder to the Windows PATH.

Make sure you restart the shell your are using after changing the path and try again. This is what I get: (i.e. no errors)

julia> Base.Libdl.dlopen("libmongoc-1.0.dll")
Ptr{Void} @0x000007fef5790000
ivborissov commented 6 years ago

@jebej thanks a lot for support! I have recompiled the last version of mongo-c driver following the guide http://mongoc.org/libmongoc/current/installing.html#building-on-windows and I have added the bin folder to the Windows PATH and now everything works!