usnistgov / REFPROP-cmake

Small repo with CMake build system for building REFPROP shared library
49 stars 27 forks source link

The Fortran compiler is not able to compile a simple test program. #84

Open danielkwalsh opened 1 year ago

danielkwalsh commented 1 year ago

Hi, I'm having trouble with building REFPROP on a 2.9 GHz 6-Core Intel Core i9 Mac. I've followed the directions in the readme, but when running cmake .. -DCMAKE_BUILD_TYPE=Release, I get the following error: `CMake Error at /usr/local/Cellar/cmake/3.22.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/danielkwalsh/Work/REFPROP-cmake/build/CMakeFiles/CMakeTmp`

I read the section on OSX notes in the readme, and since I don't have an M1, I skipped that portion. I've tried looking around the internet at possible solutions to this, and read that I should instead run this: cmake .. -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE:FILEPATH=/usr/local/bin/python3 But this also fails with what appears to be the same error.

ianhbell commented 1 year ago

Where did you get your gfortran from? I have found the most reliable method, by far, to be the homebrew one. I use that on all my Macs

danielkwalsh commented 1 year ago

I don't recall where it was originally obtained, but I tried to rm gfortran and then run brew install gcc to make sure it's using homebrew.

ianhbell commented 1 year ago

you can run which gfortran to give more info. For me:

(base) XXXX:~ me$ which gfortran
/opt/homebrew/bin/gfortran
danielkwalsh commented 1 year ago

I think that's the issue. I get this: /usr/local/bin/gfortran

ianhbell commented 1 year ago

Seems likely. When you install gfortran via homebrew, does it give you some warnings about needing to adjust the PATH variable?

danielkwalsh commented 1 year ago

I don't see any warnings like that, but when I run cmake, I do see this line: -- The Fortran compiler identification is GNU 13.2.0

ianhbell commented 1 year ago

That is a very recent compiler, that is good news

ianhbell commented 1 year ago

Can you show the shell output when you do your cmake command?

danielkwalsh commented 1 year ago
cmake .. -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE:FILEPATH=/usr/local/bin/python3ls
-- The Fortran compiler identification is GNU 13.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 - 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.22.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/danielkwalsh/Work/REFPROP-cmake/build/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/make -f Makefile cmTC_1356f/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make  -f CMakeFiles/cmTC_1356f.dir/build.make CMakeFiles/cmTC_1356f.dir/build
    Building Fortran object CMakeFiles/cmTC_1356f.dir/testFortranCompiler.f.o
    /usr/local/bin/gfortran   -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -c /Users/danielkwalsh/Work/REFPROP-cmake/build/CMakeFiles/CMakeTmp/testFortranCompiler.f -o CMakeFiles/cmTC_1356f.dir/testFortranCompiler.f.o
    Linking Fortran executable cmTC_1356f
    /usr/local/Cellar/cmake/3.22.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_1356f.dir/link.txt --verbose=1
    /usr/local/bin/gfortran  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk CMakeFiles/cmTC_1356f.dir/testFortranCompiler.f.o -o cmTC_1356f 
    ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/lib/libSystem.tbd' for architecture x86_64
    collect2: error: ld returned 1 exit status
    make[1]: *** [cmTC_1356f] Error 1
    make: *** [cmTC_1356f/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!
See also "/Users/danielkwalsh/Work/REFPROP-cmake/build/CMakeFiles/CMakeOutput.log".
See also "/Users/danielkwalsh/Work/REFPROP-cmake/build/CMakeFiles/CMakeError.log".
ianhbell commented 1 year ago

Hrm. What if you brew uninstall gcc and brew install gcc? Something about your installation seems to be messed up.

danielkwalsh commented 1 year ago

I'll try that now.

danielkwalsh commented 1 year ago

brew uninstall gcc


Error: Refusing to uninstall /usr/local/Cellar/gcc/13.2.0
because it is required by ipopt and openblas, which are currently installed.
You can override this and force removal with:
  brew uninstall --ignore-dependencies gcc

So I did that: brew uninstall --ignore-dependencies gcc and then brew install gcc It prints out a bunch of stuff, and sometimes mentions that things are already downloaded, but sees to complete with no errors. Then I run the cmake command again and get what appears to be the same error.

ianhbell commented 1 year ago

Make sure you delete your build folder before you try again. Otherwise Cmake can use cached things

danielkwalsh commented 1 year ago

I just tried re-cloning the whole repo to ensure I didn't make any bad changes, as well as deleting the build folder as you suggested, then re-trying brew uninstall --ignore-dependencies gcc and brew install gcc again. I still see the same error.

ianhbell commented 1 year ago

Looking at the error message you got, it seems like XCode is the culprit, not gfortran

ianhbell commented 1 year ago

https://developer.apple.com/forums/thread/722490

ianhbell commented 1 year ago

You are not alone it seems: https://www.google.com/search?q=unsupported+tapi+file+type+%27!tapi-tbd%27+in+YAML+file&rlz=1C5GCEM_enUS1026US1026&oq=unsupported+tapi+file+type+%27!tapi-tbd%27+in+YAML+file&aqs=chrome..69i57j0i512j0i22i30j0i390i650l3.181j0j7&sourceid=chrome&ie=UTF-8&safe=active&ssui=on

danielkwalsh commented 1 year ago

Hmm, so what should I do then?

danielkwalsh commented 1 year ago

Ah... Guess what? By following one of your links, I saw someone mention that a conda environment could be the issue. I deactivated my base environment, and I think that may have solved it.

ianhbell commented 1 year ago

Weird. I will keep that in my brain for future re-use.

jcmendezcarvajal commented 7 months ago

Have you guys found a solution to the previous problem? I deactivate the conda env, and I have -- The Fortran compiler identification is GNU 13.2.0

ianhbell commented 7 months ago

I guess I would suggest to read the links listed above, other than that I have no idea