Как включить gnu-libstdc ++ в JNI-проект JNI Swing? - PullRequest
0 голосов
/ 05 февраля 2019

Я пытаюсь включить библиотеку C ++ в свой проект Swing.

Когда я компилирую jnilib / so, с stdio.h это прекрасно работает:

gcc -shared -o libhello.jnilib hello.c -fPIC -I/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/include/darwin

Я пытаюсь импортировать и мне нужно использовать gnu-libstdc ++ / 4.9 Как мне связать мой проект Java?

Когда я пытаюсь создать файл jni:

It will throw this:
test.c:5:10: fatal error: 'string' file not found
#include <string>

РЕДАКТИРОВАТЬ

Теперь, когда я ссылаюсь на это:

-I /Users/tnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86_64/include

Выдает эту ошибку:

...

/Users/tnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86_64/include/bits/ctype_base.h:69:37: error: use of undeclared identifier '_U'
    static const mask graph     = _P | _U | _L | _N;
                                       ^
/Users/tnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86_64/include/bits/ctype_base.h:69:42: error: use of undeclared identifier '_L'
    static const mask graph     = _P | _U | _L | _N;
                                            ^
/Users/tnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86_64/include/bits/ctype_base.h:69:47: error: use of undeclared identifier '_N'
    static const mask graph     = _P | _U | _L | _N;
                                                 ^
/Users/tnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86_64/include/bits/ctype_base.h:70:32: error: use of undeclared identifier '_C'
    static const mask cntrl     = _C;
                                  ^
/Users/tnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86_64/include/bits/ctype_base.h:71:32: error: use of undeclared identifier '_P'
    static const mask punct     = _P;
                                  ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

EDIT2

После добавления -I /Users/timnuwin/Documents/ndk/android-ndk-r12b/platforms/android-17/arch-x86/usr/include теперь выдает:

/Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/cwchar:164:11: error: no member named 'vfwscanf' in the global namespace
  using ::vfwscanf;
        ~~^
/Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/cwchar:170:11: error: no member named 'vswscanf' in the global namespace
  using ::vswscanf;
        ~~^
/Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/cwchar:174:11: error: no member named 'vwscanf' in the global namespace
  using ::vwscanf;
        ~~^
/Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/cwchar:191:11: error: no member named 'wcstof' in the global namespace
  using ::wcstof;
        ~~^
In file included from hello.cpp:6:
In file included from /Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/sstream:38:
In file included from /Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/istream:38:
In file included from /Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/ios:44:
In file included from /Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_ios.h:37:
In file included from /Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/locale_facets.h:39:
/Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/cwctype:89:11: error: no member named 'iswblank' in the global namespace; did you
      mean 'isblank'?
  using ::iswblank;
        ~~^
/Users/timnuwin/Documents/ndk/android-ndk-r12b/platforms/android-17/arch-x86/usr/include/ctype.h:88:5: note: 'isblank' declared here
int     isblank(int);
        ^
1 warning and 5 errors generated.

EDIT3 Хорошо, я думаю, что я немногоближе вот обновленный включает в себя ...

gcc -shared -o libhello.jnilib hello.cpp -fPIC 
-I/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/include 
-I/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/include/darwin 
-I /Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/backward 
-I /Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/bits 
-I /Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/debug 
-I /Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/decimal 
-I /Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/experimental 
-I /Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/ext 
-I /Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/parallel 
-I /Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/profile 
-I /Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/tr1 
-I /Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/tr2

Но теперь он бросает:

/Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/tr1/stdio.h:8:10: fatal error: 'tr1/cstdio' file not found #include

РЕДАКТИРОВАТЬ

Ладно, установка базового каталога включает include -I /Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include, теперь выбрасывает:

/Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/cstdio:98:11: error: no member named 'FILE' in the global namespace
  using ::FILE;
        ~~^
/Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/cstdio:99:11: error: no member named 'fpos_t' in the global namespace
  using ::fpos_t;
        ~~^
/Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/cstdio:101:11: error: no member named 'clearerr' in the global namespace
  using ::clearerr;
        ~~^
/Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/cstdio:102:11: error: no member named 'fclose' in the global namespace
  using ::fclose;
        ~~^
/Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/cstdio:103:11: error: no member named 'feof' in the global namespace
  using ::feof;
        ~~^

1 Ответ

0 голосов
/ 07 февраля 2019
clang++ -shared -o libhello.jnilib hello.cpp -fPIC -funwind-tables -no-canonical-prefixes -fexceptions -frtti -Os -g -DNDEBUG -DNDEBUG -fPIC -std=gnu++11 -I/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/include/darwin -isystem /Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem /Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include -isystem /Users/timnuwin/Documents/ndk/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/backward -I /Users/timnuwin/Documents/ndk/android-ndk-r12b/platforms/android-17/arch-x86/usr/include

Этот cmd смог создать мой файл jnilib.: D 3 дня спустя хе-хе

...