forked from obfuscated/codeblocks_sf
-
Notifications
You must be signed in to change notification settings - Fork 3
protobuff_index
bluehazzard edited this page Oct 2, 2018
·
1 revision
This guide shows you how to integrate the protocol buffer compiler within codeblocks so the .proto files get automatically generated and updated on build
- Download the protocol buffer framework: Download and install the protobuffer compiler and library on your system
- Open Codeblocks
- Settings -> Compiler -> Global compiler settings
- Select your compiler from the
Selected compilerlist. (Normally you use theGNU GCC Compiler) - Select the tab
Toolchain executablesand thenAdditional Paths - Enter the path to the installed
protocexecutable (Where you have installed proto buffer) If the installation path is in the system PATH variable, or in the compiler path you do not have to do this. - Hit the right arrow button under the "Reset default" button until
Other settingstab appears and select it - Click
Advanced options - Select tab
Commandsand from the "Command" dropdown selectCompile single file to object file - Next to the
Source extclick the+button and enterproto - In "Command line macro" enter
protoc -I $file_dir --cpp_out=$file_dir $file_name.$file_ext
- in "Generated files (to be future compiled):" enter
$file_dir/$file_name.pb.cc
$file_dir/$file_name.pb.h
- Hit Ok on all Dialogs to leave the settings
If you use linux you probably can skip this, because the protobuffer library is installed on system level.
- Settings -> global variables
- New -> enter
protobuffer - Select
protobufferfrom the list - Enter the path to your protobuffer base installation path in the
basefield. You can use the...button to browse - Enter in the
includefield the path to theincludesub folder of the protobuffer installation directory - Enter in the
libfield the path to thelibsub folder of the protobuffer installation directory - Close the dialog
- Create a new project with File -> new project
- Set up the build options: Project -> Build options
- Select the project name from the tree control on the left
- Select the tab
Linker settings-> Add -> enter the name of the protocolbuffer librarylibprotobuf - Select the tab
Search directories-> Compiler -> Add -> Push the button with right most button. This will open a dialog with the nameGet global variableand selectprotobuffer -> include - Select the tab
Search directories-> Linker -> Add -> Push the button with right most button. This will open a dialog with the nameGet global variableand selectprotobuffer -> lib - 'Ok' to close all dialogs
- Add the
.protofiles to your project. Codeblocks will create a virtual Folder with the nameAuto-generatedwith the corresponding names of the source files like the proto files - You may have the problem that the source files that include the proto.h files are compiled before the protoc compiler is called. To fix this you have to elevate the protoc priority so the files are generated before other source files are build. To do this: Select the
.protofile from the project tree and make right click -> properties -> Build -> Priority weight: 0 . This will ensure that the proto file is always build before the c files