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

Is it possible to generate binding for already compiled shared library for Android? #56

Open
mSerdcevas opened this issue Apr 30, 2021 · 3 comments

Comments

@mSerdcevas
Copy link

Hello,
I couldn't find example how to generate binding for already compiled library. I tried using gradle-javacpp-android as example but I couldn't figure out how can I link my shared library.
I have 4 libraries for 4 architectures:

lib
|-arm64-v8a
    |-libtest_library.so
|-armeabi-v7a
    |-libtest_library.so
|-x86
    |-libtest_library.so
|-x86_64
    |-libtest_library.so

test.h

#ifndef UNTITLED1_TEST_H
#define UNTITLED1_TEST_H

class Test {
    int m_val;
public:
    Test();

    int get_val();
};

#endif //UNTITLED1_TEST_H

@saudet
Copy link
Member

saudet commented Apr 30, 2021

Sure, what is the issue exactly?

@mSerdcevas
Copy link
Author

This is my forked example I added libs to src/main/jniLibs added my test.h to src/main/cpp and edited NativeLibraryConfig

package com.example.myapplication;

import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.annotation.*;
import org.bytedeco.javacpp.tools.*;

@Properties(
    value = @Platform(include = {"NativeLibrary.h", "test.h"}),
    target = "com.example.myapplication.NativeLibrary"
)
public class NativeLibraryConfig implements InfoMapper {
    static {
        // Let Android take care of loading JNI libraries for us
        System.setProperty("org.bytedeco.javacpp.loadLibraries", "false");
    }

    public void map(InfoMap infoMap) {
    }
}

Where should I specify linkage to my test_library? Without linking to my library I get error:

app/src/main/cpp/jniNativeLibrary.cpp:760: error: undefined reference to 'Test::Test()'

@saudet
Copy link
Member

saudet commented Apr 30, 2021

You'll need to add that to the CMakeLists.txt file. This isn't related to JavaCPP, but with the CMake build system that comes with Android Studio.

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

No branches or pull requests

2 participants