Using Google's ProtoBuf (and a .proto file) to create a Python API Library - protocol-buffers

I have the .proto file used in the open-source Android API (http://code.google.com/p/android-market-api/), and am having some trouble compiling the file to generate the .py.
I'm trying to follow the instructions here, https://developers.google.com/protocol-buffers/docs/pythontutorial , and am on the steps that are under the header "Compiling Your Protocol Buffers".
I've downloaded the compiler, protoc.exe. The readme says "To install, simply place this binary somewhere in your PATH," which I'm not understanding. I'm messed around with it for a while now, but can't think of how to proceed.
I'm quite the novice programmer, so please tell me if something isn't clear, or if I'm having some sort of fundamental misunderstanding... about anything. I'm on Windows 7 by the way.
Thanks!

if protoc.exe is not in the same directory you're calling it from, you need to add it to your PATH environment variable to be accessible from the calling directory when you're in the shell. open up a command shell and execute:
set PATH=%PATH%c:\directory\to\proto\executable;
then change directories over to where your source code is and execute the compilation line as instructed from the google page.

I had the same problem because it is not written that clear in the README.txt. What they mean is to:
1. take the protoc.exe and put it in the same folder with the other files of your project.
2. open the cmd to that directory and run: protoc --cpp_out=. myfile.proto
=> This will create the 2 new files in the folder with the files of your project, and then you can add them normally to your program.
This helped me: http://www.scriptol.com/programming/protocol-buffers-tutorial.php
This is for c++, but I guess it will be something similar for python; I guess you just have to change the command you are using in the cmd :)

Related

building boost with emscripten on windows

I am trying to build boost using emscripten on windows. In particular, I am trying to use the emscripten toolset as suggested in https://stackoverflow.com/a/47751199/5969590. However, this produces the following error for me:
C:\dev\emsdk\python\3.9.2-1_64bit\python.exe: can't open file 'c:\dev\boost_1_76_0\emcc.py': [Errno 2] No such file or directory
Somewhere in the toolchain boost tries to invoke emcc.py using python, but fails by passing the wrong module path (there is no emcc.py in c:\dev\boost_1_76_0\).
I made sure path environment variables are setup correctly by executing emsdk_env.bat. Running emcc.bat (which internally runs emcc.py) manually, executes the compiler as expected.
I inserted some debug printouts in emcc.bat and from that I gather that the boost toolchain is not using that file. It seems it tries to use python and emcc.py directly. This seems to be where things break down.
Any help or hint is greatly appreciated.
Best,
David
Problem was related to this: What is the reason for batch file path referenced with %~dp0 sometimes changes on changing directory?
I solved the problem by hacking emcc.bat to use hardcoded path to the emcc.py file.

How to run program using OpenMesh

I have read through most of OpenMesh's documentation, and am lost in how to run a simple program using OpenMesh. I followed the tutorial for making a basic cube and building the project: http://www.openmesh.org/media/Documentations/OpenMesh-6.2-Documentation/a00068.html but nowhere do they mention how to RUN the program. The tutorial says to put the file that makes the cube in a particular folder: http://www.openmesh.org/media/Documentations/OpenMesh-6.2-Documentation/a00066.html and I did this. It clearly compiled the code when I built it with cmake and make. After that I am lost.
Assuming you used the CMakeLists.txt as given in the page you linked as-is, the linker should create a file MyOwnProject within the directory where you executed cmake and then make. That's your executable. To run your program, execute that file, either by double-clicking it within a file manager (Explorer, if you are on Windows) or by typing ./MyOwnProject on a Linux command line.

Find out where bash command definition is stored?

I used make/cmake for a project a while ago to build a command line tool, and I thought the binary was only executable while in that directory, but I just found out I'm able to call the command from any directory. This is troublesome because I'm having trouble building a newer project and I suspect this is related.
For example, I can run the command caffe train from a specific folder where I built the binary, but it turns out I can run caffe train from any folder, which I shouldn't be able to do. I could delete the binary, but the problem is that the command for it is stored and being called from somewhere, but I don't know where.
How can I find out where the definition for this command is stored? I examined my .bash_profile and looked at all the paths it listed, but I'm not seeing a relevant one. Is there another place I ought to be looking to find where command line tools are installed?
Ah sorry I just found out: Using type command gives where it is stored. Apparently whereis command should also do the same thing, though it gives me no output; for anyone else who has this problem, trying both would be good!

how to add to PATH variable in OSX

I'm going to try building a custom language extension for Komodo Edit.
In order to build an xpi file, I need to add something to the PATH variable.
I'm not really familiar with the command line, so I'm not 100% sure how to do this.
I started by created an empty .profile file in my user directory.
Can I add modify that in a text editor to do what I need to do?
Here's the instructions I'm trying to follow.
http://community.activestate.com/forum/introduction-building-komodo-extension
Here is how packing up the Mako UDL into a Komodo extension works. Komodo includes a SDK in its install tree. On Linux and Windows this is found at "installdir/lib/sdk", and for a Mac it's found at "komodo.app/Contents/SharedSupport/sdk". That SDK includes a koext helper tool in the /lib/sdk/bin directory:
Put the SDK bin dir on your PATH and you should be able to run koext at the command line. Similar to tools like cvs or svn, these are tools with multiple sub-commands.
Something like that should be helpful
http://www.tech-recipes.com/rx/2621/os_x_change_path_environment_variable/
export PATH=/ANYTHING_YOU_ARE_WORKIN_ON/bin:/opt/local/bin:/opt/local/sbin:$PATH export

Configuring Bison to compile an input file under Visual C 6

I'm trying to get Bison to do it's thing in VC6. I'm sure this must be a problem with my configuration. At the moment I have a Custom Build step as follows.
<Commands>
echo Start parser generation
"C:\GnuWin32\bin\bison.exe" $(InputPath)
echo Finish parser generation
<Outputs>
$(ProjDir)\$(InputName).c
$(ProjDir)\$(InputName).h
The error I get is "C:\GnuWin32\bin\bison.exe: m4: No such file or directory", which makes me think the m4.exe doesn't exist or isn't on the path, but I can run the exact same command from CMD in the same directory with no errors.
This thought process makes me think it's a problem with the output options, but I've tried various configurations with no luck.
Any help would be great, thanks in advance.
Edit: I've added some more visual studio versions to the tag list to try to get some more exposure for the question. Hopefully someone will have done this in a later version and I can work backwards.
Okay, I've managed to slove this in a very round-about way but I will try my best to document it here.
It seems that VC6 Custom build options will only look in the project directory for the m4.exe, even when you specify where the calling exe (bison) is explicitly. To solve this I did a bit of a hack and did a full cd command in the custom build window to get to the gnuwin32 directory (where both bison and m4 live) before trying to call the parser generator.
This works fine but is a bit of a hassle for trying to distribute it to other people when they may have installed GNU tools to a different location.

Resources