usnistgov/REFPROP-cmake

Installing REPROP Using C-Make in Macbook Air M1

gautam-subburaj opened this issue · 48 comments

@ianhbell
Hi Ian,
I have tried the methods given in the wrapper for installing REFPROP in the latest M1 based MacBook and found this error after getting the header file and using it in the python
OSError: dlopen(/usr/local/REFPROP/librefprop.dylib, 0x0006): tried: '/usr/local/REFPROP/librefprop.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
I had done this same procedure with success in a 2015 build iMAC which worked fine.
Please help.

Makes sense it worked before since everything was x86_64 arch. What do you get when you start up the python interpreter? Somehow your python seems to be using the x86_64 emulation layer.

Hi and greetings,

First of all, thank you for your active support here.

I have the same problem and several attempts have so far failed to remedy it. I am sure that this problem going to come up more and more often, so I am going to try and give some more context for you and others that may come across this later on. I am no expert in any of these topics, so please correct me if I am wrong somewhere or I mix up some vocabulary. Maybe we can resolve it together.

Due to the new M1s having a different processor architecture, they require their own build (I guess build is the right name for it?). However, Apple has developed a software (Rosetta 2), which translates x84_64, which enables running x86_64 on these machines, so as to make the transitional period easier.

Many Python packages are not yet available natively on the M1 processor, and, until recently, there was no M1-native Anaconda. And although now there is an option to install Miniconda (https://docs.conda.io/en/latest/miniconda.html) natively with most of the scientific stack, it may not work with some less maintained packages relying on the x86_64 architecture. Thus, for people that experiment with many packages and are not set with their handful ones provided by Miniconda directly, running Anaconda through the translation layer is still the best option.

Now the problem: During building Refprop, I first got the same error as Vincen-Jo, which stated that libquadmath.a is missing. As you suggested, I commented out the lines in the CMakeLists.txt, which seemed to work. Thereafter, the building went without hitches. When I tried to access the xx.dylib in Python, I had the same error as gautam-subburaj, suggesting that the build went well, but with the "wrong" architecture.

I tried digging through the internet to find some solutions and have unsuccessfully tried several things so far:

  1. Same process, but with the Terminal running through Rosetta2 (-> could still be part of the solution)
  2. With the "-DREFPROP_32BIT=ON"-option
  3. cmake --build --target=x86_64 .
  4. Setting the ARCH_FLAG in the CMakeLists.txt to -x86_64 (-> "gfortran: error: language 86_64 not recognized" during building process)
  5. Without the RELEASE flag
  6. Naively adding arch -x86_64 ... to the makefile
  7. Adding "-DCMAKE_OSX_ARCHITECTURES=x86_64" to the first cmake

The person asking (and solving) in this stackoverflow thread: https://stackoverflow.com/questions/71422088/how-can-i-compile-x86-64-asm-code-on-m1-mac-arm

... seems to have solved a similar issue by adding "arch -x86_64 ... " to the makefile, but I cannot put the puzzle pieces together as to where this should be added exactly.

Am I missing something? Do you have some idea where to put the "arch -x86_64 ... "?

Thank you again. Any suggestions are appreciated.

Hello again,

after many hours I have managed to get it to work. In the end, only an x86_64 version of gcc was required. I first installed a separate Intel-version of Homebrew, then installed the Intel-verision of gcc, and specified it in the CMakeLists.txt file.

Specifying it in the CMakeLists.txt was a bit "dirty" to say the least. I added

set(CMAKE_Fortran_COMPILER "path/to/the/x86_64/gfortran/compiler")

right below the "BUILD OPTIONS" block comment and replaced

set(ARCH_FLAG "")

with

set(ARCH_FLAG "-march=x86-64")

There should be a better way to pass these arguments into the cmake. Maybe you could add a flag to pass both to cmake? Maybe there is already one, that I just missed. And you could just specify in the Notes for M1, that an Intel-version of gcc is required and specify the flags.
I do not have much experience with cmake and building in general, but I'd be happy to assist you with the testing, since I assume you don't have a M1 laptop.

Thank you for your support.
Best regards

The core problem is that gfortran is not available for silicon. Intel's compiler is now free, do they have a silicon version yet? I'm trying out flang, but I'm struggling.

I can add a cmake flag to allow you to set the arch. The fortran compiler can be specified in the cmake config call.

And yes, you are right that I don't have access to an M1 chip.

ddqp commented

https://medium.com/mkdir-awesome/how-to-install-x86-64-homebrew-packages-on-apple-m1-macbook-54ba295230f
This link explains how to install two homebrew for both arm and x86, use x86 brew to install gcc, might work.
simply use the updated file CMakeLists.txt on my m1 got some issue like below:

[ 3%] Building Fortran object CMakeFiles/refprop.dir/FORTRAN_temp/CORE_ANC.FOR.o
f951: Error: unknown value 'x86-64' for '-march'
f951: note: valid arguments are: armv8-a armv8.1-a armv8.2-a armv8.3-a armv8.4-a armv8.5-a armv8.6-a armv8-r native
make[2]: *** [CMakeFiles/refprop.dir/FORTRAN_temp/CORE_ANC.FOR.o] Error 1
make[1]: *** [CMakeFiles/refprop.dir/all] Error 2
make: *** [all] Error 2

I have not fixed it yet, but installing x86 brew and gcc is ongoing

file /opt/homebrew/bin/gfortran
/opt/homebrew/bin/gfortran: Mach-O 64-bit executable arm64

I will try to do the same and check whether the build is successful or not.
Thanks

ddqp commented

I just got it worked!
Environment: MacBook pro m1 pro, intel iterm, intel python, intel gcc, intel ...., Xcode, refprop 10.0

with below command:
cmake .. -DPYTHON_EXECUTABLE:FILEPATH=/usr/local/homebrew/Cellar/python@3.9/3.9.12/bin/python3 -DCMAKE_FORTRAN_COMPILER=/usr/local/homebrew/Cellar/gcc/11.2.0_3/bin/gfortran
cmake --build .

librefprop.dylib: Mach-O 64-bit dynamically linked shared library x86_64

Scanning dependencies of target refprop
[ 6%] Building Fortran object CMakeFiles/refprop.dir/fortran/CORE_ANC.FOR.o
[ 12%] Building Fortran object CMakeFiles/refprop.dir/fortran/CORE_FEQ.FOR.o
[ 18%] Building Fortran object CMakeFiles/refprop.dir/fortran/CORE_PR.FOR.o
[ 25%] Building Fortran object CMakeFiles/refprop.dir/fortran/FLSH_SUB.FOR.o
[ 31%] Building Fortran object CMakeFiles/refprop.dir/fortran/MIX_HMX.FOR.o
[ 37%] Building Fortran object CMakeFiles/refprop.dir/fortran/PROP_SUB.FOR.o
[ 43%] Building Fortran object CMakeFiles/refprop.dir/fortran/REFPROP.FOR.o
[ 50%] Building Fortran object CMakeFiles/refprop.dir/fortran/SAT_SUB.FOR.o
[ 56%] Building Fortran object CMakeFiles/refprop.dir/fortran/SETUP.FOR.o
[ 62%] Building Fortran object CMakeFiles/refprop.dir/fortran/TRNSP.FOR.o
[ 68%] Building Fortran object CMakeFiles/refprop.dir/fortran/TRNS_TCX.FOR.o
[ 75%] Building Fortran object CMakeFiles/refprop.dir/fortran/TRNS_VIS.FOR.o
[ 81%] Building Fortran object CMakeFiles/refprop.dir/fortran/UTILITY.FOR.o
[ 87%] Building Fortran object CMakeFiles/refprop.dir/fortran/DLLFILES/PASS_FTN.FOR.o
[ 93%] Linking Fortran shared library librefprop.dylib
[ 93%] Built target refprop
[100%] About to build the REFPROP.h header file w/ /usr/local/homebrew/Cellar/python@3.9/3.9.12/bin/python3;-u;/Users/abc/REFPROP-cmake/externals/REFPROP-headers/generate_header.py;--FORTRAN-path;/Users/abc/REFPROP-cmake/fortran/DLLFILES;--python-exe;/usr/local/homebrew/Cellar/python@3.9/3.9.12/bin/python3
Writing the .pyf file with numpy.f2py, please be patient...
About to run: /usr/local/homebrew/Cellar/python@3.9/3.9.12/bin/python3 -m numpy.f2py --quiet --no-lower -h REFPROP.pyf /Users/abc/REFPROP-cmake/fortran/DLLFILES/PASS_FTN.FOR
numpy version: 1.20.1
Deleting REFPROP.pyf
[100%] Built target REFPROP_H

And does the shared library work?

ddqp commented

yes, it works with OSX Matlab without any issue.

On an M1 chip? Can you please write up more precisely what you did? It would be very useful to others. Did you get a ARM64 shared library?

A colleague and I installed it on his machine as well. However, he had a differernt setup on his M1 Mac and we encountered different issues. He is working with the native Python installation with Arm64 architecture rather than the x86_64 Rosetta tranlated version. Thus, the flags

cmake .. -DCMAKE_FORTRAN_COMPILER=/path/to/gfortran -DREFPROP_X8664=ON

were not required. We installed the Arm64 gcc version with his "normal" homebrew and compiled Refprop to Arm64, which worked in the end.
Problem we ran into:

  • Like for my machine, we did not initially find the libquadmath, but found it later on in some other directory by searching the hidden directories. The compilation works without it, if the corresponsing lines are commented out, but we compiled it again after we located it. We copied the file into the same directory and specified the path in the CMakeLists.txt.
  • He seemed to have no global Python installation, and was working only with virtual environments. He had set up Python and all his related projects inside PyCharm, so I guess this is how PyCharm manages the installations and projects. Thus, we installed Python globally with homebrew and installed numpy using pip.
ddqp commented

On an M1 chip? Can you please write up more precisely what you did? It would be very useful to others. Did you get a ARM64 shared library?

yes, on m1 silicon MacBook, with matlab , I use the x86 version librefprop.dylib, but I did get an arm version librefprop.dylib in the past with arm version terminal, python, etc.
to have x86 version librefprop.dylib, I have already described above, no other special points.
Actually, it's easy to get librefprop.dylib, but it's not easy to get REFPROP.h, what I have done is to use all intel version tools; And intel version terminal on silicon Mac can be called by using Rosetta translation.
I think arm version librefprop.dylib can be used with silicon version excel, and x86 version librefprop.dylib should be used with Matlab, because Matlab has no native silicon version.

The reason I am using x86 version librefprop.dylib, because I need to use same Matlab code on both Windows and Silicon Macbook.

I wonder if we could make a universal binary of the shared library. These things are quite tricky on macs.

What is tricky about REFPROP.h? That's just a python script, no?

ddqp commented

I am not expert, but what I encountered is, at beginning with refprop 9.1, if I don't turn off numpy, there will be numpy error and no .h will be output. But I can always get librefprop.dylib (ARM version)

It is proving to be very difficult to support M1 chips due to the range of variables that are included. Can you please write some more about what you did, output you got, etc. so that there is a record? I don't have access to an M1 chip for testing.

@ddqp and @viktmar, How did you end up managing to compile refprop? I would be more interested in getting it to compile natively on ARM, but currently I am running a Rosetta version of home-brew in a Rosetta terminal. I was able to brew install the x86 gcc with the associated gfortran, however, when I try to run cmake I get the following error:

martinschmeidler@macbook-air build % cmake .. -DCMAKE_FORTRAN_COMPILER=/usr/local/bin/gfortran -DREFPROP_X8664=ON
-- The Fortran compiler identification is unknown
dyld[52111]: Library not loaded: /usr/local/opt/isl/lib/libisl.23.dylib
  Referenced from: /usr/local/Cellar/gcc/12.2.0/libexec/gcc/x86_64-apple-darwin21/12/cc1
  Reason: tried: '/usr/local/opt/isl/lib/libisl.23.dylib' (no such file), '/usr/local/lib/libisl.23.dylib' (no such file), '/usr/lib/libisl.23.dylib' (no such file)
gfortran: internal compiler error: Abort trap: 6 signal terminated program cc1
Please submit a full bug report, with preprocessed source (by using -freport-bug).
See <https://github.com/Homebrew/homebrew-core/issues> for instructions.
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - failed
-- Check for working Fortran compiler: /usr/local/bin/gfortran
-- Check for working Fortran compiler: /usr/local/bin/gfortran - broken
CMake Error at /usr/local/Cellar/cmake/3.24.2/share/cmake/Modules/CMakeTestFortranCompiler.cmake:61 (message):
  The Fortran compiler

    "/usr/local/bin/gfortran"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /Users/martinschmeidler/REFPROP-cmake/build/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/usr/bin/make -f Makefile cmTC_57809/fast && /Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/cmTC_57809.dir/build.make CMakeFiles/cmTC_57809.dir/build
    Building Fortran object CMakeFiles/cmTC_57809.dir/testFortranCompiler.f.o
    /usr/local/bin/gfortran    -c /Users/martinschmeidler/REFPROP-cmake/build/CMakeFiles/CMakeTmp/testFortranCompiler.f -o CMakeFiles/cmTC_57809.dir/testFortranCompiler.f.o
    dyld[52132]: Library not loaded: /usr/local/opt/isl/lib/libisl.23.dylib
      Referenced from: /usr/local/Cellar/gcc/12.2.0/libexec/gcc/x86_64-apple-darwin21/12/f951
      Reason: tried: '/usr/local/opt/isl/lib/libisl.23.dylib' (no such file), '/usr/local/lib/libisl.23.dylib' (no such file), '/usr/lib/libisl.23.dylib' (no such file)
    gfortran: internal compiler error: Abort trap: 6 signal terminated program f951
    Please submit a full bug report, with preprocessed source (by using -freport-bug).
    See <https://github.com/Homebrew/homebrew-core/issues> for instructions.
    make[1]: *** [CMakeFiles/cmTC_57809.dir/testFortranCompiler.f.o] Error 4
    make: *** [cmTC_57809/fast] Error 2
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (enable_language)


-- Configuring incomplete, errors occurred!

@mschmeid
I cannot gather from your answer if you want to "compile natively on ARM" or compile it through Rosetta2. A Rosetta2 compiled version will not work with a natively running Python and v.v.
So, for example, if you use Anaconda, I am quite sure that you need to install it using Rosetta2.

I am not sure, but error looks like you used the Arm-gfortran path and instructing it to compile to X8664.

So, do you want to compile natively to Arm or to x8664?

I build REFPROP natively on M1, it works fine in 2022

I build REFPROP natively on M1, it works fine in 2022

I downloaded gfortran for M1. And still receiving:

CMake Error at CMakeLists.txt:153 (file):
file failed to open for reading (No such file or directory):

/Users/baran/REFPROP-cmake/build/aliases_string.txt

Any suggestions would be appreciated.

@BaranKaypakoglu Please show what commands you ran and what shell output you received. Where did you get gfortran from? Are you using conda for python?

It is most reliable to use the homebrew gfortran in my experience. I think it is not sufficient to copy gfortran locally since there are also libraries and so on to worry about, and you'll note that a diferent libquadmath.a was found, which definitely is a problem.

Also, make sure you respond in the web interface to keep the email response chain from appearing online.

I removed the previous gfortran and installed via homebrew. Result is the same:

baran@Barans-MacBook-Pro build % cmake .. -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE:FILEPATH=/usr/local/bin/python3
-- The C compiler identification is AppleClang 14.0.0.14000029
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The Fortran compiler identification is GNU 12.2.0
-- Checking whether Fortran compiler has -isysroot
-- Checking whether Fortran compiler has -isysroot - yes
-- Checking whether Fortran compiler supports OSX deployment target flag
-- Checking whether Fortran compiler supports OSX deployment target flag - yes
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /opt/homebrew/bin/gfortran - skipped
-- Found PythonInterp: /usr/local/bin/python3
-- DEFSYM_FLAG:

CMake Error at CMakeLists.txt:153 (file):
file failed to open for reading (No such file or directory):

/Users/baran/REFPROP-cmake/build/aliases_string.txt

-- Path to libquadmath.a:/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../libquadmath.a
-- Copied libquadmath.a here.
-- Configuring incomplete, errors occurred!
See also "/Users/baran/REFPROP-cmake/build/CMakeFiles/CMakeOutput.log".
See also "/Users/baran/REFPROP-cmake/build/CMakeFiles/CMakeError.log".
baran@Barans-MacBook-Pro build %

What else should I try?

I made some updates to force absolute paths in cc0f644 , can you try again?

I removed the previous clone and re-cloned it. Result is the same though:

baran@Barans-MacBook-Pro REFPROP-cmake % mkdir build
baran@Barans-MacBook-Pro REFPROP-cmake % cd build
baran@Barans-MacBook-Pro build % cmake .. -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE:FILEPATH=/usr/local/bin/python3
-- The C compiler identification is AppleClang 14.0.0.14000029
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The Fortran compiler identification is GNU 12.2.0
-- Checking whether Fortran compiler has -isysroot
-- Checking whether Fortran compiler has -isysroot - yes
-- Checking whether Fortran compiler supports OSX deployment target flag
-- Checking whether Fortran compiler supports OSX deployment target flag - yes
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /opt/homebrew/bin/gfortran - skipped
-- Found PythonInterp: /usr/local/bin/python3
-- DEFSYM_FLAG:

CMake Error at CMakeLists.txt:157 (file):
file failed to open for reading (No such file or directory):

/Users/baran/REFPROP-cmake/build/aliases_string.txt

-- Path to libquadmath.a:/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../libquadmath.a
-- Copied libquadmath.a here.
-- Configuring incomplete, errors occurred!
See also "/Users/baran/REFPROP-cmake/build/CMakeFiles/CMakeOutput.log".
See also "/Users/baran/REFPROP-cmake/build/CMakeFiles/CMakeError.log".
baran@Barans-MacBook-Pro build %

Make sure you pass the path to the sources too

And how do I do that?

sorry Ian, I am no programmer...and I am really appreciating your patience and time with this..surely there must be something I am doing wrong..

Bullet point 2 here: https://github.com/usnistgov/REFPROP-cmake#general-notes

Don't worry, we'll get there, almost working.

If by "passing the path to the sources" you mean "to move the FORTRAN" folder to the root of the checked out code, yes I had done that already. I have a virtual machine running windows where refprop is installed. I copied the fortran from there.

In any case I also tried referencing the pathname as cmake .. -DREFPROP_FORTRAN_PATH=/path/to/refprop/fortran

Results were the same. Here are all my efforts:

baran@Barans-MacBook-Pro build % cmake .. -DREFPROP_FORTRAN_PATH=/Users/baran/REFPROP-cmake/FORTRAN -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE:FILEPATH=/usr/local/bin/python3 -DCMAKE_FORTRAN_COMPILER=/path/to/gfortran -DREFPROP_X8664=ON
-- The C compiler identification is AppleClang 14.0.0.14000029
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The Fortran compiler identification is GNU 12.2.0
-- Checking whether Fortran compiler has -isysroot
-- Checking whether Fortran compiler has -isysroot - yes
-- Checking whether Fortran compiler supports OSX deployment target flag
-- Checking whether Fortran compiler supports OSX deployment target flag - yes
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /opt/homebrew/bin/gfortran - skipped
-- Found PythonInterp: /usr/local/bin/python3
-- Forcing x86_64 build and passing -march=x86-64 to compiler...
-- DEFSYM_FLAG:

CMake Error at CMakeLists.txt:157 (file):
file failed to open for reading (No such file or directory):

/Users/baran/REFPROP-cmake/build/aliases_string.txt

-- Path to libquadmath.a:/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../libquadmath.a
-- Copied libquadmath.a here.
-- Configuring incomplete, errors occurred!
See also "/Users/baran/REFPROP-cmake/build/CMakeFiles/CMakeOutput.log".
See also "/Users/baran/REFPROP-cmake/build/CMakeFiles/CMakeError.log".
baran@Barans-MacBook-Pro build % cmake .. -DREFPROP_FORTRAN_PATH=/Users/baran/REFPROP-cmake/FORTRAN -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE:FILEPATH=/usr/local/bin/python3 -DCMAKE_FORTRAN_COMPILER=/path/to/gfortran -DREFPROP_X8664=ON -DREFPROP_32BIT=ON
-- The C compiler identification is AppleClang 14.0.0.14000029
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The Fortran compiler identification is GNU 12.2.0
-- Checking whether Fortran compiler has -isysroot
-- Checking whether Fortran compiler has -isysroot - yes
-- Checking whether Fortran compiler supports OSX deployment target flag
-- Checking whether Fortran compiler supports OSX deployment target flag - yes
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /opt/homebrew/bin/gfortran - skipped
-- Found PythonInterp: /usr/local/bin/python3
-- Forcing 32-bit build and passing -m32 to compiler...
-- DEFSYM_FLAG:

CMake Error at CMakeLists.txt:157 (file):
file failed to open for reading (No such file or directory):

/Users/baran/REFPROP-cmake/build/aliases_string.txt

-- Path to libquadmath.a:gfortran: error: unrecognized command-line option '-m32'
/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../libquadmath.a
CMake Error at CMakeLists.txt:177 (file):
file COPY cannot find "/Users/baran/REFPROP-cmake/gfortran: error:
unrecognized command-line option '-m32'

/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../libquadmath.a":
No such file or directory.

-- Copied libquadmath.a here.
-- Configuring incomplete, errors occurred!
See also "/Users/baran/REFPROP-cmake/build/CMakeFiles/CMakeOutput.log".
See also "/Users/baran/REFPROP-cmake/build/CMakeFiles/CMakeError.log".
baran@Barans-MacBook-Pro build % cmake .. -DCMAKE_BUILD_TYPE=Release
-- The C compiler identification is AppleClang 14.0.0.14000029
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The Fortran compiler identification is GNU 12.2.0
-- Checking whether Fortran compiler has -isysroot
-- Checking whether Fortran compiler has -isysroot - yes
-- Checking whether Fortran compiler supports OSX deployment target flag
-- Checking whether Fortran compiler supports OSX deployment target flag - yes
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /opt/homebrew/bin/gfortran - skipped
-- Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)
-- DEFSYM_FLAG:

CMake Error at CMakeLists.txt:157 (file):
file failed to open for reading (No such file or directory):

/Users/baran/REFPROP-cmake/build/aliases_string.txt

-- Path to libquadmath.a:/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../libquadmath.a
-- Copied libquadmath.a here.
-- Configuring incomplete, errors occurred!
See also "/Users/baran/REFPROP-cmake/build/CMakeFiles/CMakeOutput.log".
See also "/Users/baran/REFPROP-cmake/build/CMakeFiles/CMakeError.log".
baran@Barans-MacBook-Pro build %

I think your python might be too old. I ran what you did on my side, with the FORTRAN folder copied, and it was fine:

(base) 647ibmac:bld ihb$ cmake .. -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 
-- The C compiler identification is AppleClang 14.0.0.14000029
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The Fortran compiler identification is GNU 12.2.0
-- Checking whether Fortran compiler has -isysroot
-- Checking whether Fortran compiler has -isysroot - yes
-- Checking whether Fortran compiler supports OSX deployment target flag
-- Checking whether Fortran compiler supports OSX deployment target flag - yes
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /opt/homebrew/bin/gfortran - skipped
-- Found PythonInterp: /usr/bin/python3 (found version "3.9.6") 
-- DEFSYM_FLAG: 
-- darwin
Missing from PASS_CMN_tokens:  []
Missing from REFPROP_lib.h: []

-- Path to libquadmath.a:/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin21/12/../../../libquadmath.a
-- Copied libquadmath.a here.
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/ihb/Documents/Code/REFPROP-cmake/bld

The problem is clearly alias generation. I pushed a change that will print out the error message, indicating the problem. Please try again

My phython is 3.9.6:

Python 3.9.6 (default, Oct 18 2022, 12:41:40)
[Clang 14.0.0 (clang-1400.0.29.202)] on darwin

I ran the whole process again. The issue remains:

baran@Barans-MacBook-Pro build % cmake .. -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE:FILEPATH=/usr/local/bin/python3
-- The C compiler identification is AppleClang 14.0.0.14000029
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The Fortran compiler identification is GNU 12.2.0
-- Checking whether Fortran compiler has -isysroot
-- Checking whether Fortran compiler has -isysroot - yes
-- Checking whether Fortran compiler supports OSX deployment target flag
-- Checking whether Fortran compiler supports OSX deployment target flag - yes
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /opt/homebrew/bin/gfortran - skipped
-- Found PythonInterp: /usr/local/bin/python3
-- DEFSYM_FLAG:
CMake Error at CMakeLists.txt:160 (file):
file failed to open for reading (No such file or directory):

/Users/baran/REFPROP-cmake/build/aliases_string.txt

-- Path to libquadmath.a:/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../libquadmath.a
-- Copied libquadmath.a here.
-- Configuring incomplete, errors occurred!
See also "/Users/baran/REFPROP-cmake/build/CMakeFiles/CMakeOutput.log".
See also "/Users/baran/REFPROP-cmake/build/CMakeFiles/CMakeError.log".
baran@Barans-MacBook-Pro build %

Should we give up ? :)

Never give up! :)

I think you didn't update the code as you should have gotten an error message about alias generation?

I believe I did update it. I removed the whole folder and re-cloned the repository. Let me try again.

Yep. I did it all from scratch. Same thing:

baran@Barans-MacBook-Pro build % cmake .. -DCMAKE_FORTRAN_COMPILER=/path/to/gfortran -DREFPROP_X8664=ON -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE:FILEPATH=/usr/local/bin/python3
-- The C compiler identification is AppleClang 14.0.0.14000029
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The Fortran compiler identification is GNU 12.2.0
-- Checking whether Fortran compiler has -isysroot
-- Checking whether Fortran compiler has -isysroot - yes
-- Checking whether Fortran compiler supports OSX deployment target flag
-- Checking whether Fortran compiler supports OSX deployment target flag - yes
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /opt/homebrew/bin/gfortran - skipped
-- Found PythonInterp: /usr/local/bin/python3
-- Forcing x86_64 build and passing -march=x86-64 to compiler...
-- DEFSYM_FLAG:
CMake Error at CMakeLists.txt:160 (file):
file failed to open for reading (No such file or directory):

/Users/baran/REFPROP-cmake/build/aliases_string.txt

-- Path to libquadmath.a:/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../libquadmath.a
-- Copied libquadmath.a here.
-- Configuring incomplete, errors occurred!
See also "/Users/baran/REFPROP-cmake/build/CMakeFiles/CMakeOutput.log".
See also "/Users/baran/REFPROP-cmake/build/CMakeFiles/CMakeError.log".
baran@Barans-MacBook-Pro build %

What I don't understand is how the alias generation fails but you don't get any error message. Let me try to force failure on my side and see what happens.

Hmm it fails properly on my side and you get error output:

...
-- DEFSYM_FLAG: 
-- Alias generation output: 
-- Alias generation error:   File "/Users/ihb/Documents/Code/REFPROP-cmake/generate_aliases.py", line 4
    Raise grretre()
          ^^^^^^^
SyntaxError: invalid syntax

CMake Error at CMakeLists.txt:160 (file):
  file failed to open for reading (No such file or directory):

    /Users/ihb/Documents/Code/REFPROP-cmake/bld/aliases_string.txt


-- Path to libquadmath.a:/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin21/12/../../../libquadmath.a

Ah, new idea: did you clone recursively? Maybe you are missing the externals. Do you have files in externals/REFPROP-headers?

I copied and pasted this in the terminal:

git clone --recursive https://github.com/usnistgov/REFPROP-cmake.git

Yes I have some files in externals/REFPROP-headers as follows:

CMakeLists.txt
generate_header.py
generate_mangling_header.py
LICENSE
main.cpp
other.cpp
README.md
REFPROP_lib.h
REFPROP_underscore_lowercase_renaming.h
scrape_PASS_FTN.py
testRP.m

After I do the process, these are created in the build folder:

CMakeCache.txt
CMakeFiles
libquadmath.a

Inside the CMakeFiles there are these:

3.25.2
cmake.check_cache
CMakeError.log
CMakeOutput.log
CMakeScratch
pkgRedirects

should I try downloading anaconda for M1 and use the terminal there perhaps ? that's all I can think of at this moment. maybe worth a try..?

Maybe, but that should be overkill. Can you email and we can debug offline?

Hey Ian!

Thank you so much for developing this and providing incredible support! I have had similar issue with following output:

cmake .. -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE:FILEPATH=/opt/homebrew/bin/python3.10 -DREFPROP_FORTRAN_PATH=/opt/homebrew/bin/gfortran -DCMAKE_OSX_ARCHITECTURES=x86_64
-- The C compiler identification is AppleClang 14.0.3.14030022
-- The CXX compiler identification is AppleClang 14.0.3.14030022
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The Fortran compiler identification is GNU 12.2.0
-- Checking whether Fortran compiler has -isysroot
-- Checking whether Fortran compiler has -isysroot - yes
-- Checking whether Fortran compiler supports OSX deployment target flag
-- Checking whether Fortran compiler supports OSX deployment target flag - yes
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /opt/homebrew/bin/gfortran - skipped
-- Found PythonInterp: /opt/homebrew/bin/python3.10 (found version "3.10.10") 
-- DEFSYM_FLAG: 
-- Alias generation output: darwin

-- Alias generation error: Traceback (most recent call last):
  File "/Users/koshelev/temp/REFPROP-cmake/generate_aliases.py", line 22, in tokenize
    for line in open(os.path.join(path_to_FORTRAN,"PASS_FTN.FOR"), 'r').readlines():
NotADirectoryError: [Errno 20] Not a directory: '/opt/homebrew/Cellar/gcc/12.2.0/bin/gfortran-12/PASS_FTN.FOR'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/koshelev/temp/REFPROP-cmake/generate_aliases.py", line 129, in <module>
    tokens = tokenize(header_path, FORTRAN_path)
  File "/Users/koshelev/temp/REFPROP-cmake/generate_aliases.py", line 25, in tokenize
    for line in open(os.path.join(path_to_FORTRAN,"DLLFILES","PASS_FTN.FOR"), 'r').readlines():
NotADirectoryError: [Errno 20] Not a directory: '/opt/homebrew/Cellar/gcc/12.2.0/bin/gfortran-12/DLLFILES/PASS_FTN.FOR'

CMake Error at CMakeLists.txt:174 (file):
  file failed to open for reading (No such file or directory):

    /Users/koshelev/temp/REFPROP-cmake/build/aliases_string.txt


-- Path to libquadmath.a:/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin21/12/../../../libquadmath.a
-- Copied libquadmath.a here.
-- Configuring incomplete, errors occurred!

I am using homebrew version of python and gcc/gfortran. Surprisingly, adding -DREFPROP_FORTRAN_PATH=/path/to/REFPROP/fortran solved the issue. REFPROP successfully compiled and worked after. I hope this could be helpful.

You passed the wrong command line argument, the -DREFPROP_FORTRAN_PATH needs to be the path to the FORTRAN sources for REFPROP provided with your REFPROP installation.