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

fatal error: gdal.h: No such file or directory #96

Open
lithium555 opened this issue Nov 8, 2023 · 2 comments
Open

fatal error: gdal.h: No such file or directory #96

lithium555 opened this issue Nov 8, 2023 · 2 comments

Comments

@lithium555
Copy link

lithium555 commented Nov 8, 2023

Hi! I have erorr:

go build cmd/main.go
# github.com/lukeroth/gdal
/root/go/pkg/mod/github.com/lukeroth/[email protected]/gdal.go:44:11: cannot define new methods on non-local type C.CPLErr
/root/go/pkg/mod/github.com/lukeroth/[email protected]/gdal.go:60:11: cannot define new methods on non-local type C.OGRErr
In file included from /root/go/pkg/mod/github.com/lukeroth/[email protected]/algorithms.go:4:0:
./go_gdal.h:8:10: fatal error: gdal.h: No such file or directory
 #include <gdal.h>
          ^~~~~~~~
compilation terminated.

I tried to solve this problem, like here https://stackoverflow.com/questions/72887400/install-gdal-on-linux-ubuntu-20-04-4lts-for-python but it didnt help.

I tried to fix troubles with gdall library, I installed on OS:

sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-get update
sudo apt-get install gdal-bin
sudo apt-get install libgdal-dev

But it didnt help.

Whitch GDAL version I have at present time:

apt list --installed | grep "gdal"

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

gdal-bin/bionic,now 2.2.3+dfsg-2 arm64 [installed]
gdal-data/bionic,now 2.2.3+dfsg-2 all [installed,automatic]
libgdal-dev/bionic,now 2.2.3+dfsg-2 arm64 [installed]
libgdal20/bionic,now 2.2.3+dfsg-2 arm64 [installed,automatic]


gdalinfo --version
GDAL 2.2.3, released 2017/11/20

If we speak about another libraries, which we need to install near GDAL, I installed them in Docker container via command:

RUN apt-get update && apt-get upgrade -yy && apt-get install -yy \
    wget \
    git \
    build-essential \
    git \
    clang-3.8 \
    libpng-dev \
    libopencv-dev \
    libgeos-dev \
    libproj-dev && \
    apt remove cmake -y && \
    pip3 install --upgrade pip && \
    pip3 install cmake --upgrade && \
    apt autoremove -y

Version of Ubuntu:

 lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.6 LTS
Release:        18.04
Codename:       bionic

@bishen
Copy link

bishen commented Jan 12, 2024

edit file lukeroth\[email protected]\c_windows_amd64.go
head #cgo windows LDFLAGS and CFLAGS change to you path

@bartwalczak
Copy link

bartwalczak commented Jan 20, 2024

I'm running into the same issue on arm64 Apple Silicon:

2.204 # github.com/lukeroth/gdal
2.204 ../pkg/mod/github.com/lukeroth/[email protected]/gdal.go:44:11: cannot define new methods on non-local type C.CPLErr
2.204 ../pkg/mod/github.com/lukeroth/[email protected]/gdal.go:60:11: cannot define new methods on non-local type C.OGRErr
2.204 In file included from ../pkg/mod/github.com/lukeroth/[email protected]/algorithms.go:4:
2.204 ./go_gdal.h:8:10: fatal error: gdal.h: No such file or directory
2.204     8 | #include <gdal.h>
2.204       |          ^~~~~~~~
2.204 compilation terminated.
FROM ubuntu:23.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y git gdal-bin libgdal-dev
RUN apt-get install -y python3.10 python3-setuptools python3-pip pipx python3-gdal
RUN apt-get install -y golang-1.20-go
RUN ln -s /usr/lib/go-1.20/bin/go /usr/local/bin/go

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

No branches or pull requests

3 participants