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

Bazel support #43

Open
carlfm01 opened this issue Oct 30, 2018 · 5 comments
Open

Bazel support #43

carlfm01 opened this issue Oct 30, 2018 · 5 comments

Comments

@carlfm01
Copy link

Is there an example to use with bazel, or at least an idea on how to use it with Bazel?

@traversaro
Copy link
Collaborator

Hi @carlfm01 ,
as far as I know, there is no Bazel BUILD file available for dlfcn-win32.
However, the library is quite simple (it is just composed of the dlfcn.h header file and
the dlfcn.c source file. There are a few more details (you need to define the SHARED macro
if you are building it as a shared library, and you need to link the psapi library) but it should be fairly simple to compile in any build system, and bazel
has some nice docs on how to build C++ projects: https://docs.bazel.build/versions/master/tutorial/cpp.html and https://github.com/bazelbuild/examples/tree/master/cpp-tutorial .

As the library is relatively simple, it is not a problem to maintain several build systems upstream, so if you want to work on Bazel support I will be happy to review a PR.

@carlfm01
Copy link
Author

Thanks, really appreciate that you take the time to reply, I'll look into that. My final goal with this is to finally bring a DeepSpeech client to Windows. I'll share the results.

@carlfm01
Copy link
Author

carlfm01 commented Nov 1, 2018

Hi, I finally compiled it using this BUILD file for Bazel

cc_library(
name = "dlfnwin",
srcs = ["dlfcn.c"],
hdrs = ["dlfcn.h"],
linkopts = ["-DEFAULTLIB:psapi.lib"],

)

cc_library(
name = "testdl",
srcs = ["testdll.c"],
deps = [
":dlfnwin",
],

)

cc_binary(
name = "test",
srcs = ["test.c"],
deps = [
":testdl",
],

)

The problem is when I run the .exe the file the lib didn't load.

I found https://github.com/kkm000/openfst for my project. When I finish my project I'll try again.

@traversaro
Copy link
Collaborator

I am not a bazel user, but I have two doubts:

  • Are you sure that cc_library for testdll.c is generating a shared library with the correct name testdll.dll ? The test hardcoded that that is the expected name of the plugin to load:
    library = dlopen( "testdll.dll", RTLD_GLOBAL );
    .
  • Are you running the test executable in the same directory that contains the testdll.dll file? Again, that is something that is hardcoded in the test.

@traversaro
Copy link
Collaborator

For people interested in Bazel support, the rules_foreign_cc may be interesting.

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

No branches or pull requests

2 participants