Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to compile a libCommon.a that can be used on Android Platform? #64

Open
perfectworld0415 opened this issue Apr 2, 2020 · 3 comments

Comments

@perfectworld0415
Copy link

I compiled it with NDK toolchains on Ubuntu , errors happened like X11/Xlib.h' file not found? Anyone knows how to solve it?

@danginsburg
Copy link
Owner

It sounds like it's building the Linux/X11 version instead of the Android version. It should be using this: https://github.com/danginsburg/opengles3-book/blob/master/Common/Source/Android/esUtil_Android.c

@javedrabbani can you advise?

@javedrabbani
Copy link

@perfectworld0415 Can you please share how you are building on Ubuntu? I mean please share how you are invoking CMake to build for android?

@perfectworld0415
Copy link
Author

@perfectworld0415 Can you please share how you are building on Ubuntu? I mean please share how you are invoking CMake to build for android?

Cmakelist.txt:
set ( common_src Source/esShader.c
Source/esShapes.c
Source/esTransform.c
Source/esUtil.c )

Win32 Platform files

if(WIN32)
set( common_platform_src Source/Win32/esUtil_win32.c )
add_library( Common STATIC ${common_src} ${common_platform_src} )
target_link_libraries( Common ${OPENGLES3_LIBRARY} ${EGL_LIBRARY} )
else()
find_package(X11)
find_library(M_LIB m)
find_package(Threads)
find_library(android-lib android)
find_library(log-lib log )
# set( common_platform_src Source/LinuxX11/esUtil_X11.c )
set( common_platform_src Source/Android/esUtil_Android.c )
# add_library( Common STATIC ${common_src} ${common_platform_src} )
add_library( Common SHARED ${common_src} ${common_platform_src} )
target_link_libraries( Common ${OPENGLES3_LIBRARY} ${EGL_LIBRARY} ${X11_LIBRARIES} ${M_LIB} ${CMAKE_THREAD_LIBS_INIT} ${android-lib} ${log-lib})
endif()

Cmake : cmake -DCMAKE_TOOLCHAIN_FILE=/home/codingbo/Liuqc/android-ndk-r20/build/cmake/android.toolchain.cmake
-DANDROID_ABI="arm64-v8a"
-DANDROID_ARM_NEON=ON
-DANDROID_STL=c++_static
-DANDROID_PLATFORM=android-24
..

error : CMakeFiles/Common.dir/Source/Android/esUtil_Android.c.o: In function android_main': /home/codingbo/Liuqc/WorkSpace/opengles3-book-master/Common/Source/Android/esUtil_Android.c:142: undefined reference to app_dummy'
CMakeFiles/Common.dir/Source/Android/esUtil_Android.c.o: In function HandleCommand': /home/codingbo/Liuqc/WorkSpace/opengles3-book-master/Common/Source/Android/esUtil_Android.c:86: undefined reference to esMain'
/home/codingbo/Liuqc/WorkSpace/opengles3-book-master/Common/Source/Android/esUtil_Android.c:86: undefined reference to `esMain'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Common/CMakeFiles/Common.dir/build.make:148: recipe for target 'Common/libCommon.so' failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants