frett27 / jfgdb

Java File Geodatabase (FGDB) JNI Wrapper, permit to read/write simple features in .gdb from Java
Apache License 2.0
13 stars 11 forks source link

Error in building the jar and native wrappers #7

Closed YuChenu closed 3 years ago

YuChenu commented 3 years ago

Hi, I am very interested in jfgdb project. I want to build the jar and native wrappers on Linux. However,when I execute the code according to the method you give:gradlew build -x test distZip, the problem arised. The specific problems were as follows: `Execution failed for task ':jfgdb:transfertPreparedBinaries'.

Unable to load AWS credentials from any provider in the chain: [EnvironmentVariableCredentialsProvider: Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY)), SystemPropertiesCredentialsProvider: Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey), com.amazonaws.auth.profile.ProfileCredentialsProvider@7434ee13: profile file cannot be null, com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper@14b48f39: Unable to load credentials from service endpoint]`. Hence, can you solve the problem?thank you!

frett27 commented 3 years ago

Theses are needed for deployment, change the build.gradle to skip this step (not needed in you case)

YuChenu commented 3 years ago

I have generated jars and native wrappers according to the steps, but when I used them, the following errors occur: undefined symbol: _ZN10FileGDBAPI8IndexDefC1ERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEES8_b (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI17CreateGeodatabaseERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEERNS_11GeodatabaseE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI3Row8SetFloatERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEf (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI5Table16GetDocumentationERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI11Geodatabase6RenameERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEES8_S8_ (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI11Geodatabase12GetQueryNameERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEERS6_ (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI8FieldDef7SetNameERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI5Table13DeleteSubtypeERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE(./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI3Row9SetStringERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEES8_ (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI16SpatialReference23SetSpatialReferenceTextERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI11Geodatabase19GetDomainDefinitionERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEERNS2_IcS3_IcESaIcEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI11Geodatabase11CreateTableERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS2_IwS3_IwESaIwEEERNS_5TableE (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI3Row7GetGUIDERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEERNS_4GuidE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI5Table11DeleteFieldERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI5Table6SearchERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEES8_bRNS_8EnumRowsE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI9ErrorInfo19GetErrorDescriptionEiRNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI11Geodatabase15GetDatasetTypesERSt6vectorINSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEESaIS7_EE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI11Geodatabase12DeleteDomainERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI3Row6SetXMLERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEERKNS2_IcS3_IcESaIcEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI3Row6GetXMLERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEERNS2_IcS3_IcESaIcEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI11Geodatabase12CreateDomainERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI3Row7SetNullERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI3Row9GetDoubleERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEERd (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI5Table8AddIndexERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI5Table8AddFieldERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI11Geodatabase11AlterDomainERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI8IndexDef9SetFieldsERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI11Geodatabase9OpenTableERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEERNS_5TableE (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI8FieldDef8GetAliasERNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI11Geodatabase18GetRelatedDatasetsERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEES8_S8_RSt6vectorIS6_SaIS6_EE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI4Guid10FromStringERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI17DeleteGeodatabaseERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI11Geodatabase16GetChildDatasetsERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEES8_RSt6vectorIS6_SaIS6_EE (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI11Geodatabase10GetDomainsERSt6vectorINSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEESaIS7_EE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI11Geodatabase4MoveERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEES8_(./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI8FieldDef8SetAliasERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI11Geodatabase6DeleteERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEES8_ (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI11Geodatabase28GetRelatedDatasetDefinitionsERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEES8_S8_RSt6vectorINS2_IcS3_IcESaIcEEESaISC_EE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI5Table14EnableSubtypesERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEERKNS2_IcS3_IcESaIcEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI5Table6SearchERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEES8_RKNS_8EnvelopeEbRNS_8EnumRowsE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI4Guid8ToStringERNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI3Row7SetDateERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEERK2tm (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI3Row10GetIntegerERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEERi (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI3Row8GetFloatERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEERf (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI3Row6IsNullERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEERb (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI3Row9GetStringERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEERS6_ (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI5Table10GetIndexesERSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI11Geodatabase20CreateFeatureDatasetERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI3Row10SetIntegerERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEi (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI5Table16SetDocumentationERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI8IndexDef9GetFieldsERNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI9FieldInfo12GetFieldNameEiRNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI3Row7SetGUIDERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEERKNS_4GuidE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI5Table11DeleteIndexERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI8IndexDef7SetNameERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI3Row8GetShortERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEERs (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI5Table10AlterFieldERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI8IndexDef7GetNameERNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI3Row7GetDateERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEER2tm (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI3Row9SetDoubleERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEd (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI5Table13GetDefinitionERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI11Geodatabase23GetDatasetDocumentationERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEES8_RNS2_IcS3_IcESaIcEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI11Geodatabase26GetChildDatasetDefinitionsERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEES8_RSt6vectorINS2_IcS3_IcESaIcEEESaISC_EE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI5Table13CreateSubtypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI11Geodatabase27GetDatasetRelationshipTypesERSt6vectorINSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEESaIS7_EE (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI11Geodatabase10ExecuteSQLERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEbRNS_8EnumRowsE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI5Table12AlterSubtypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI8FieldDef7GetNameERNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI11Geodatabase20GetDatasetDefinitionERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEES8_RNS2_IcS3_IcESaIcEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI3Row8SetShortERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEs (./libFGDBJNIWrapper.so) undefined symbol: _ZNK10FileGDBAPI16SpatialReference23GetSpatialReferenceTextERNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE (./libFGDBJNIWrapper.so) undefined symbol: _ZN10FileGDBAPI15OpenGeodatabaseERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEERNS_11GeodatabaseE (./libFGDBJNIWrapper.so) Are these errors caused by my mistakes or by jfgdb itself? Thank you!

frett27 commented 3 years ago

If you are on linux plateform, because the esri fjdb shared library has some dependency, you have currently to set the LD_LIBRARY_PATH environment variable pointing to the folder with nativewrapper + its dependencies. This is not currenlty needed on windows, as the OS also use the sharedlibrary full path to lookup associated dependencies.

YuChenu commented 3 years ago

If you are on linux plateform, because the esri fjdb shared library has some dependency, you have currently to set the LD_LIBRARY_PATH environment variable pointing to the folder with nativewrapper + its dependencies. This is not currenlty needed on windows, as the OS also use the sharedlibrary full path to lookup associated dependencies.

I have set the LD_LIBRARY_PATH environment to point the FileGDB API by ESRI by edit th .bashrc file: JFGDB Path export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/hyc/Install/JFGDB/nativewrapper export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/hyc/Install/FileGDB_API-64/lib The dynamic link library required by libFGDBJNIWrapper.so is as follows: ldd /home/hyc/IdeaPro/GDAL_Pro1/lib/libFGDBJNIWrapper.so linux-vdso.so.1 => (0x00007ffcad977000) libFileGDBAPI.so => /home/hyc/Install/FileGDB_API-64/lib/libFileGDBAPI.so (0x00007f49b3c73000) libfgdbunixrtl.so => /home/hyc/Install/FileGDB_API-64/lib/libfgdbunixrtl.so (0x00007f49b39f0000) libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f49b512a000) libm.so.6 => /lib64/libm.so.6 (0x00007f49b36ee000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f49b34d8000) libc.so.6 => /lib64/libc.so.6 (0x00007f49b310a000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f49b2f06000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f49b2cea000) librt.so.1 => /lib64/librt.so.1 (0x00007f49b2ae2000) /lib64/ld-linux-x86-64.so.2 (0x00007f49b507f000) The dynamic link library required by libFileGDBAPI.so is as follows: linux-vdso.so.1 => (0x00007fffa0d89000) libfgdbunixrtl.so => /home/hyc/Install/FileGDB_API-64/lib/libfgdbunixrtl.so (0x00007f2c913ce000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f2c911ca000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f2c90fae000) librt.so.1 => /lib64/librt.so.1 (0x00007f2c90da6000) libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f2c928bc000) libm.so.6 => /lib64/libm.so.6 (0x00007f2c90aa4000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f2c9088e000) libc.so.6 => /lib64/libc.so.6 (0x00007f2c904c0000) /lib64/ld-linux-x86-64.so.2 (0x00007f2c92812000) The error while I use the jar and .so file in Linux : symbol lookup error: /home/hyc/IdeaPro/GDAL_Pro1/lib/libFGDBJNIWrapper.so: undefined symbol: _ZNK10FileGDBAPI11Geodatabase10GetDomainsERSt6vectorINSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEESaIS7_EE Can you give me some specific advice or tell me how to use jfgdb in Linux. Thanks!

frett27 commented 3 years ago

on linux, wrapper must have all dependencies declared in the LD _LIBRARY_PATH, once the wrapper is inited, the dependencies are copied to /tmp, here is files concerned :

use@alexa:~/tmp/fgdbexample/jfgdb/samples/CRUDSample$ ll /tmp/fgdbsharedlibs/0.1.4/ total 18288 drwxrwxr-x 2 use use 4096 août 22 23:02 ./ drwxrwxr-x 3 use use 4096 août 22 23:02 ../ -rw-rw-r-- 1 use use 380424 août 22 23:02 libFGDBJNIWrapper.so -rw-rw-r-- 1 use use 646471 août 22 23:02 libfgdbunixrtl.so -rw-rw-r-- 1 use use 17688158 août 22 23:02 libFileGDBAPI.so

then, export LD_LIBRARY_PATH=/tmp/fgdbsharedlibs/0.1.4/ and run the application,

frett27 commented 3 years ago

i recorded an example on howto use compile samples, https://asciinema.org/a/qOjFQITZVowgUHQ0mAuHvLTzW

YuChenu commented 3 years ago

i recorded an example on howto use compile samples, https://asciinema.org/a/qOjFQITZVowgUHQ0mAuHvLTzW

Thank you for your answer.I have set the LD_LIBRARY_PATH as you said and the problem has solved.However, I have a new problem: How can I get the XYResolution and XYTolerance of the layer in the database?Does jfgdb not support reading the XY resolution and tolerance of layers in the database?Thanks !

frett27 commented 3 years ago

jfgdb has descriptions of datasets, and layers, table stored in XML format, this is part of the filegeodatabase format. These informations can be retrieved from the fgdb wrapper objects.

In the jfgdb library, there are some additional XML Object mapper you can use to unserialize it and use plain old java objects to has these informations. Depending on the version of the .gdb there might have some extensions you'll need to manage.