[erlang-questions] How to use gpb?

Tomas Abrahamsson <>
Sat Jun 29 15:37:42 CEST 2013


Hi, Rebar by default uses another protobuf compiler for any *.proto files
it finds in the src subdirectory.

One way to use gpb with rebar is to put your *.proto in another
subdirectory, and use hooks to compile it. I got it working with the
following stuff in rebar.config:

    %% -*- erlang -*-
    {pre_hooks,
     [{compile, "mkdir -p include"}, %% ensure the include dir exists
      {compile,
       "erl +B -noinput -pa /path/to/gpb/ebin "
       "-I`pwd`/proto -o-erl src -o-hrl include "
       "-s gpb_compile c `pwd`/proto/x.proto"
      }]}.

    {post_hooks,
     [{clean, "rm -f src/x.erl include/x.hrl"}]}.

    {erl_opts, [{i, "/path/to/gpb/include"}]}.

and the following initial file/directory layout:

    prompt# find .
    .
    ./proto
    ./proto/x.proto
    ./src
    ./src/g_sup.erl
    ./src/g.app.src
    ./src/g_app.erl
    ./rebar.config

BRs
Tomas


On Fri, Jun 28, 2013 at 11:08 AM, Bin Wang <> wrote:

> Hi,
>
> I'm using google protocol buffers. I found an erlang plugin named
> gpb(https://github.com/tomas-abrahamsson/gpb). But I don't know how
> to use it. When I add it as a dependency of my app using rebar, while
> compile, it always comes out this error:
>
> ERROR: Protobuffs library not present in code path!
>
> Which I searched in google and only found it in erlang_protobuffs
> code. I do use it as a dependency before, but dose it matters?
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130629/76fd7a3e/attachment.html>


More information about the erlang-questions mailing list