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 6250417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:25:09+00:00 2026-05-24T13:25:09+00:00

I am interested in generating a C++ header using Apache Avro’s code generation tool

  • 0

I am interested in generating a C++ header using Apache Avro’s code generation tool (i.e. the python script). According to the documentation it should be fairly easy to do, but I don’t usually use python, so things look kinda strange to me.

The instructions state:

To generate the code is a two step process:

precompile < imaginary > imaginary.flat

The precompile step converts the schema into an intermediate format that is used by the code generator. This intermediate file is just a text-based representation of the schema, flattened by a depth-first-traverse of the tree structure of the schema types.

python scripts/gen-cppcode.py --input=example.flat --output=example.hh –-namespace=Math

This tells the code generator to read your flattened schema as its input, and generate a C++ header file in example.hh. The optional argument namespace will put the objects in that namespace…

My Issue (no, I can’t see a doctor or use a cream for it):

I don’t see anything that explains in details how to precompile. The documentation makes it seem like if I just type “precompile” in the command prompt and supply the command line arguments, then things would magically work, but precompile is not a valid Windows command. So what’s the proper way to precompile on Windows? If anybody knows how to do it, then PLEASE let me know!

I also tried to run the gen-cppcode.py script, but it gets an error in line 316 (which, I suspect, may be happening because I didn’t precompile the schema):

def doEnum(args):
    structDef = enumTemplate;
    typename = args[1]
    structDef = structDef.replace('$name$', typename)
    end = False
    symbols = '';
    firstsymbol = '';
    while not end:
        line = getNextLine()
        if line[0] == 'end': end = True
        elif line[0] == 'name':
            if symbols== '' :
                firstsymbol = line[1]
            else :
                symbols += ', '
            symbols += line[1]
        else: print "error" // <-- Syntax Error: invalid syntax
    structDef = structDef.replace('$enumsymbols$', symbols);
    structDef = structDef.replace('$firstsymbol$', firstsymbol);
    addStruct(typename, structDef)
    return (typename,typename)
  • 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-05-24T13:25:11+00:00Added an answer on May 24, 2026 at 1:25 pm

    About the only way I figured to do this is to:

    1. Download VirtualBox.
    2. Install Ubuntu (or another distro).
    3. Download Avro.
    4. Install cmake.
    5. Install the C++ compilers (build essential).
    6. Install boost, flex, bison (sudo apt-get install boost flex bison); btw, you will specifically need these boost libraries:
      — regex
      — filesystem
      — system
      — program_options
    7. Build Avro:

      $ tar xf avro-cpp-1.5.1.tar.gz
      $ cd avro-cpp-1.5.1
      $ cmake -G “Unix Makefiles”
      $ make -j3
      $ build/precompile file.input file.flatoutput

    You can now generate a header file (still in the terminal window of the VM):

    python scripts/gen-cppcode.py –input=example.flat –output=example.hh

    Note that even after you generate the C++ file, you will still be unable to build with it in Windows (even if you have the right dependency includes to the avro-cpp-1.5.1/api. Avro has dependencies on GNU libraries (such as sys/uio.h) and I’m not sure how to specifically resolve them yet.

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

Sidebar

Related Questions

I am especially interested in generating code from sequence diagrams and vice versa- ie.,
How do you get started generating native code for a target platform? I've got
What are your approaches to generating some sort of human-readable documentation from WSDLs? In
I'm working with generating .pdf's from PHP using this library: http://www.fpdf.org/ I am currently
I'm working with a VB6 code base and I'm interested in beginning to generate
Using SQL Plus, you can run a script with the @ operator from the
I'm working on a planet generation tool in C++ and currently I'm trying to
I'm generating PDFs from HTML (using ABCPdf and C#) and the files are coming
I've seen several questions regarding problems with generating classes from XML Schema using xsd.exe
I was wondering if any of you guys had any experience generating code coverage

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.