When I build my code, I see that $(NDK)\toolchains\arm-linux-androideabi-4.6 is being used although I have $(NDK)\toolchains\arm-linux-androideabi-4.8 available on my machine.
My understanding is that one should always use the latest androideabi so that the latest gcc compiler can be used. I am wondering why ndk-build is picking up an older version.
Here is my Application.mk for your reference:
APP_ABI := armeabi-v7a
APP_PLATFORM := android-16
APP_OPTIM := release
APP_STL := gnustl_static
APP_CPPFLAGS := -std=gnu++11
The value forAPP_PLATFORMneeds to be android-16 so that we can support Android OS version 4.1 and above. I wonder if androideabi is tied toAPP_PLATFORMvalue.
The issue is not the ABI, but rather the toolchain version.
You can control this in your Android.mk
From the documentation thereof:
NDK_TOOLCHAIN_VERSION
Define this variable to either 4.6, 4.7 or 4.8 to select version of the GCC compiler. 4.6 is the default
Related
Windows 11 supports emulating x64 hardware whilst actually running on an ARM64 platform. An example of this would be running Windows inside a virtual machine on a Mac.
Previously my Inno installer was just using the following to ensure that the PC was capable of running our software:
ArchitecturesAllowed=x64
However on an ARM-based system like the example given this causes the setup to terminate because it (rightly) sees arm64 as the architecture.
I can't just add arm64 to that line because that won't distinguish between older ARM-based systems which have no x64 emulation capability and those that do.
Hopefully, in the Inno Setup Google Group this topic was discussed as follows:
Jordan Russell Oct 4, 2021, 5:45:40 PM
...
If they were to switch to "ArchitecturesInstall64BitMode=x64 arm64",
then you should get the x64 files. Unfortunately, however, the x64
files would also be installed on older ARM64 builds that don't support
x64 emulation, resulting in a non-functioning app.
...
I do still plan, though, to add official support for detecting x64
emulation in the near future. A new architecture identifier
"x64compatible" will match both x64 Windows and ARM64 Windows with x64
emulation support, and an IsX64Compatible function will also be added.
To encourage adoption of "x64compatible" so that more x64 apps can be
installed on ARM64, the existing "x64" will be deprecated and renamed
to "x64strict", and later on the compiler will print a warning when
"x64" is used.
However the relevant Inno documentation sections don't seem to have any mention of this. (https://jrsoftware.org/ishelp/index.php?topic=setup_architecturesallowed,
https://jrsoftware.org/ishelp/index.php?topic=isxfunc_isarm64)
Is there any built-in way to do it?
If not I may have to try some direct system calls such as those mentioned in How to detect if Windows supports running x64 processes?.
As the question you have linked shows, you can call GetMachineTypeAttributes WinAPI function on Windows 11 to determine x64 support. On older versions of Windows, use ProcessorArchitecture Inno Setup support function
Something like this should do (but I do not have ARM64 machine to test this on).
[Code]
const
IMAGE_FILE_MACHINE_AMD64 = $8664;
function GetMachineTypeAttributes(
Machine: Word; var MachineTypeAttributes: Integer): HRESULT;
external 'GetMachineTypeAttributes#Kernel32.dll stdcall delayload';
<event('InitializeSetup')>
function InitializeSetupCheckArchitecture(): Boolean;
var
MachineTypeAttributes: Integer;
Arch: TSetupProcessorArchitecture;
begin
if IsWindows11OrNewer then
begin
OleCheck(
GetMachineTypeAttributes(IMAGE_FILE_MACHINE_AMD64, MachineTypeAttributes));
if MachineTypeAttributes <> 0 then
begin
Log('Windows 11 or newer, with x64 support');
Result := True;
end
else
begin
Log('Windows 11 or newer, without x64 support');
Result := False;
end;
end
else
begin
Arch := ProcessorArchitecture;
if Arch = paX64 then
begin
Log('Windows 10 or older, on x64 architecture');
Result := True;
end
else
begin
Log('Windows 10 or older, not on x64 architecture');
Result := False;
end;
end;
if not Result then
begin
MsgBox('This product can be installed on system with x64 support only.',
mbError, MB_OK);
end;
end;
The code completely replaces the ArchitecturesAllowed directive (it assumes it is not set, though setting it to x64 arm64 should do no harm).
The IsWindows11OrNewer comes from Determine Windows version in Inno Setup.
I'm using Mac to compile "rewritersample.cpp" from https://github.com/eliben/llvm-clang-samples/tree/master/src_clang with clang and I get the following error,
fatal error: 'clang/AST/ASTConsumer.h' file not found
I don't know why I'm getting this error even though I have clang installed on my Mac.
I was getting the same error and I fixed it by installing the libclang-dev library for the version of clang/llvm I was using.
On Linux with LLVM version 5.0 that was (not sure what the command is on a mac - sorry):
sudo apt-get install libclang-5.0-dev
Note that the documentation suggests that these examples are designed to be run with a version of llvm/clang that you have built from source (either by downloading a tarred release or cloning the llvm repository). I was able to get them to build exclusively from a version of LLVM and Clang I installed via my package manager. I had to set the configuration variables for the Makefile as follows:
CXX := /usr/bin/clang++
LLVM_SRC_PATH := /usr/lib/llvm-5.0
LLVM_BUILD_PATH := /usr/lib/llvm-5.0/build
LLVM_BIN_PATH := /usr/lib/llvm-5.0/bin
Again, it's probably a little different on a mac, but hopefully this can help point you in the right direction.
my game is using cocos2dx 2.2.6 I have upgrade the NDK to the the NDKr12 beta1 and try to build my project then I get so many errors at the NdkModule folder and NDK complain that it doesn't found the output file in Ndk Module Path:
cocos2dx/platform/third_party/android/prebuilt/lib*/libs/arm64-v8a/file.a
what it that mean and how to fix it?
I manage to solve it by specific the target architectures at application.mk
by adding this line:
APP_ABI := armeabi armeabi-v7a x86
I have native source code written in C that I would like to run on my Android device (Nexus 7). I already successfully did lots of research and online tutorials on running native code on Android using Android NDK. I gained quite some knowledge on this.
However, the code that I have makes use of the complex functionalities of the standard math library, defined in complex.h. The NDK C library however does not seem to support the complex functionalities. Whenever I do an ndk-build on the project I get:
fatal error: complex.h: no such file or directory.
As a solution I thought of getting the standard math library (libm.a) from arm-linux-gnueabi and link it with my native source. Here is my Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := StandardC
LOCAL_SRC_FILES := libc.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := mathLib
LOCAL_SRC_FILES := libm.a
LOCAL_STATIC_LIBRARIES := StandardC
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := ComplexOperations
LOCAL_SRC_FILES := libComplexOperations.a
LOCAL_STATIC_LIBRARIES := mathLib
LOCAL_C_INCLUDES += /usr/arm-linux-gnueabi/include
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := MySource
LOCAL_CFLAGS += -std=c99
LOCAL_SRC_FILES := com_samuel_test_ComplexOperationsLib.c
LOCAL_C_INCLUDES += /usr/arm-linux-gnueabi/include
LOCAL_STATIC_LIBRARIES := ComplexOperations
include $(BUILD_SHARED_LIBRARY)
I had to link the libc of the arm-linux-gnueabi-gcc as well as libm needs it.
The "ComplexOperations" module was statically compiled using arm-linux-gnueabi-gcc with compiler flags -march=armv7-a. This library makes use of complex.h.
This builds without any errors and warnings. But when I run the application and call
System.loadLibrary("MySource");
I get this error on logcat:
E/dalvikvm( 3932): dlopen("/data/app-lib/com.samuel.test-1/libMySource.so") failed: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol ".LANCHOR2" referenced by "libMySource.so"...
On this error an UnsatisfiedLinkError exception is thrown which causes the application to crash if not handled.
Can somebody PLEAASEE help me out!! I've already tried figuring this out myself for days!! :(
As of Android-L(ollipop) the NDK now provides the complex.h header.
Download the latest NDK revision from https://developer.android.com/tools/sdk/ndk/index.html and complex.h can be found in /platforms/android-L/arch-arm/usr/include.
I added the following line to Android.mk, which seems to have fixed the problem.
LOCAL_C_INCLUDES += C:\Users\Sami\workspace\android-ndk-r8e\sources\cxx-stl\gnu-libstdc++\4.7\include\
Not sure which variable would replace the C:\Users\Sami\workspace\ part, so if anybody know, please do tell.
Edit:
Actually, that only removed the error for some reason, but it didn't fix the problem from what I noticed. On that note, C:\Users\Sami\workspace\android-ndk-r8e could have been replaced with $(NDK_ROOT).
I tried Crystax's NDK, but I kept getting the complex.h not being found error. All I did was simply copying complex.h and _mingw.h into my jni directory. Everything worked an it the code was tested on both x86 and ARM emulator.
It seems like your PATH is broken. Kindly refer to following posts to solve this issue.
Android NDK: how to include Android.mk into another Android.mk (hierarchical project structure)?
android ndk error "no such file or directory"?
SOLVED!
First of all I should've built my ComplexOperations sources with the toolchain provided by the Android NDK, as the documentation clearly states not to cross-compile with gnu compilers. So that was my first mistake.
That alone didn't yet solve my problem as I still got the complex.h not found error when I do an ndk-build. The Android NDK contains a VERY limited implementation of the Standard libc.
To solve this I used CrystaX NDK, an extended implementation of Android NDK. That solved everything!!
I met an err when I installed JikesRVM, that is,
skipping incompatible /usr/lib64/gcc/x86_64-suse-linux/4.4/libstdc++.so when searching for -lstdc++
So I am trying to install/update it to a later version. Now, the machine already has
gcc (SUSE Linux) 4.4.1 [gcc-4_4-branch revision 150839]
I am new to openSUSE, could you help?
Thanks!
You need to install 32 bit support for the GNU C/C++ compiler since JikesRVM on x86_64 currently supports only the 32 bit architecture.
To install this support in OpenSuSE 11.2 type
sudo zypper install gcc44-32bit gcc-32bit libstdc++44-devel-32bit
The first two provide runtime support for the C language and the 32-bit version of libgcc, the GCC low level runtime library. The third provides the 32-bit version of libstdc++, both the static import library and the dynamic library. It is the static libstdc++.a that was missing for JikesRVM.
To verify that the 32bit C++ build system is installed correctly you can test it with the following
echo "int main(){}" | g++ -x c++ -m32 -
Note Official support for OpenSuSE 11.2 has ended. Evergreen support will be available through 2013. Yet it is reasonable to update to 11.3 or a later version soon.