Issue
I'm migrating to cocos2d-x 3.17.2 from cocos2d-x 3.9 and when I build android studio project, I have errors when linking Wwise libAuroPannerMixer.a. NDK version 19.2, compile with clang, wwise version 2017.1.3.6377. Maybe someone has the same problem?
Application.mk
APP_STL := c++_static
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -
fsigned-char -Wno-extern-c-compat
APP_LDFLAGS := -latomic -stdlib=libc++ -lstdc++
APP_ABI := arm64-v8a
APP_SHORT_COMMANDS := true
ifeq ($(NDK_DEBUG),1)
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
APP_OPTIM := debug
else
APP_CPPFLAGS += -DNDEBUG
APP_OPTIM := release
endif
build.gradle:
import org.gradle.internal.os.OperatingSystem
apply plugin: 'com.android.application'
android {
compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
defaultConfig {
applicationId "org.bio.brick.breaker"
minSdkVersion PROP_MIN_SDK_VERSION
targetSdkVersion PROP_TARGET_SDK_VERSION
versionCode 55
versionName "1.55"
multiDexEnabled true
externalNativeBuild {
if (PROP_BUILD_TYPE == 'ndk-build') {
ndkBuild {
targets 'BioBrickBreaker'
arguments 'NDK_TOOLCHAIN_VERSION=clang'
arguments '-j' + Runtime.runtime.availableProcessors()
def module_paths = [project.file("../../cocos2d").absolutePath,
project.file("../../cocos2d/cocos").absolutePath,
project.file("../../cocos2d/external").absolutePath]
if (OperatingSystem.current().isWindows()) {
module_paths = module_paths.collect {it.replaceAll('\\\\', '/')}
arguments 'NDK_MODULE_PATH=' + module_paths.join(";")
}
else {
arguments 'NDK_MODULE_PATH=' + module_paths.join(':')
}
}
}
else if (PROP_BUILD_TYPE == 'cmake') {
cmake {
targets 'BioBrickBreaker'
arguments "-DCMAKE_FIND_ROOT_PATH=", "-DANDROID_STL=c++_static", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_ARM_NEON=TRUE"
cppFlags "-frtti -fexceptions -fsigned-char"
}
}
}
ndk {
abiFilters = []
abiFilters.addAll(PROP_APP_ABI.split(':').collect{it as String})
}
}
sourceSets.main {
java.srcDir "src"
res.srcDir "res"
jniLibs.srcDir "libs"
manifest.srcFile "AndroidManifest.xml"
assets.srcDir "../../Resources"
}
externalNativeBuild {
if (PROP_BUILD_TYPE == 'ndk-build') {
ndkBuild {
path "jni/Android.mk"
}
}
else if (PROP_BUILD_TYPE == 'cmake') {
cmake {
path "../../CMakeLists.txt"
}
}
}
buildTypes {
release {
debuggable false
jniDebuggable false
renderscriptDebuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (project.hasProperty("RELEASE_STORE_FILE")) {
signingConfig signingConfigs.release
}
externalNativeBuild {
ndkBuild {
arguments 'NDK_DEBUG=0'
}
}
}
debug {
debuggable true
jniDebuggable true
renderscriptDebuggable true
externalNativeBuild {
ndkBuild {
arguments 'NDK_DEBUG=1'
}
}
}
}
}
buildscript {
repositories {
mavenCentral()
}
}
repositories {
maven {
url "https://maven.google.com"
}
maven {
url "http://maven.gameanalytics.com/release"
}
flatDir {
dirs 'libs-aar'
}
}
android.applicationVariants.all { variant ->
delete "${buildDir}/intermediates/assets/${variant.dirName}"
variant.mergeAssets.doLast {
copy {
from "${buildDir}/../../../Resources"
into "${buildDir}/intermediates/assets/${variant.dirName}"
exclude "**/*.gz"
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':libcocos2dx')
implementation project(':downloader_library')
implementation project(':license_library')
implementation project(':zip_library')
}
Output log:
D:/dev/biobrickbreaker/proj.android/app/jni/../../../WwiseLib/android-21_arm64-v8a/Release/lib/libAuroPannerMixer.a(AuroPannerMixer.o): In function `__static_initialization_and_destruction_0':
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x/iostream:74: undefined reference to `std::ios_base::Init::Init()'
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
D:/dev/biobrickbreaker/proj.android/app/jni/../../../WwiseLib/android-21_arm64-v8a/Release/lib/libAuroPannerMixer.a(LSSAuroPanner.o): In function `LssAuroPannerEncoder::setSourceParameter(char const*, float)':
C:\jenkins\ws\wwise_v2017.1\wwise\Partners\Auro\AuroPanner\SoundEnginePlugin\Android/../../../auro-commons/audio/LSSAuroPanner/Src/LSSAuroPanner.cpp:627: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
C:\jenkins\ws\wwise_v2017.1\wwise\Partners\Auro\AuroPanner\SoundEnginePlugin\Android/../../../auro-commons/audio/LSSAuroPanner/Src/LSSAuroPanner.cpp:628: undefined reference to `std::string::compare(char const*) const'
D:/dev/biobrickbreaker/proj.android/app/jni/../../../WwiseLib/android-21_arm64-v8a/Release/lib/libAuroPannerMixer.a(LSSAuroPanner.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x\bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x\bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x\bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x\bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x\bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
D:/dev/biobrickbreaker/proj.android/app/jni/../../../WwiseLib/android-21_arm64-v8a/Release/lib/libAuroPannerMixer.a(LSSAuroPanner.o): In function `LssAuroPannerEncoder::setSourceParameter(char const*, float)':
C:\jenkins\ws\wwise_v2017.1\wwise\Partners\Auro\AuroPanner\SoundEnginePlugin\Android/../../../auro-commons/audio/LSSAuroPanner/Src/LSSAuroPanner.cpp:632: undefined reference to `std::string::compare(char const*) const'
C:\jenkins\ws\wwise_v2017.1\wwise\Partners\Auro\AuroPanner\SoundEnginePlugin\Android/../../../auro-commons/audio/LSSAuroPanner/Src/LSSAuroPanner.cpp:636: undefined reference to `std::string::compare(char const*) const'
C:\jenkins\ws\wwise_v2017.1\wwise\Partners\Auro\AuroPanner\SoundEnginePlugin\Android/../../../auro-commons/audio/LSSAuroPanner/Src/LSSAuroPanner.cpp:640: undefined reference to `std::string::compare(char const*) const'
C:\jenkins\ws\wwise_v2017.1\wwise\Partners\Auro\AuroPanner\SoundEnginePlugin\Android/../../../auro-commons/audio/LSSAuroPanner/Src/LSSAuroPanner.cpp:644: undefined reference to `std::string::compare(char const*) const'
C:\jenkins\ws\wwise_v2017.1\wwise\Partners\Auro\AuroPanner\SoundEnginePlugin\Android/../../../auro-commons/audio/LSSAuroPanner/Src/LSSAuroPanner.cpp:648: undefined reference to `std::string::compare(char const*) const'
D:/dev/biobrickbreaker/proj.android/app/jni/../../../WwiseLib/android-21_arm64-v8a/Release/lib/libAuroPannerMixer.a(LSSAuroPanner.o):C:\jenkins\ws\wwise_v2017.1\wwise\Partners\Auro\AuroPanner\SoundEnginePlugin\Android/../../../auro-commons/audio/LSSAuroPanner/Src/LSSAuroPanner.cpp:652: more undefined references to `std::string::compare(char const*) const' follow
D:/dev/biobrickbreaker/proj.android/app/jni/../../../WwiseLib/android-21_arm64-v8a/Release/lib/libAuroPannerMixer.a(LSSAuroPanner.o): In function `__static_initialization_and_destruction_0':
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x/iostream:74: undefined reference to `std::ios_base::Init::Init()'
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)D:/dev/biobrickbreaker/proj.android/app/jni/../../../WwiseLib/android-21_arm64-v8a/Release/lib/libAuroPannerMixer.a(AuroPannerMixer.o): In function `__static_initialization_and_destruction_0':
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x/iostream:74: undefined reference to `std::ios_base::Init::Init()'
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
D:/dev/biobrickbreaker/proj.android/app/jni/../../../WwiseLib/android-21_arm64-v8a/Release/lib/libAuroPannerMixer.a(LSSAuroPanner.o): In function `LssAuroPannerEncoder::setSourceParameter(char const*, float)':
C:\jenkins\ws\wwise_v2017.1\wwise\Partners\Auro\AuroPanner\SoundEnginePlugin\Android/../../../auro-commons/audio/LSSAuroPanner/Src/LSSAuroPanner.cpp:627: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
C:\jenkins\ws\wwise_v2017.1\wwise\Partners\Auro\AuroPanner\SoundEnginePlugin\Android/../../../auro-commons/audio/LSSAuroPanner/Src/LSSAuroPanner.cpp:628: undefined reference to `std::string::compare(char const*) const'
D:/dev/biobrickbreaker/proj.android/app/jni/../../../WwiseLib/android-21_arm64-v8a/Release/lib/libAuroPannerMixer.a(LSSAuroPanner.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x\bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x\bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x\bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x\bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x\bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
D:/dev/biobrickbreaker/proj.android/app/jni/../../../WwiseLib/android-21_arm64-v8a/Release/lib/libAuroPannerMixer.a(LSSAuroPanner.o): In function `LssAuroPannerEncoder::setSourceParameter(char const*, float)':
C:\jenkins\ws\wwise_v2017.1\wwise\Partners\Auro\AuroPanner\SoundEnginePlugin\Android/../../../auro-commons/audio/LSSAuroPanner/Src/LSSAuroPanner.cpp:632: undefined reference to `std::string::compare(char const*) const'
C:\jenkins\ws\wwise_v2017.1\wwise\Partners\Auro\AuroPanner\SoundEnginePlugin\Android/../../../auro-commons/audio/LSSAuroPanner/Src/LSSAuroPanner.cpp:636: undefined reference to `std::string::compare(char const*) const'
C:\jenkins\ws\wwise_v2017.1\wwise\Partners\Auro\AuroPanner\SoundEnginePlugin\Android/../../../auro-commons/audio/LSSAuroPanner/Src/LSSAuroPanner.cpp:640: undefined reference to `std::string::compare(char const*) const'
C:\jenkins\ws\wwise_v2017.1\wwise\Partners\Auro\AuroPanner\SoundEnginePlugin\Android/../../../auro-commons/audio/LSSAuroPanner/Src/LSSAuroPanner.cpp:644: undefined reference to `std::string::compare(char const*) const'
C:\jenkins\ws\wwise_v2017.1\wwise\Partners\Auro\AuroPanner\SoundEnginePlugin\Android/../../../auro-commons/audio/LSSAuroPanner/Src/LSSAuroPanner.cpp:648: undefined reference to `std::string::compare(char const*) const'
D:/dev/biobrickbreaker/proj.android/app/jni/../../../WwiseLib/android-21_arm64-v8a/Release/lib/libAuroPannerMixer.a(LSSAuroPanner.o):C:\jenkins\ws\wwise_v2017.1\wwise\Partners\Auro\AuroPanner\SoundEnginePlugin\Android/../../../auro-commons/audio/LSSAuroPanner/Src/LSSAuroPanner.cpp:652: more undefined references to `std::string::compare(char const*) const' follow
D:/dev/biobrickbreaker/proj.android/app/jni/../../../WwiseLib/android-21_arm64-v8a/Release/lib/libAuroPannerMixer.a(LSSAuroPanner.o): In function `__static_initialization_and_destruction_0':
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x/iostream:74: undefined reference to `std::ios_base::Init::Init()'
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
Solution
I see at least three problems.
APP_LDFLAGS := -latomic -stdlib=libc++ -lstdc++
Delete this whole line. The first flag is redundant (it's automatic with ndk-build), and the second two are wrong.
ndk-build manually links the standard library at the correct place in the link command and uses -nostdlib++
to inhibit the compiler's default behavior. Adding -stdlib=libc++
breaks that, so now it is being linked twice and in the wrong location.
-lstdc++
links the wrong library.
c:\jenkins\ws\wwise_v2017.1\wwise\sdk\source\build\android\android-21_arm64-v8a\include\c++\4.9.x/iostream:74: undefined reference to `std::ios_base::Init::Init()'
Note specifically the path and the name of the std
namespace here. include\c++\4.9.x
is the path for the gnustl headers, and std
is the name of the gnustl namespace. libc++ uses a different header path and the namespace is std::__ndk1
(the second part is an inline namespace so that's an implementation detail you don't need to worry about when coding, but it breaks at build time to protect you from exactly these issues). Your wwise library was built with gnustl and you're using libc++. These two libraries are not compatible and cannot be used in the same application.
You need to rebuild wwise with libc++ to use it with libc++. If you're unable to do so, you need to revert to NDK r17 (the last release that supported gnustl). Note that by doing so you'll also lose access to C++14 and some pieces of C++11 (as well as reintroduce any bugs that we've fixed since then), so it's strongly preferable to rebuild wwise rather than use an old NDK.
Answered By - Dan Albert
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.