I try. to compile a lib with Android Studio. If I compile the lib with CMAKE on Linux everything went fine. With Android Studio I always get the error:
error: undefined reference to 'ConvertUtf8ToKString(char const*)'
This confuse me. The function is definitely found in the referenced CPP file.
The complete function is:
bool BsdSockServer::ReceiveAnswer(KString &refStrAnswer)
{
static const int utf8BuffSize = UTF8_BUFF_SIZE;
static char utf8Buff[UTF8_BUFF_SIZE];
int res = recv(m_socket, utf8Buff, utf8BuffSize, 0);
if(res == -1)
{
throw FDBException(FDB_EXC_CONNECTION_ERROR);
}
if(res == 0)
{
throw FDBException(FDB_EXC_CONNECTION_CLOSED);
}
if(res >= utf8BuffSize)
{
throw FDBException(FDB_EXC_TOO_BIG_ANSWER);
}
utf8Buff[res] = char(0);
refStrAnswer = ConvertUtf8ToKString(utf8Buff); //<----- LINE
return true;
}
The function in the KString class is:
KString ConvertUtf8ToKString(const char* szString)
{
size_t nSrcLength = strlen(szString);
wchar_t* wszBuffer = new wchar_t[nSrcLength + 1];
utf2wcs(wszBuffer, szString, int(nSrcLength + 1));
KString result(wszBuffer);
delete[] wszBuffer;
return result;
}
In my eyes there is everything ok. Why the NDK compile nag around? I also checked the compiler and CMAKE flags and there is nothing different. Compiler is always clang with c+11.
The important Gradle lines are:
ndk { // these platforms cover 99% percent of all Android devices
//abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
abiFilters 'x86_64'
}
externalNativeBuild {
cmake {
arguments '-DANDROID_PLATFORM=android-29', '-DANDROID_TOOLCHAIN=clang', '-DANDROID_ARM_NEON=TRUE', '-DANDROID_STL=c++_static'
cFlags '-O3', '-fsigned-char' // full optimization, char data type is signed
cppFlags '-std=c++11', '-fsigned-char', '-fPIC'
}
}
Anybody can give me a tip why this compile error happen?
Aucun commentaire:
Enregistrer un commentaire