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

How to add postgis driver? #36

Closed
qjw2bqn opened this issue Jan 25, 2021 · 10 comments · Fixed by #37
Closed

How to add postgis driver? #36

qjw2bqn opened this issue Jan 25, 2021 · 10 comments · Fixed by #37
Assignees

Comments

@qjw2bqn
Copy link

qjw2bqn commented Jan 25, 2021

I have successfully compiled the project on windows OS.
Then I want to add the postgis driver,how should i start?
Can you help me?

@MaxRev-Dev
Copy link
Owner

Yes, this driver can be easily installed, as it not requires a lot of dependencies.
Step 1 - Update vcpkg:
VCPKG should be built with the proper version which can be set in shared/GdalCore.opt.

VCPKG_COMMIT_VER=5dc53211caedebf4387d590155ed53ee44161f10

I suggest you to use the latest commit in master branch to build all properly.
If the package build failed with any error try to pull the latest version of vcpkg or look for the issue to the problem exists with that library.

Step 2 - Install libpq:
Then add a postgresql client library - libpq to the list of packages in shared/GdalCore.opt.

VCPKG_REQUIRE=tiff expat xerces-c libpng libiconv zlib

If you already build vcpkg's packages, then you should rebuild them - nmake -f vcpkg-makefile.vc install_requirements

Step 3 - Define the package path:
Every vcpkg library is installed to vcpkg package folder, so you can use this macro - $(BUILD_ROOT_VCPKG)/libpq
Define it in win/gdal-nmake.opt

# PostGIS Libraries
#PG_INC_DIR = n:\pkg\libpq_win32\include
#PG_LIB = n:\pkg\libpq_win32\lib\libpqdll.lib wsock32.lib

Step 4 - Building GDAL:
If there was nothing updated, I suggest you to rebuild only a gdal library - nmake -f makefile.vc build-gdal-only.
If GDAL fails to build, maybe some libraries did not referenced correctly. Or if you will have any issues on gdal library linking, there could be some problems with the new library. On this step I had some struggle with curl for example. I don't know everything, and always trying to search first what went wrong.

Step 5 - Testing
Run nmake -f makefile.vc test to ensure that everything works.
All new packages can be found in nuget folder.

@MaxRev-Dev
Copy link
Owner

One more comment on this.
Currently WSL is required to rebuild the core package.
Because c# bindings are linux based, I did not tested everything to build bindings from windows.

@qjw2bqn
Copy link
Author

qjw2bqn commented Jan 27, 2021

Thank you very much ,I had compiled the MaxRev.Gdal.WindowsRuntime.Minimal.3.2.0.254.nupkg!

But how to build MaxRev.Gdal.Core.nupkg?
When I excute the command “dotnet build .\gdalcore.loader.csproj”
Something error:

error CS0103 “OSGeo” gdalcore.loader (net5.0), gdalcore.loader (netcoreapp2.1), gdalcore.loader (netcoreapp3.1), gdalcore.loader (netstandard2.0), gdalcore.loader (netstandard2.1) C:\gdal\compile\GdalConfigureAll.cs 77

I used ILSpy to decompile the Gdal.Core.dll on nuget.org which you push. I found OSGeo.GDAL/OSGeo.ORG/OSGeo.OSR folder exist lots of files. where the files come from?

@MaxRev-Dev
Copy link
Owner

MaxRev-Dev commented Jan 27, 2021

One more comment on this.
Currently WSL is required to rebuild the core package.
Because c# bindings are linux based, I did not tested everything to build bindings from windows.

As I wrote previously, those bindings currently available for build only from linux.
I'm working on windows makefile for separated sources for gdalcore.loader.

@qjw2bqn
Copy link
Author

qjw2bqn commented Feb 1, 2021

Hi,I had successfully compiled the project on Ubuntu 16.04/18.04. I found both of MaxRev.Gdal.Core.nupkg and MaxRev.Gdal.WindowsRuntime.Minimal.nupkg generated!

Then I try to add driver postgis to project. First I edit the shared/GdalCore.opt file as you said. Then I Edit the unix/gdal-makefile file --- "--with-pg ". But it didn't success!

Can you tell how to add postgis driver on linux? thanks!

@MaxRev-Dev
Copy link
Owner

@qjw2bqn Did you specified a package path with --with-pg flag, e.g. --with-pg=${VCPKG_INSTALLED} ?

@qjw2bqn
Copy link
Author

qjw2bqn commented Feb 2, 2021

@MaxRev-Dev yes,i edit the gdal-makefile as below:
-without-pcidsk
--without-pcraster
--without-pcre
--without-perl
_--with-pg=${VCPKG_INSTALLED} _
--without-python
--without-qhull
--without-sde \

then,excute :
make -f gdal-makefile
make
make pack

But didn't add pg driver success!

@qjw2bqn
Copy link
Author

qjw2bqn commented Feb 22, 2021

@MaxRev-Dev I had test on CentOS 7.
The command "make -f gdal-makefile" went wrong.

./.libs/libproj.so: undefined reference to curl_easy_getinfo' ./.libs/libproj.so: undefined reference to curl_easy_setopt'
./.libs/libproj.so: undefined reference to curl_easy_init' ./.libs/libproj.so: undefined reference to curl_easy_perform'
./.libs/libproj.so: undefined reference to `curl_easy_cleanup'
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:1394: proj] Error 1
make[4]: Leaving directory '/root/gdal/build-unix/proj-source/src'
make[3]: *** [Makefile:884: all] Error 2
make[3]: Leaving directory '/root/gdal/build-unix/proj-source/src'
make[2]: *** [Makefile:450: all-recursive] Error 1
make[2]: Leaving directory '/root/gdal/build-unix/proj-source'
make[1]: *** [gdal-makefile:173: build_proj] Error 2
make[1]: Leaving directory '/root/gdal/unix'
make: *** [gdal-makefile:42: proj] Error 2

How can I do?

@MaxRev-Dev
Copy link
Owner

@qjw2bqn Sorry for delay, this month was busy. I've added support for separate build on windows.
Also, the postgis driver is now included in both runtime packages. Please, checkout the latest 3.2.0.300 version.

If you will have any issues with compiling drivers, you can try to cleanup your environment.

@qjw2bqn
Copy link
Author

qjw2bqn commented Mar 8, 2021

@MaxRev-Dev thanks, next I will test.

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

Successfully merging a pull request may close this issue.

2 participants