Closed YangRongAtGit closed 7 years ago
environment The target android SDK version is 25 android studio version 2.3
What I did is copied header and source files into android project and use CMake to generate project files containing all sources and hearders. And to generate a shared library for an android application
During that process, I have following compile issues. In the file mrmuldv.c (renamed from mrmuldv.g64 or for 32 bit system mrmuldv.gcc)
mr_small muldvm(mr_small a,mr_small c,mr_small m,mr_small *rp)
{
mr_small q;
__asm__ __volatile__ (
"movl %1,%%edx\n"
"movl %2,%%eax\n"
"divl %3\n"
"movl %4,%%ebx\n"
"movl %%edx,(%%ebx)\n"
"movl %%eax,%0\n"
: "=m"(q)
: "m"(a),"m"(c),"m"(m),"m"(rp)
: "eax","ebx","memory"
);
return q;
}
I tried both version of the mrmuldv.c the 32 bit version has following error Error:(76, 7) error: unknown register name 'rax' in asm
the amd64 version has following error Error:(21, 7) error: unknown register name 'eax' in asm
I also tried to remove the mrmuldv.c from the project. It turns out mrarth1.c, mrarth2.c, mrbuild.c and other files are calling function in the mrmuldv.c.
Is there a way I could disable the usage of assembly language in MIRACL? e.g using MR_NOASM?
It seems I should use mrmuldv.ccc. Will give it a try soon.
All suggestions are welcome
Thanks
Rong
Hello,
Problem here is that you are attempting to build for an Intel x86 target, whereas your processor is probably an ARM. Its probably best not to start with any assembly language.
Best to start with a standard C build of the library.
Mike
On Wed, Mar 29, 2017 at 11:30 PM, r0nG notifications@github.com wrote:
environment The target android SDK version is 25 android studio version 2.3
I tried both version of the mrmuldv.c the 32 bit version has following error Error:(76, 7) error: unknown register name 'rax' in asm
the amd64 version has following error Error:(21, 7) error: unknown register name 'eax' in asm
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/miracl/MIRACL/issues/45#issuecomment-290246138, or mute the thread https://github.com/notifications/unsubscribe-auth/ACm8jrSoI2Dkz7tZRlB_pibPXxm-z6KZks5rqttzgaJpZM4MrFmw .
Hello Mike, Thanks for your suggestion. I realised that there is a ARM.txt file in the repository. I was using incorrect setting file.
Thanks
Sure, but that file contains in-line assembly language. You need to rename mrmuldv.ccc to mrmuldv.c
Alternatively follow instructions in ARM.TXT
Mike
On Thu, Mar 30, 2017 at 1:14 AM, r0nG notifications@github.com wrote:
Hello Mike, The error is from mrmuldv.c which is renamed from mrmuldv.g64. It is in the MIRACL library. I will edit my comment to make it clear.
Thanks
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/miracl/MIRACL/issues/45#issuecomment-290264246, or mute the thread https://github.com/notifications/unsubscribe-auth/ACm8jo9uY2K_dbBpuYcbQWb8O5PZZasLks5rqvPggaJpZM4MrFmw .
@YangRongAtGit Can you tell me steps to use this library in android project. I am very much new to android so. Thanks in advance.
Sorry, I have no experience of using MIRACL with Android. However as I indicated it can be configured as a pure C library.
So its just programming...
Mike
On Thu, Mar 30, 2017 at 6:56 PM, npj008 notifications@github.com wrote:
@YangRongAtGit https://github.com/YangRongAtGit Can you tell me steps to use this library in android project. I am very much new to android so. Thanks in advance.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/miracl/MIRACL/issues/45#issuecomment-290491232, or mute the thread https://github.com/notifications/unsubscribe-auth/ACm8jvi1P2d2oGXQL4fZS_J7iBOGXwy4ks5rq-zHgaJpZM4MrFmw .
For the developers who is using android studio 2.3 here is the CMake file for MIRACL. If the cmake file already in the project, I am sorry for the duplicated post :)
set (MIRACLE_SOURCE_DIR src/main/cpp/miracl/)
include_directories(${MIRACLE_HEADER_DIR})
file(GLOB MIRACLE_HEADER_FILES ${MIRACLE_SOURCE_DIR}/*.h)
file(GLOB MIRACLE_SOURCE_FILES ${MIRACLE_SOURCE_DIR}/*.c)
add_library( # Sets the name of the library.
mrc-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
src/main/cpp/mrc-lib.cpp
${MIRACLE_HEADER_FILES}
${MIRACLE_SOURCE_FILES}
)
find_library(log-lib log)
target_link_libraries(mrc-lib ${log-lib} )
Another thing is it seems google fixed the bug mentioned in the ARM.txt. I run a test in a glue function as the doc stated:
unsigned long long x;
unsigned long a,b;
a=0;
b=0xFFFFFFFF;
x=(unsigned long long)a-b;
The result is :
(lldb) p x
(unsigned long long) $1 = 18446744069414584321
(lldb) p/x x
(unsigned long long) $2 = 0xffffffff00000001
@npj008 I am not an expert of android studio 2.3. By some reason I really dislike Java. Although I spent all my time in uni using Java as my main programming language. Anyway, the way I integrate MIRACL into an android studio 2.3 project is:
extern "C"
{
...
shs256_hash(...);
}
9. Clean & rebuild-> RUN your test
Thanks for your super steps. I will try your step today. If you have any working demo project of android studio, then please attach at joshinikunj008 at gmaiel dot com Thank you...
You might want to take a look at https://github.com/miracl/incubator-milagro-mfa-sdk-android.
It is an Android SDK that wraps some crypto functionality. The crypto lib is not MIRACL
, but its successor. In any case, you can see how the C/C++ code is wrapped in an Android/Java code.
It also builds with Android Studio, so it will be helpful for you.
Anywhere I could find a guide about use the library on Android studio 2.3? Thanks [SLOVED]