Code Monkey home page Code Monkey logo

Comments (6)

kyle-github avatar kyle-github commented on June 28, 2024

The C runtime environment of Android has diverged from that of "stock" Linux so this might be a bit more challenging than a "pure" POSIX system. I will look into it when I get a chance. However, my current priority is working on version 2.0 which has a very different internal structure so I probably will not be able to get to this for a while.

I will keep this in mind as I work on 2.0 and hopefully I can make sure that the Android port will be fairly painless.

from libplctag.

nmnhero avatar nmnhero commented on June 28, 2024

Understood. But by "a while", do you mean months or years?

from libplctag.

kyle-github avatar kyle-github commented on June 28, 2024

Months. Hopefully only a few. I am really busy right now and the 2.0 code
is taking a lot longer than I had hoped.

On Sun, Feb 14, 2016 at 7:52 PM nmnhero [email protected] wrote:

Understood. But by "a while", do you mean months or years?


Reply to this email directly or view it on GitHub
#26 (comment)
.

from libplctag.

kyle-github avatar kyle-github commented on June 28, 2024

I am moving to a CMake-based build system. I think this will help isolate platform dependencies, but I have only just managed to get Linux builds working.

from libplctag.

ornithophile avatar ornithophile commented on June 28, 2024

@kyle-github I just compiled this with Termux, the only thing I had to change was to replace pthread_cancel() with pthread_kill() since Android's standard C library (Bionic) doesn't have pthread_cancel(). I can't test though, I can't get the dang OpenVPN app to work.

from libplctag.

GitHubDragonFly avatar GitHubDragonFly commented on June 28, 2024

To find all Android related deficiencies in any of the new plctag library releases, these would probably be the good steps to follow in Android Studio:

  • Start a new Android Studio project

  • Select "Native C++" template

  • Choose Name / PackageName / Location, Java Language (or Kotlin) and Minimum SDK

  • On the next screen "Customize C++ Support" select "Toolchain Default" (or if you know what you are doing one of C++11 / C++14 / C++17)

  • In the newly created project, remove CMakeLists.txt and native-lib.cpp files from the "cpp" folder as well as all related entries in the MainActivity.java and activity_main.xml layout

  • Copy all your libplctag project files and folders to the "cpp" folder

  • Copy Tag.java file from the library project, wrappers/java/libplctag folder, to the folder where the MainActivity.java file is (normally app/src/main/java/{PackageName folders}). Modifications are needed to this file in order to make it usable:

    1. Change package from "libplctag" to your PackageName (which might be: com.example.plctagtest)

    2. Change all the jna imports to read "com.sun.jna" instead of "dev.java.net.jna"

    3. Remove "void" from: private static native int plc_tag_get_lib_version(void);

    4. Replace "private static native int plc_tag_check_lib_version(int encoded_version);" with "private static native int plc_tag_check_lib_version(int req_major, int req_minor, int req_patch);"

    5. Comment out the following entries, which are at the beginning of the class:
      public static final String JNA_LIBRARY_NAME = "plctag";
      public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(Tag.JNA_LIBRARY_NAME);
      Native.register(Tag.JNA_LIBRARY_NAME);
      System.err.printLn("Library must be compatible with version 2.1.0!");
      System.abort();

         You should instead register the library in your MainActivity with:  static { Native.register(Tag.class, "plctag"); }
      
  • Download jna.aar file: https://github.com/java-native-access/jna/blob/master/dist/jna.aar

  • On the menu click File/Project Structure, in the new window select Modules, click "+", select "Import .JAR/.AAR package" and browse to the download location to select the file

  • Add to the app's build.gradle file "implementation project(':jna')" as a part of the "dependencies"

  • On the menu click File/Save All and then File/Sync Project with Gradle Files

  • Build/Rebuild Project (infrequent use of Build/Refresh Linked C++ Projects, File/Invalidate Caches / Restart might also help)

One of the first errors might be related to the deleted native-lib.cpp, so just do Build/Rebuild Project again.

Plctag related errors should be within CMakeLists.txt file, related to "examples" and "tests".

Otherwise the library should compile fine.

from libplctag.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.