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

copyToTarget function appends "lib" to file name. #1

Closed
jersilver opened this issue Jul 5, 2014 · 3 comments · Fixed by #3
Closed

copyToTarget function appends "lib" to file name. #1

jersilver opened this issue Jul 5, 2014 · 3 comments · Fixed by #3

Comments

@jersilver
Copy link

Hi,

Great plugin!

I found that when libs are copied to the jniLibs directory, the .so file names are appended with "lib". So if the file name was originally "test.so", it becomes "libtest.so".

This is leading to linkage problems. Is there any reason you need to append "lib" to the filenames?

Thanks!

@nhachicha
Copy link
Collaborator

Hi,

This is the convention, the module name is used to name the generated file as a result of the build process (if you build from NDK a module name hello-jni the generated shared library will be named as libhello-jni.so)

also from the http://developer.android.com/training/articles/perf-jni.html (Native Libraries Chapter)

-- The argument is the "undecorated" library name, so to load "libfubar.so" you would pass in "fubar".

@jersilver
Copy link
Author

Hi Nabil,

Thank you for the quick reply.

Where this seems to become a problem is if the module name always has "lib" prefixed to the name. Here's an example:

We use SqlCipher to encrypt Sqlite DBs. SqlCipher provides native (.so) libraries that already have "lib" prefixed on the file name. For example, one of the files is "libdatabase_sqlcipher.so".

When we use the plugin, an extra "lib" is prefixed on the name, so we get "liblibdatabase_sqlcipher.so", which is not correct. I'd rather modify the plugin than change the name of the files we get from the vendor.

One suggestion/enhancement for the tool would be to check if "lib" is already prefixed on the name OR, have a parameter/option to control the prefixing.

Thanks,
~Jeremy

@nhachicha
Copy link
Collaborator

Interesting...
AFAIK SqlCipher never made it to maven central (or any other public repo) see issue #33

so I guess you're installing manually the lib using mvn install:install
if this is the case, you need to follow the convention above, so maven will create the correct POM.xml (without the lib prefix as part of the artifact name)

Example:

  • remove previous installation of SqlCipher
rm -Rf  ~/.m2/repository/net/sqlitecipher/ 
  • install correctly the native lib
mvn install:install-file -Dfile=libdatabase_sqlcipher.so -DgroupId=net.sqlitecipher -DartifactId=database_sqlcipher -Dversion=2.1.1 -Dpackaging=so -Dclassifier=armeabi

notice how artifactId doesn't include the lib prefix

maven will create the following POM.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>net.sqlitecipher</groupId>
  <artifactId>database_sqlcipher</artifactId>
  <version>2.1.1</version>
  <packaging>so</packaging>
  <description>POM was created from install:install-file</description>
</project>

now you can use your library using the Gradle plugin as follow:

native_dependencies {
    artifact 'net.sqlitecipher:database_sqlcipher:2.1.+:armeabi'
}

Hopefully this will work for you.

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