Experience in building an osg Android platform Library

Source: Internet
Author: User

The pc-side osg has proved its strength, a large number of expansion projects, strict cross-platform. At present, there is no good 3D open-source framework available on mobile terminals. developers need to write from scratch, which is not a single day to build such a platform, it is easy to compile it to the mobile platform. The following are some problems encountered during the construction process in the past few days. They are frequent and have been resolved. Let's share them.

First, I will briefly introduce some of the tools I used during building:

1. Operating System: Win764-bit flagship

2. Configuration tool: CygWin32 and its 32-bit cmake

3. Build tool: make tool in Cygwin32 bits (3.8.92)

4. NDK: r9b

5. sdk api: android-19

6, Eclipse: adt-bundle-windows-x86-20131030 built-in


Osg uses 3.2.0 because it is a stable master version and generally does not need to be changed. I compiled it directly and didn't test it on the pc at all. There was a slight flaw in the final compilation and running example. Let's introduce it later.

Third-party libraries use the one introduced on the osg official website. Although we can do this on our own, it will be useful for new users like me.


Build command:

Cmake .. -DOSG_BUILD_PLATFORM_ANDROID = ON-DDYNAMIC_OPENTHREADS = OFF-DDYNAMIC_OPENSCENEGRAPH = OFF-balance = ON-demand = OFF-DOSG_GL1_AVAILABLE -paths = OFF-DOSG_GLES1_AVAILABLE = ON-demand = OFF-DJ = 4-DANDROID_PLATFORM = 8-DANDROID_STL = "gnustl_static"-DCMAKE_INSTALL_PREFIX = {path to folder you want put your libs and headers}


Why should I describe the wordlength of the system and tool when introducing the build tool? In other words, I used a 64-bit cygwin during construction for half a day.

-- The C compiler identification is unknown
-- The CXX compiler identification is GNU 4.8.2
CMake Warning at/usr/share/cmake-2.8.11.2/Modules/Platform/CYGWIN. cmake: 15 (message ):
CMake no longer defines WIN32 on Cygwin!


(1) If you are just trying to build this project, ignore this warning or
Quiet it by setting CMAKE_LEGACY_CYGWIN_WIN32 = 0 in your environment or in
The CMake cache. If later configuration or build errors occur then this
Project may have been written under the assumption that Cygwin is WIN32.
In that case, set CMAKE_LEGACY_CYGWIN_WIN32 = 1 instead.


(2) If you are developing this project, add the line


Set (CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake> = 2.8.4 is required


At the top of your top-level CMakeLists.txt file or set the minimum
Required version of CMake to 2.8.4 or higher. Then teach your project
Build on Cygwin without WIN32.
Call Stack (most recent call first ):
/Usr/share/cmake-2.8.11.2/Modules/CMakeSystemSpecificInformation. cmake: 36 (include)
CMakeLists.txt: 47 (PROJECT)

-- Check for working C compiler:/usr/bin/cc
-- Check for working C compiler:/usr/bin/cc -- broken
CMake Error at/usr/share/cmake-2.8.11.2/Modules/CMakeTestCCompiler. cmake: 61 (message ):
The C compiler "/usr/bin/cc" is not able to compile a simple test program.


It fails with the following output:


Change Dir :/... /Build/CMakeFiles/CMakeTmp

Run Build Command :/... /Strawberry/c/bin/gmake.exe
"Cmtrycompileexec316328133/fast"


... /Strawberry/c/bin/gmake-f
CMakeFiles/cmTryCompileExec316328232.dir/build. make
CMakeFiles/cmTryCompileExec316328232.dir/build


Gmake [1]: Entering directory
'... /Build/CMakeFiles/CMakeTmp'


/Usr/bin/cmake.exe-E cmake_progress_report
... /Build/CMakeFiles/CMakeTmp/CMakeFiles
1


Gmake [1]: Leaving directory
'../CMakeFiles/CMakeTmp'


Process_begin: CreateProcess (NULL,/usr/bin/cmake.exe-E
Cmake_progress_report
.../Build/CMakeFiles/CMakeTmp/CMakeFiles
1,...) failed.


Make (e = 2 ):?????????????????


Gmake [1]: *** [CMakeFiles/cmTryCompileExec316328232.dir/testCCompiler. c. o]
Error 2


Gmake: *** [cmtrycompileexec316328133/fast] Error 2

CMake will not be able to correctly generate this project.
Call Stack (most recent call first ):
CMakeLists.txt: 47 (PROJECT)


-- Refreshing incomplete, errors occurred!

In fact, it should be a problem with gmake. I also suspect that, I removed the Path of perl in the environment variable (there is a strawberry perl Path in my Path environment variable). gmake is under the bin directory of perl, delete files such as CmakeCache In the build folder and change the 32-bit cygwin. When building an example, I am sure that it is the gmake in perl that deletes the path from the path environment variable. In theory, we should consider placing the bin directory of cygwin in the path environment variable in the perl directory to block the influence of the perl path. If you encounter this problem, try again.

When constructing an example, you may encounter the following problems:

Ndk-build

Android NDK: WARNING: jni/Android. mk: osgNativeLib: non-system libraries in linker flags:

......

......

Android NDK: This is likely to result in incorrectbuilds. Try using LOCAL_STATIC_LIBRARIES

Android NDK: or LOCAL_SHARED_LIBRARIES instead to listthe library dependencies of

Android NDK: current module

...

...

... Oolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin /.. /lib/gcc/arm-linux-androideabi/4.6 /.. /.. /.. /.. /arm-linux-androideabi/bin/ld.exe: D:/android/osg_android/osges2/obj/local/armeabi/libosg. a (Program. o): infunction std: _ Vector_base >:: _ Vector_impl: _ Vector_impl (std: allocator Const &): C:/android/android-ndk-r9b/sources/cxx-stl/gnu-libstdc ++/4.6/include/bits/stl_vector.h: 87: error: undefined reference to 'std: allocator : Allocator (std: allocator Const &)'

Collect2: ldreturned 1 exit status

... Android-ndk-r9b/build/core/build-binary.mk: 577: recipe for target 'obj/local/armeabi/libosgNativeLib. so 'failed

Make: *** [obj/local/armeabi/libosgNativeLib. so] Error 1

This is related to the variable setting method in the mk file. If there are more than two/errors in the same line of the variable LOCAL_C_FLAGS, it will be even more strange if the space error is used at the branch:

$ ANDROID_NDK/ndk-build

Jni/Android. mk: 26: *** the Delimiter is missing. Stop.


OK. Write it here first.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.