Error building iphreeqc library with PGI compilers

Hi PGI Users,

I am trying to build iphreeqc library (source can be found here https://water.usgs.gov/water-resources/software/PHREEQC/iphreeqc-3.4.0-12927.tar.gz) with PGI compilers (18.4 community edition), this is the configure line:

CXX=pgc++ CC=pgcc FC=pgfortran ./configure --prefix=$DEV_lib_dir/iphreeqc --enable-fortran-module --enable-fortran-test

Once I start compiling with make I got the following errors:

  CXX      phreeqcpp/transport.lo
"phreeqcpp/transport.cpp", line 1: error: unrecognized token
  #include "Utils.h"
  ^

"phreeqcpp/transport.cpp", line 1: error: expected a declaration
  #include "Utils.h"
  ^

"phreeqcpp/transport.cpp", line 1: error: unrecognized token
  #include "Utils.h"
   ^

"phreeqcpp/transport.cpp", line 1: error: unrecognized token
  #include "Utils.h"
    ^

"phreeqcpp/transport.cpp", line 1: error: "#" not expected here
  #include "Utils.h"
     ^

"/usr/include/c++/5/bits/postypes.h", line 98: error: identifier "ptrdiff_t" is
          undefined
    typedef ptrdiff_t	streamsize; // Signed integral type
            ^

"/usr/include/c++/5/iosfwd", line 76: error: char_traits is not a template
    template<typename _CharT, typename _Traits = char_traits<_CharT> >
                                                 ^

"/usr/include/c++/5/iosfwd", line 79: error: char_traits is not a template
    template<typename _CharT, typename _Traits = char_traits<_CharT> >
                                                 ^

... a lot more errors ...

"/usr/include/c++/5/bits/basic_string.h", line 4999: error: basic_string is not
          a template
      operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
                      ^

"/usr/include/c++/5/bits/basic_string.h", line 4999: error: nonmember operator
          requires a parameter with class or enum type
      operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      ^

"/usr/include/c++/5/bits/basic_string.h", line 5012: error: basic_string is not
          a template
  	      const basic_string<_CharT, _Traits, _Alloc>& __rhs)
  	            ^

"/usr/include/c++/5/bits/basic_string.h", line 5011: error: nonmember operator
          requires a parameter with class or enum type
      operator<(const _CharT* __lhs,
      ^

"/usr/include/c++/5/bits/basic_string.h", line 5024: error: basic_string is not
          a template
      operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
                      ^

Error limit reached.
100 errors detected in the compilation of "phreeqcpp/transport.cpp".
Compilation terminated.

I used gcc compilers without problems, what could be the problem here?

Thank you for your help,

Best regards,

Hector

Hi Hector,

The problem is in src/phreeqcpp/transport.c

There is a byte order mark (bytes EF BB BF) at the start of the file that is throwing the compiler off.

$ hexdump -C src/phreeqcpp/transport.cpp | head -n2
00000000  ef bb bf 23 69 6e 63 6c  75 64 65 20 22 55 74 69  |...#include "Uti|
00000010  6c 73 2e 68 22 0a 23 69  6e 63 6c 75 64 65 20 22  |ls.h".#include "|

I got it to compile by removing the BOM, I believe you can do :set nobomb and save with vim or with set-buffer-file-coding-system and pick utf-8 in emacs. The dos2unix command will also work.

Hi aglobus,

That was definitely the problem, I used dos2unix and it worked.

Thanks for your help!