Source: http://hi.baidu.com/guccang/item/9205cbe25c3a1c03570f1dfb
I. Local Environment: ubuntu64-bit Operating System
Uname-A Query
Operating System: Ubuntu 64-bit Operating System
Cross Compiler: arm-linux-gcc-4.4.3
Google protobuf: protobuf-2.4.1
Result: When making, the system prompts can not find arm-Linux-G ++.
Ii. Local Environment: Red Hat 32-bit Operating System
Uname-A Query
Operating System: Linux suowenair 2.6.32-131.0.15.el6.i686 #1 SMP Tue May 10 15:42:28 EDT 2011 i686 i686 i386 GNU/Linux
Cross Compiler: arm-linux-gcc-4.4.3
Google protobuf: protobuf-2.4.1:
Steps:
Step 1: deploy the protoc.exe file.
./Configure
Sudo make
Sudo make check
Sudo make install
Make distclean
Make distclean clears the generated makefile to prepare for the second makefile configuration.
Make check does not display any error messages
Step 2: Cross-Compilation
Configure the MAKEFILE file.
1:./configure -- Build = i686_pc_linux_gnu -- Host = arm-Linux -- With-protoc = protoc -- prefix = path_of_arm_linux_lib
-- Build indicates the local environment. If it is unclear, you can view the printed information or makefile generated in step 1./configure when generating the makefile.
-- Host indicates the runtime environment of the compiled database. I run it on the cpu Of the ARM architecture, so I use arm-Linux, in the generated makefile, The -- Host option is arm-unknown-Linux-GNU.
Failed. An error occurs.
The error message is: protoc cannot be found.
-- Prefix = path_of_arm_linux_lib, and set to the upper directory of the lib directory of the Cross-compilation tool arm-linux-gcc-4.4.3, -- prefix set path, that is, make install,
Include of protobuf and copy directory of lib directory. Objective To use the library application method ('pkg-config -- cflags -- libs protobuf') in Google protobuf standard during compilation ').
After configuring configure above, generate the MAKEFILE file and check whether CC/ccxx and other commands are equal to the arm-linux version.
My options are cc = arm-Linux-GCC ccxx = arm-Linux-G ++.
2: sudo make
If -- With-protoc = protoc is not configured, an error occurs.
An error occurs if the first step is not performed. The system prompts that the protoc cannot be found.
Other errors are unknown.
3: sudo make check
This step fails. I have monitored 5 prompts, but all 5 failed. I don't know why?
However, it is no problem for the ARM platform to use libprotobuf. A library. Other libraries, for verification.
4: sudo make install
No error
Iii. database usage
View the protobuf example. The makefile in the example folder. Let's analyze the: makfile fragment.
Add_person_cpp: add_person.cc protoc_middleman
PKG-config -- cflags protobuf # fails if protobuf Is Not Installed
C ++ add_person.cc addressbook. Pb. CC-O add_person_cpp 'pkg-config -- cflags -- libs protobuf'
1: PKG-config -- cflags protobuf # fails if protobuf Is Not Installed
To check whether protobuf is installed.
2: C ++ is used for compilation, but G ++ is not used,
3: Use 'pkg-config -- cflags -- libs protobuf 'to load libprotobuf..
The display configuration is not used:-L/path0flib-lprotobuf
Note that 'pkg-config -- cflags -- libs protobuf 'uses the button on the left of the Number 1, not a single quotation mark.
4: When I use arm-Linux for compilation, the above format is also used. Note the following three points:
PKG-config -- cflags protobuf # fails if protobuf is not installed just in case
'Pkg-config -- cflags -- libs protobuf 'to load the protobuf Library
Arm-Linux-C ++ to compile the C ++ project.
5: Why pay attention to the above three points: I encountered a problem during use.
For example, if you use arm-Linux-G ++ to compile the project, you are always prompted that the libprotobuf. A library cannot be found.
In principle, the database cannot be found for two reasons:
The first is: the Library directory contains the search directory.
The second is: the Library version is incorrect, such as the arm-Linux compiler, connecting to a non-arm-Linux compiled library.
But I am satisfied with both. You can still find the libprotobuf. A library file.
Instead, use arm-Linux-C ++.
6: This article is only intended for those who encounter the same problems as me.