Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8192827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:15:57+00:00 2026-06-07T04:15:57+00:00

I managed to compile my .proto files like this: def build(bld): bld(rule=’protoc –cpp_out=. -I..

  • 0

I managed to compile my .proto files like this:

def build(bld):
    bld(rule='protoc --cpp_out=. -I.. ${SRC}', source='a.proto b.proto', name='genproto')

Seems to work nice, when I make changes to the source files, they are recompiled and so on. But the result would be files called build/a.pb.cc and build/b.pb.cc which I need to include into my main programs source list. Of course I know how to manually construct them from my protocol buffers file names, but I don’t think this is the way to go. Can anyone provide me a hint?

Best regards, Philipp

UPDATE

With patient help from the IRC people I was able to manage to build a tool, as suggested below.

#!/usr/bin/env python
# encoding: utf-8
# Philipp Bender, 2012

from waflib.Task import Task
from waflib.TaskGen import extension 

"""
A simple tool to integrate protocol buffers into your build system.

    def configure(conf):
        conf.load('compiler_cxx cxx protoc_cxx')

    def build(bld):
    bld.program(source = "main.cpp file1.proto proto/file2.proto", 
            target = "executable") 

"""

class protoc(Task):
    run_str = '${PROTOC} ${SRC} --cpp_out=. -I..'
    color = 'BLUE'
    ext_out = ['.h', 'pb.cc']

@extension('.proto')
def process_protoc(self, node):
    cpp_node = node.change_ext('.pb.cc')
    hpp_node = node.change_ext('.pb.h')
    self.create_task('protoc', node, [cpp_node, hpp_node])
    self.source.append(cpp_node)
    self.env.append_value('INCLUDES', ['.'] )

    self.use = self.to_list(getattr(self, 'use', '')) + ['PROTOBUF']

def configure(conf):
    conf.check_cfg(package="protobuf", uselib_store="PROTOBUF", 
            args=['--cflags', '--libs'])
    conf.find_program('protoc', var='PROTOC')

You can also find it in the bugtracker:

https://code.google.com/p/waf/issues/detail?id=1184

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:15:58+00:00Added an answer on June 7, 2026 at 4:15 am

    This kind of processing is documented in the Waf book (look for “idl”).

    However I’m pretty sure a protobuf tool would be welcomed by the community, so I suggest you attempt to create one and submit it for review on the bug tracker or on IRC. This way, you’ll have less maintenance burden, a shorter wscript.

    I would expect to use the tool like this:

    bld(
     name="protobufs",
     features="protoc cxx",
     source=["protobuf/a.proto", "protobuf/b.proto"],
     includes=["protobuf", "..."],
    )
    
    bld(
     target="test",
     features="cxx cxxprogram",
     source="test.cpp",
     use="protobufs", # uses the generated C++ code, links to -lprotobuf
    )
    

    Or something like that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I managed to get this code to compile with out error. But somehow it
I cannot seem to compile mod_dontdothat on Windows. Has anybody managed to achieve this?
I have a const int that is computed at compile time in my Managed
I managed to apply this excellent example to my needs: http://code.google.com/p/galleriffic/issues/attachmentText?id=76&aid=-3045121742886940548&name=example-2.html&token=4nlvmgAfVpc5whcXC9UEqHZaSz0%3A1339257750721 With a small
I managed to compile V8 engine on the machine, however when I type $
I managed to compile Lua 5.1.4 for Palm webOS and now I'm trying to
After following instructions on the emscripten wiki I have managed to compile a small
I am trying to compile this libevent2 package to Windows, but currently I can't
I managed to build ffmpeg and libx264 on my Ubuntu 11.10 machine from source.
I managed to compile Poco C++ 1.3.6 library for iPhone by the following commands:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.