[gdal-dev] How to build py-gdal using the C++ compiler

Chris Marsh chris.marsh at usask.ca
Thu Jun 18 10:09:31 PDT 2020


Hi Ryan,

Agreed. However for working in pyenvs, it 'just works' more reliably.

I'm actually quite interested in this issue as I have python code on pypi
that uses gdal & setuptools.

I note you commented on the setuptools issue here
https://github.com/pypa/setuptools/issues/1732

but there is also this earlier post
https://github.com/pypa/setuptools/issues/1192

>From what I can tell, I agree that CXXFLAGS aren't explicitly handled by
setuptools and it uses gcc/clang instead of the ++ variants. I see clang++
being used for the link invocation though.
However, either gcc/g++ can be used to compile c++ as code, as long as with
gcc the c++ libraries are linked against (which seems to be done
correctly). So other than the CXXFLAGS being ignored, it's perhaps not that
big of a problem (ie, it's still a C++ compiler at the end of the day
https://gcc.gnu.org/onlinedocs/gcc/Invoking-G_002b_002b.html)

I'll use the pygdal example (the one I linked above) as it uses setuptools

If I do
CC=clang++ CXXFLAGS='-std=c++11 -stdlib=libc++' pip -v install
--force-reinstall  pygdal=="`gdal-config --version`.*"

it fails to compile due to C++11 not being enabled

If I do
CC=clang++ CFLAGS='-std=c++11 -stdlib=libc++' pip -v install
--force-reinstall  pygdal=="`gdal-config --version`.*"

then it works as expected and it uses clang++ throughout in the log file.

My read is:
-I don't think this is a GDAL specific problem but a disutils/setuptools
quirk.
- It seems using CFLAGS=$CXXFLAGS would be sufficient to work around the
setuptools/distutils behaviour, but that may not be possible with
macports/your build env.


Cheers
Chris



Cheers
Chris




Chris Marsh, PhD
University of Saskatchewan
chrismarsh.ca



On Wed, Jun 17, 2020 at 7:24 PM Ryan Schmidt <gdal at ryandesign.com> wrote:

> CAUTION: This email originated from outside of the University of
> Saskatchewan. Do not click links or open attachments unless you recognize
> the sender and know the content is safe. If in doubt, please forward
> suspicious emails to phishing at usask.ca
>
>
> On Jun 17, 2020, at 18:38, Chris Marsh wrote:
>
> > I don't have anything to do with the gdal project, so I don't have a
> proper answer for you.
> >
> > However, I use this project
> > https://github.com/nextgis/pygdal
> > for using python gdal in my venvs as it behaves much better.
> >
> > It uses setuptools and does C++11 checks, which requires a c++ compiler.
> Might help you out if you can't get a good answer here.
>
> It looks like there are many changes between the pypi version of gdal that
> I've been using and the one you referred to above. I don't have anything to
> do with the gdal project either so I'm not qualified to judge whether those
> changes are appropriate but my default reaction is to be uncomfortable
> using forks of software projects, especially when the original version of
> the project is still active.
>
> Nevertheless I tried building the extension from the code you posted
> above, and it has the same problem: the C++ code gets built using the C
> compiler, not the C++ compiler. Do you see a different result when you
> build it? If so can you tell me more about your system?
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200618/4ac5ecb5/attachment-0001.html>


More information about the gdal-dev mailing list