Gdal installation on Mac OS - eclipse

I’m trying to work with Gdal Library and Java in a Mac OS. But I’m new on Goal and I’m not able to make it works.
Also, I’m working with Maven. So I added this dependency on pom.xml
<dependency>
<groupId>org.gdal</groupId>
<artifactId>gdal</artifactId>
<version>2.1.0</version>
</dependency>
In order to test it on Eclipse I create a simple class like below:
import org.gdal.gdal.gdal;
import org.gdal.gdalconst.gdalconstConstants;
import org.gdal.ogr.ogr;
public class test {
public static void main(String[] args) {
gdal.AllRegister();
}
}
When I execute I’m facing with the following error:
Native library load failed.
java.lang.UnsatisfiedLinkError: no ogrjni in java.library.path
I tried to fix it all day without success. I just wanna know a simple way to execute Gdal into Eclipse.
PS: I can run Gdal successfully on terminal

You need to set the java.library.path system property when you run java. It must point to the directory containing the gdal shared libraries. I've also found that you may need to set the DYLD_LIBRARY_PATH or DYLD_FALLBACK_LIBRARY_PATH environment variable as well.
I have gdal installed via homebrew and here is what I do:
export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/opt/gdal/lib
java -Djava.library.path=/usr/local/opt/gdal/lib -cp gdal.jar ...

GDAL installation
Install arguments
Make sure you have installed gdal with java and swig-java arguments.
brew install gdal --with-java --with-swig-java
ps: remove your current gdal installation before run the command above.
You may need some additional arguments. Check all arguments using
brew info gdal
Also, you can check the arguments available below.
--with-armadillo
Build with Armadillo accelerated TPS transforms.
--with-complete
Use additional Homebrew libraries to provide more drivers.
--with-java
Build with java support
--with-libkml
Build with Google's libkml driver (requires libkml --HEAD or >= 1.3)
--with-mdb
Build with Access MDB driver (requires Java 1.6+ JDK/JRE, from Apple or Oracle).
--with-mysql
Build with mysql support
--with-opencl
Build with OpenCL acceleration.
--with-postgresql
Build with postgresql support
--with-python3
Build with python3 support
--with-swig-java
Build the swig java bindings
--with-unsupported
Allow configure to drag in any library it can find. Invoke this at your own risk.
--without-python
Build without python2 support
--HEAD
Install HEAD version
Check gdal required dependencies
Check if you have installed all dependencies required by gdal. Use
brew info gdal
to see all dependencies and if you have them installed.
==> Dependencies
Required: libpng ✔, jpeg ✔, giflib ✔, libtiff ✔, libgeotiff ✔, proj ✔, geos ✔, json-c ✔, libxml2 ✔, pcre ✔, sqlite ✔, freexl ✔, libspatialite ✔
Optional: postgresql ✘, mysql ✔, armadillo ✔
==> Requirements
Build: java >= 1.7 ✔, fortran ✔, git ✔
Optional: java >= 1.7 ✔, python3 ✔
Maven configuration
If you're using maven on your project, you need to add gdal dependency in pom.xml.
<dependency>
<groupId>org.gdal</groupId>
<artifactId>gdal</artifactId>
<version>1.11.1</version>
</dependency>
Environment variable
You have to add environment variable in Eclipse, like jdeolive said.
Run > Run Configurations
then select your application in the left and go to Environment tab.
Add DYLD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH pointing to /usr/local/opt/gdal/lib.
That's how I installed gdal and it's working perfectly on macOS 10.12.6.

Related

Cannot install zlib system headers for python packages

When installing python packages with poetry on Catalina OS I get this error for Pillow 6.2.1
The headers or library files could not be found for zlib,
a required dependency when compiling Pillow from source.
Even after I installed zlib with homebrew and added the relevant lines for the zshrc profile
export LDFLAGS="-L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"
I use python 3.8.0 which matches with the Pillow version I am trying to install.
I don't know what else to do.

cannot link libpq on Mac M1

I've been trying to run the Rust Diesel crate on my Macbook M1 and it doesn't work. The final part of the compilation gets broken by the following error:
= note: ld: warning: ignoring file /usr/local/Cellar/libpq/14.1/lib/libpq.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
When I get the info for libpq I get the following:
maxwellflitton#Maxwells-MacBook-Pro vanguard % brew info libpq
libpq: stable 14.1 (bottled) [keg-only]
Postgres C API library
https://www.postgresql.org/docs/14/libpq.html
/usr/local/Cellar/libpq/14.1 (2,335 files, 27.8MB)
Poured from bottle on 2022-01-09 at 00:14:32
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libpq.rb
License: PostgreSQL
==> Dependencies
Required: krb5 ✔, openssl#1.1 ✔
==> Caveats
libpq is keg-only, which means it was not symlinked into /usr/local,
because conflicts with postgres formula.
If you need to have libpq first in your PATH, run:
echo 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> ~/.zshrc
For compilers to find libpq you may need to set:
export LDFLAGS="-L/usr/local/opt/libpq/lib"
export CPPFLAGS="-I/usr/local/opt/libpq/include"
I've tried installing with the following command:
RUSTFLAGS='-L /usr/local/Cellar/libpq/14.1/lib' cargo install diesel_cli --no-default-features --features postgres --force
But I still get the same error. Will it just be easier to wipe the whole thing and start again and if so how would I do this? Other people on the internet using the M1 seem to be able to get round the problem with a simple brew install libpq. Never had any issues with my previous intel mac. My ~/.cargo/config.toml has the following configuration:
[target.aarch64-apple-darwin]
rustflags = '-L /usr/local/Cellar/libpq/14.1/lib -L /opt/homebrew/lib'
Surprisingly this worked
brew install postgresql libpq
cargo clean
cargo build
cargo install diesel_cli --no-default-features --features postgres
I think it had to do with installing diesel-cli before installing the necessary dependencies. Cleaning the cargo dependencies and reinstalling worked for me
on my M1 mac, I installed the postgresql client and library with brew:
brew install postgresql libpq
and attempted to install diesel_cli again, this time it worked fine:
cargo install diesel_cli --no-default-features --features postgres
for some reason, simply installing libpq was not enough to install diesel_cli, i had to install the postgres library and the client.
Encountered a similar problem, and the issue was coming from my brew config (I restored my filesystem from my mac Intel) :
❯ brew config
...
macOS: 12.6-x86_64
...
Therefore, brew was downloading packages built for intel processors. I uninstalled and reinstalled brew following their website and now brew config is correct:
❯ brew config
...
macOS: 12.6-arm64
...
Hope this helps!
I have a Mac M1 and installed both postgresql and libpq with brew
I eventually succeeded in installing diesel_cli with these lines in my ~/.cargo/config.toml file
[target.aarch64-apple-darwin]
rustflags = '-L /opt/homebrew/opt/libpq/lib -L /opt/homebrew/lib'
source was https://github.com/diesel-rs/diesel/issues/2605

Building fontconfig with freetype in non standard user home directories fails to find the freetype dependency

I successfully built freetype with the following steps:
Download the file freetype-2.7.1.tar.gz from http://www.freetype.org/download.html#stable
The 2.7.1 version is a version that can be built into the GD library. The 2.8 and 2.8.1 version prevented the GD library from building.
./configure \
--prefix=/home/stephane/programs/install \
--with-bzip2
make
make install
I'm now trying to build fontconfig but it fails to find freetype in the following steps:
Download the file fontconfig-2.12.91.tar.gz from https://www.freedesktop.org/software/fontconfig/release/
./configure \
--prefix=/home/stephane/programs/install
checking for FREETYPE... no
configure: error: Package requirements (freetype2) were not met:
No package 'freetype2' found
I'm running Ubuntu 16.04

Can't install jdk on Fedora with yum nor with rpm

Help! I can't figure out how to install a jdk!
[/usr/lib/jvm]$ su -c "yum install java-1.7.0-openjdk-devel"
Loaded plugins: langpacks, presto, refresh-packagekit
No package java-1.7.0-openjdk-devel available.
Error: Nothing to do
[/usr/lib/jvm]$ su -c "yum install java-1.7.0-openjdk"
Loaded plugins: langpacks, presto, refresh-packagekit
No package java-1.7.0-openjdk available.
Error: Nothing to do
[/usr/lib/jvm]$ su -c "yum install java-1.6.0-openjdk-devel"
Loaded plugins: langpacks, presto, refresh-packagekit
No package java-1.6.0-openjdk-devel available.
Error: Nothing to do
[/usr/lib/jvm]$ su -c "yum install java-1.6.0-openjdk"
Loaded plugins: langpacks, presto, refresh-packagekit
No package java-1.6.0-openjdk available.
Error: Nothing to do
Here I've manually downloaded some rpm's, the last one from oracle's website:
[~]$ rpm -ivh java-1.7.0-openjdk-devel-1.7.0.19-2.3.9.3.fc20.x86_64.rpm
error: Failed dependencies:
java-1.7.0-openjdk = 1:1.7.0.19-2.3.9.3.fc20 is needed by java-1.7.0-openjdk-devel-1:1.7.0.19-2.3.9.3.fc20.x86_64
[~]$ sudo rpm -ivh java-1.7.0-openjdk-1.7.0.19-2.3.9.3.fc20.x86_64.rpm
Preparing... ################################# [100%]
file /usr/lib/jvm-exports/jre-1.7.0-openjdk.x86_64 from install of java-1.7.0-openjdk-1:1.7.0.19-2.3.9.3.fc20.x86_64 conflicts with file from package java-1.7.0-openjdk-1:1.7.0.9-2.3.7.0.fc18.x86_64
file /usr/lib/jvm/jre-1.7.0-openjdk.x86_64 from install of java-1.7.0-openjdk-1:1.7.0.19-2.3.9.3.fc20.x86_64 conflicts with file from package java-1.7.0-openjdk-1:1.7.0.9-2.3.7.0.fc18.x86_64
[~]$ sudo rpm -ivh jdk-7u21-linux-x64.rpm
Preparing... ################################# [100%]
file /etc/init.d/jexec from install of jdk-2000:1.7.0_21-fcs.x86_64 conflicts with file from package jdk-2000:1.6.0_38-fcs.x86_64
Debug
Here's some debug information:
[/usr/lib/jvm]$ yum search jdk
Loaded plugins: langpacks, presto, refresh-packagekit
=========================================================== N/S Matched: jdk ============================================================
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
jdk.x86_64 : Java(TM) Platform Standard Edition Development Kit
ldapjdk.noarch : The Mozilla LDAP Java SDK
Name and summary matches only, use "search all" for everything.
.
[/usr/lib/jvm]$ yum list java*
Loaded plugins: langpacks, presto, refresh-packagekit
Installed Packages
java-1.5.0-gcj.x86_64
.
[/usr/lib/jvm]$ cat /etc/fedora-release
Fedora release 18 (Spherical Cow)
Requirements
I must have "jni.h", "libjava.so", "libhpi.so", "lipverify.so" and "libjvm.so" included.
So far I've found out that these DO NOT have what I need:
Undesired Versions (for sure):
jdk1.7.0_06 <-- I'm surprised about this one, but it doesn't have libjvm nor libhpi
java-1.7.0
java-openjdk
java-1.7.0-openjdk-1.7.0.9.x86_64
java-1.5.0-gcj-4.4
java-1.6.0-openjdk
java-1.7.0-openjdk.x86_64
jre-1.5.0-gcj
jre-1.7.0-openjdk.x86_64
jre-openjdk
jre-1.7.0
jre-7u11-linux-x64.rpm java-1.5.0-gcj-1.5.0.0
jre-1.5.0
jre1.7.0_11
jre-gcj
And these do:
Desired Versions (that I know of, there could be more):
jdk1.6.0_34-x86
jdk1.5.0_22-x86
java-6-openjdk
Can someone help me install jdk1.6 or java-6-openjdk please?
The problem here is that you cannot use the Oracle rpm to install JDK 7 when you already have the Oracle JDK 6 as it tries to install the /etc/init.d/jexec script which is already installed and required for JDK 6.
I would advise sticking to the tarball or self extracting *.bin and using JAVA_HOME if you are going to use the Oracle distribution as it does not have this problem and you will probably not need jexec anyway.
In general I would suggest that you install the Oracle JDK not the OpenJDK. Otherwise you might risk running into some issues. I always found problems of all sorts and sizes with OpenJDK that I don't even bother trying it any more.
Download the JDK RPM from here and follow the usual instructions. Its usually very straightforward and without problems.
Full detailed instructions including how to install it here.
Make sure you choose the right version you need (JDK 1.7 or JDK 1.6, dont mix) because from your question you seem to have a confusion of library versions from 1.5 to 1.7.
And another thing, uninstall whatever you have installed already before installing a fresh one to avoid conflicts.
Check my answer here Transaction check error when installing Sun JDK 7
Basically you may use rpm --force to install one JDK on top of the other. This scenario is completely valid specially when you have to develop for different JAVA versions.
Just faced the same issue. I was not comfortable using --force command; did not want to risk messing-up the existing Java that came installed at system setup.
I ended up doing the following and running the app server with a different version of Java under a different user ID.
downloaded the Java tar.gz version and uncompressed:
tar -zxvf jdk-7u45-linux-x64.gz
Created the directory:
mkdir /usr/java/jdk1.7.0_45
Copied the contents to the new directory manually:
cp -r /.../jdk1.7.0_45/* /usr/java/jdk1.7.0_45
Set the java_home under the user ID home directory in .bashrc and .bash_profile files:
export JAVA_HOME=/usr/java/jdk1.7.0_45
export PATH=$JAVA_HOME/bin:$PATH
export PATH=$PATH:/usr/sfw/lib/gcc:/usr/sfw/bin
sudo rpm -i jdk-11.0.9_linux-x64_bin.rpm
or whatever package you are trying to install

Installing redmine_contacts plugin for bitnami_redmine

I am trying to install redmine_contacts plugin for my redmine 2.2.3.0 (which is installed using BITNami installer), as in readme.rdoc:
Copy redmine_contacts plugin to {RAILS_APP}/plugins on your redmine path
Run bundle install --without development test RAILS_ENV=production
Run rake redmine:plugins NAME=redmine_contacts RAILS_ENV=production
The first two steps was successful, but last executing last command, following error would occur:
(in /home/.../redmine-2.2.3-0/apps/redmine/htdocs)
Could not find sprockets-2.2.1 in any of the sources
Run bundle install to install missing gems.
To see if the sprockets library is installed by executing command: #bundle show sprockets, it shows a newer version of this library is installed:
/var/lib/gems/1.8/gems/sprockets-2.2.2
I think somehow the BitNami version of gem which is installed is not compatible with the sprockets-2.2.2 on the system and it requires 2.2.1. Maybe you should change to that version.
Try something like:
gem install sprockets -v 2.2.1