[ncl-install] Trouble in Building NCL on Mac OS with Ifort andClang

Kian kian-huang at qq.com
Fri Jul 21 05:37:35 MDT 2017


Hi Marry,
 
Recently, I have attended the International Seminar on Climate System and Climate Change, so I have limited time to try building NCL. Now I have found some solutions to solve problems:
 
 
 
1.     In front of the macro definition in include files, which will be used to create ./makefile later, such as ./config/Darwin_Intel (in my computer) and ./config/Template, there should be NO space there. If do not delete the space, default cpp with Mac OS will not process macro expectantly.
 
2.     Maybe due to the different developers of clang and intel compiler, the location of dynamic link libraries of ifort (in cross compilation part) cannot add automatically by clang, so we should add into compiling options with using
 
-Wl,-rpath,<intel lib dir>
 
 (please pay attention to ,)
 
e.g. I set the ./config/Darwin_Intel with
 
#define FcOptions          -qopenmp -L/opt/intel/lib -lintlc -lsvml -lifcore -lifport -liomp5 -limf -Wl,-rpath,/opt/intel/lib
 
#define CtoFLibraries      -L/opt/intel/lib -lintlc -lsvml -lifcore -lifport -liomp5 -limf -Wl,-rpath,/opt/intel/lib
 
 
 
Notice that, ifort recommends us to use –qopenmp instead of –openmp. Besides, there is no libm.xxx in ifort and we should use –limf instead of –lm.
 
 
 
In addition, if you have compiled the NCL successfully ($NCARG_ROOT/bin/ncl existing), and when running NCL (such as ncl) , there are a lot of problems like
 
- dyld: Library not loaded: @rpath/xxx.dylib
 
Reason: image not found
 
You can use otool –L xxx to know which dynamic link libraries the xxx need. For example, in my computer,
 
otool -L /usr/local/Cellar/ncarg/6.4.0/bin/ncl
 
(I use homebrew to manage software that are installed by make etc..)
 
Then, you will get the dynamic link libraries information of xxx, such as
 
/usr/local/Cellar/ncarg/6.4.0/bin/ncl:
 
/opt/intel/compilers_and_libraries_2017.4.181/mac/compiler/lib/libintlc.dylib
 
If you find something like
 
@rpath/xxx.dylib
 
now you can use
 
install_name_tool –change old new xxx
 
to correct the location of dynamic link library using by xxx. For example,
 
install_name_tool –change @rpath/libintlc.dylib /opt/intel/compilers_and_libraries_2017.4.181/mac/compiler/lib/libintlc.dylib ncl
 
3.     Delete –D_POXIS_SOURCE from #define StdDefines and –ansi from #define CcOptions
 
The –D_POXIS_SOURCE would cause some system not found.
 
The –ansi option would cause an error when a statement is so long that have to continue in a newline in compiling C files.
 
eemd.c:34:8: error: expected identifier or '('
 
 
 
This is my Darwin_Intel as following (clang offers openmp support default)
 
#define HdfDefines  -DDARWIN
 
#define StdDefines  -DSYSV -D_XOPEN_SOURCE -DByteSwapped -D__UNIXOS2__
 
#define ByteSwapped
 
#define Cstatic
 
#define Cdynamic
 
#define CppCommand         cpp
 
#define CCompiler          clang
 
#define CxxCompiler        clang++
 
#define FCompiler          ifort
 
#define CcOptions          
 
#define FcOptions          -qopenmp -L/opt/intel/lib -lintlc -lsvml -lifcore -lifport -liomp5 -limf -Wl,-rpath,/opt/intel/lib
 
#define CtoFLibraries      -L/opt/intel/lib -lintlc -lsvml -lifcore -lifport -liomp5 -limf -Wl,-rpath,/opt/intel/lib
 
#define CtoFLibrariesUser  
 
#define XToolLibrary       -lXt -lSM -lICE
 
#define BuildShared        NO
 
#define XLibrary           -lXpm -lX11 -lXext
 
 
 
#define LibSearchUser    -L/opt/X11/lib
 
#define IncSearchUser    -I/opt/X11/include -I/opt/X11/include/freetype2
 
 
 
#define ArchRecLibSearch    -L/opt/X11/lib
 
#define ArchRecIncSearch    -I/opt/X11/include -I/opt/X11/include/freetype2
 
 
 
F77 = ifort
 
FC = $(F77)
 
 
 
Finally, in order to debug/compile the NCL, I almost study all about how NCL create makefile and learn a new script language csh. Em.. Although it takes me a lot of time, it is worthy for me.
 


------------------
Kian Huang


 




------------------ Original ------------------
From:  "Mary Haley";<haley at ucar.edu>;
Date:  Mon, Jul 10, 2017 09:37 PM
To:  "Kian"<kian-huang at qq.com>; 
Cc:  "Kevin Hallock"<hallock at ucar.edu>; "ncl-install"<ncl-install at ucar.edu>; 
Subject:  Re: [ncl-install] Trouble in Building NCL on Mac OS with Ifort andClang



If I may jump in, it looks like the problem is with building "Iftran" which is a converter used to convert some really old Iftran code to Fortran 77.


It appears that this executable is producing an error when it is used to convert the code:


dyld: Library not loaded: @rpath/libintlc.dylib
  Referenced from: /Users/kian/Downloads/ncl_ncarg-6.4.0/ncarg2d/src/libncarg/vaspackt/../../../.././ncarg2d/src/libncarg/Iftran/Iftran
  Reason: image not found
/bin/sh: line 1:  4095 Abort trap: 6           ../../../.././ncarg2d/src/libncarg/Iftran/Iftran < CodeIftran > CodeFortran


We have built NCL successfully using ifort and icc together, but we have never tried it with ifort and clang.  Is there a reason you need this particular combination, and not gfortran and clang?


If you look at the make-output file for where it is building Iftran:


Making ./ncarg2d/src/libncarg/Iftran
ifort  -O    -c -o Iftran.o Iftran.f
ifort  -O    -o Iftran Iftran.o -L../../../.././common/src/libncarg_c -lncarg_c -L "/opt/intel/lib" -lm -lintlc -lsvml -lifcore -lifport -liomp5 -L/usr/local/Cellar/ncarg/6.4.0/lib -L/opt/X11/lib
clang  -O  -I../../../.././include -I/opt/X11/include -I/opt/X11/include/freetype2    -DSYSV -D_POSIX_SOURCE -D_XOPEN_SOURCE -DByteSwapped -D__UNIXOS2__ -D_DARWIN_C_SOURCE -DNeedFuncProto    -c -o Fsplit.o Fsplit.c
Fsplit.c:28:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main(int argc, char **argv) {
^
Fsplit.c:90:47: warning: implicitly declaring library function 'isspace' with type 'int (int)' [-Wimplicit-function-declaration]
      collecting=!(comment=(c=='c'||c=='C'))&&isspace(c);
                                              ^


there are some warnings, but nothing seems to indicate why it would fail.  However, since the error mentions "libintlc.dylib", I'm wondering if maybe you should try removing all the extra intel libraries from the Iftran compile line to see if it works.


Try this:


1. Cd to the directory containing the "Iftran" code (I'll use $NCARG to represent the top level NCARG/NCL source tree):


cd $NCARG/ncarg2d/src/libncarg/Iftran


2. Edit the Makefile in this directory and remove all references to:


-lintlc -lsvml -lifcore -lifport -liomp5



3. From the same directory, try recompiling Iftran:


rm Iftran
make all


4. If Iftran gets built without errors, then see if it works by cding to another directory that depends on it:


cd $NCARG/ncarg2d/src/libncarg/areas
make clean all 


If this all seems to work, then you can start up the build again with:


cd $NCARG
make clean all install > make-output.2 2>&1 &


​and let us know how it goes.​



--Mary





On Sat, Jul 8, 2017 at 7:14 AM, Kian <kian-huang at qq.com> wrote:


Hi Kevin,


Thanks for your help. Your solution for linking X11 library has worked perfectly. However, the solution that aims at C to Fortran library seems to have problems.


The whole make-output file is in the attachment. Here is one of related errors as following:


Making ./ncarg2d/src/libncarg/conpack
dyld: Library not loaded: @rpath/libintlc.dylib
  Referenced from: /Users/kian/Downloads/ncl_ncarg-6.4.0/ncarg2d/src/libncarg/conpack/../../../.././ncarg2d/src/libncarg/Iftran/Iftran
  Reason: image not found
/bin/sh: line 1: 82922 Abort trap: 6           ../../../.././ncarg2d/src/libncarg/Iftran/Iftran < CodeIftran > CodeFortran
make[5]: *** [IftranRun] Error 134
Making ./ncarg2d/src/libncarg/conpackt
dyld: Library not loaded: @rpath/libintlc.dylib
  Referenced from: /Users/kian/Downloads/ncl_ncarg-6.4.0/ncarg2d/src/libncarg/conpackt/../../../.././ncarg2d/src/libncarg/Iftran/Iftran
  Reason: image not found
/bin/sh: line 1: 82928 Abort trap: 6           ../../../.././ncarg2d/src/libncarg/Iftran/Iftran < CodeIftran > CodeFortran



------------------
Kian Huang


 




------------------ Original ------------------
From:  "Kevin Hallock";<hallock at ucar.edu>;
Date:  Sat, Jul 8, 2017 02:15 AM
To:  "Kian"<kian-huang at qq.com>; 
Cc:  "ncl-install"<ncl-install at ucar.edu>; 
Subject:  Re: [ncl-install] Trouble in Building NCL on Mac OS with Ifort andClang



Hi Kian,

According to one of our other developers, changing your CtoFLibraries and CtoFLibrariesUser definitions to something like this might fix the linking issue:
#define CtoFLibraries -L "/opt/intel/lib" -lm -lintlc -lsvml -lifcore -lifport -liomp5
#define CtoFLibrariesUser -L "/opt/intel/lib" -lm -lintlc -lsvml -lifcore -lifport

I hope this helps,
Kevin

On Jul 7, 2017, at 11:20 AM, Kevin Hallock <hallock at ucar.edu> wrote:

Hi Kian,

“ft2build.h” is provided by XQuartz in the “/opt/X11/include/freetype2” directory, so you might need to add “-I/opt/X11/include/freetype2” to your clang command.


I don’t have any experience with ifort myself, and I’m not sure why it’s failing to load the appropriate dynamic libraries, but I will ask some of the other NCL developers if they’ve experienced this behavior when using ifort.


Kevin


On Jul 7, 2017, at 1:41 AM, Kian <kian-huang at qq.com> wrote:



Hi everyone,


I am trying to build NCL on Mac OS with ifort, clang compilers and XQuartz library these days and I have some trouble. I have solved some of these problem, but still left some. Thank you for reading and hope for solutions.


This is my operational system kernel information:
Darwin Kernel Version 16.6.0


The error information I met list as following:


clang  -O  -I../../../.././include -I/opt/X11/include  -DDarwin    -DCTXT -DX11 -DPS -DPDF -DPIX  -DSYSV -D_POSIX_SOURCE -D_XOPEN_SOURCE -DByteSwapped -D__UNIXOS2__ -D_DARWIN_C_SOURCE -DNeedFuncProto    -c -o cro_device.o cro_device.c
In file included from cro_device.c:26:
In file included from ./cro.h:147:
/opt/X11/include/cairo/cairo-ft.h:46:10: fatal error: 'ft2build.h' file not found
#include <ft2build.h>
         ^
1 error generated.
make[5]: *** [cro_device.o] Error 1





Previously, I met another problem. Log file (make-output) showed that the compiler can not load the ifort dynamic libraries. I solved it by using static linking by setting


#define CtoFLibraries  /opt/intel/lib/libifcore.a  /opt/intel/lib/libsvml.a  /opt/intel/lib/libimf.a /opt/intel/lib/libirc.a /opt/intel/lib/libiomp5.a
#define CtoFLibrariesUser  /opt/intel/lib/libifcore.a  /opt/intel/lib/libsvml.a /opt/intel/lib/libimf.a /opt/intel/lib/libirc.a /opt/intel/lib/libiomp5.a



But it was invalid for ifort -openmp option (Maybe change makefile setting will solve that. I have not tried it yet).
------------------
Kian Huang


 
_______________________________________________
ncl-install mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-install













_______________________________________________
 ncl-install mailing list
 List instructions, subscriber options, unsubscribe:
 http://mailman.ucar.edu/mailman/listinfo/ncl-install
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-install/attachments/20170721/5fe7a9bb/attachment-0001.html 


More information about the ncl-install mailing list