Resolving Error "ld: library not found for -lgfortran"

2,352 views
Skip to first unread message

Jatin Kashyap

unread,
Mar 8, 2018, 5:46:54 PM3/8/18
to openkim
Dear OpenKIM Users,

I’m trying to install the OpenKIM API in my MacBook (had already installed the KIM models), and getting the following error while following section “D” of Install document in documentation of OpenKIM API:


**************************************************************************************************************************************************************
Jatins-Air:kim-api-v1.9.3 kashyap$ make

*******************************************************************************
** Building... kim-api-objects                                               **
*******************************************************************************
make[1]: Nothing to be done for `objects'.

*******************************************************************************
** Building... kim-api-libs                                                  **
*******************************************************************************
Creating... KIM API library....... libkim-api-v1.9.3+GCC.darwin.64bit.dynamic-load.so.
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [libkim-api-v1.9.3+GCC.darwin.64bit.dynamic-load.so] Error 1
make: *** [kim-api-libs] Error 2
**************************************************************************************************************************************************************

I’m going to use it with LAMMPS on my local machine. And I already searched the forum for relevant content.

Thank you very much in advance for any hint to solve it.

Jatin Kashyap

unread,
Mar 8, 2018, 5:47:58 PM3/8/18
to openkim
By the way, I'm using macOS High Sierra v 10.13.1

Ryan S. Elliott

unread,
Mar 8, 2018, 6:39:31 PM3/8/18
to openkim
Hi Jatin,

Thanks for your message. This can be a bit tricky on the MacOS... Can you
provide a listing of your Makefile.KIM_Config file and the compiler (c, c++,
and fortran) versions you are using?

Thanks,

Ryan


On Thu, 8 Mar 2018, Jatin Kashyap wrote:

> By the way, I'm using macOS High Sierra v 10.13.1
>
> On Thursday, March 8, 2018 at 5:46:54 PM UTC-5, Jatin Kashyap wrote:
>>
>> Dear OpenKIM Users,
>>
>> I’m trying to install the OpenKIM API in my MacBook (had already installed
>> the KIM models), and getting the following error while following section
>> “D” of Install document in documentation of OpenKIM API:
>>
>>
>>
>> **************************************************************************************************************************************************************
>> *Jatins-Air:kim-api-v1.9.3 kashyap$ make*
>>
>>
>> *********************************************************************************
>> *** Building... kim-api-objects
>> ***
>>
>> *********************************************************************************
>> *make[1]: Nothing to be done for `objects'.*
>>
>>
>> *********************************************************************************
>> *** Building... kim-api-libs
>> ***
>>
>> *********************************************************************************
>> *Creating... KIM API library.......
>> libkim-api-v1.9.3+GCC.darwin.64bit.dynamic-load.so
>> <http://GCC.darwin.64bit.dynamic-load.so>.*
>> *ld: library not found for -lgfortran*
>> *clang: error: linker command failed with exit code 1 (use -v to see
>> invocation)*
>> *make[1]: *** [libkim-api-v1.9.3+GCC.darwin.64bit.dynamic-load.so
>> <http://GCC.darwin.64bit.dynamic-load.so>] Error 1*
>> *make: *** [kim-api-libs] Error 2*
>>
>> **************************************************************************************************************************************************************
>>
>> I’m going to use it with LAMMPS on my local machine. And I already
>> searched the forum for relevant content.
>>
>> Thank you very much in advance for any hint to solve it.
>>
>
>

--
Ryan S. Elliott, Ph.D. and Associate Professor
Aerospace Engineering & Mechanics, University of Minnesota
(612) 624-2376 (626-1558 fax)
http://www.aem.umn.edu/~relliott/
download vCard <http://www.aem.umn.edu/~relliott/relliott.vcf>
----------
I don't mind your thinking slowly; I mind your publishing faster than you
think.

Pauli
----------

Jatin Kashyap

unread,
Mar 9, 2018, 4:34:41 PM3/9/18
to openkim
Hello Relliott,

I'm getting following for Makefile.KIM_Config search:

Jatins-Air:src kashyap$ locate Makefile.KIM_Config
/Users/kashyap/kim-api-v1.9.3/Makefile.KIM_Config
/Users/kashyap/kim-api-v1.9.3/Makefile.KIM_Config.example
/Users/kashyap/kim-api-v1.9.3/examples/model_drivers/Makefile.KIM_Config
/Users/kashyap/kim-api-v1.9.3/examples/models/Makefile.KIM_Config


And this one for the fortran compiler:

Jatins-Air:src kashyap$ gfortran --version
GNU Fortran (Homebrew GCC 7.3.0) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.


Thank you very much for a quick, and informative reply.

Jatin Kashyap

unread,
Mar 9, 2018, 4:37:01 PM3/9/18
to openkim
I'm greatly sorry Ryan, I just realized my mistake of misinterpreting your name.
Thank you. 


On Thursday, March 8, 2018 at 5:46:54 PM UTC-5, Jatin Kashyap wrote:

Ryan S. Elliott

unread,
Mar 9, 2018, 5:31:13 PM3/9/18
to openkim
Hi Jatin,

No problem....


OK, I just tested it out and I was able to get it all to work using the
following configuration command:


./configure --prefix=${HOME}/local --system-arch=32bit CC=gcc-7 CXX=g++-7 FC=gfortran-7 LDFLAGS+="-read_only_relocs suppress"

Explaination:

'--system-arch=32bit'

Due to a gfortran bug on MacOS we can only get the KIM API to compile
in 32 bit mode...

'CC=gcc-7'
'CXX=g++-7'
'FC=gfortran-7'

These settings tell the build system how to find the correct compilers
you have installed on your system. In your case these are the versions
installed via homebrew.

'LDFLAGS+="-read_only_relocs suppress"'

This setting works-around another bug in the gfortran compiler on
MacOS.


For everyone's reference, these things are also explained in Section F.1(h) of
the INSTALL file.



Try that configure command and see if it works for you now....


Cheers,



Ryan


On Fri, 9 Mar 2018, Jatin Kashyap wrote:

> I'm greatly sorry Ryan, I just realized my mistake of misinterpreting your
> name.
> Thank you.
>
> On Thursday, March 8, 2018 at 5:46:54 PM UTC-5, Jatin Kashyap wrote:
>>
>> Dear OpenKIM Users,
>>
>> I’m trying to install the OpenKIM API in my MacBook (had already installed
>> the KIM models), and getting the following error while following section
>> “D” of Install document in documentation of OpenKIM API:
>>
>>
>>
>> **************************************************************************************************************************************************************
>> *Jatins-Air:kim-api-v1.9.3 kashyap$ make*
>>
>>
>> *********************************************************************************
>> *** Building... kim-api-objects
>> ***
>>
>> *********************************************************************************
>> *make[1]: Nothing to be done for `objects'.*
>>
>>
>> *********************************************************************************
>> *** Building... kim-api-libs
>> ***
>>
>> *********************************************************************************
>> *Creating... KIM API library.......
>> libkim-api-v1.9.3+GCC.darwin.64bit.dynamic-load.so
>> <http://GCC.darwin.64bit.dynamic-load.so>.*
>> *ld: library not found for -lgfortran*
>> *clang: error: linker command failed with exit code 1 (use -v to see
>> invocation)*
>> *make[1]: *** [libkim-api-v1.9.3+GCC.darwin.64bit.dynamic-load.so
>> <http://GCC.darwin.64bit.dynamic-load.so>] Error 1*
>> *make: *** [kim-api-libs] Error 2*
>>
>> **************************************************************************************************************************************************************
>>
>> I’m going to use it with LAMMPS on my local machine. And I already
>> searched the forum for relevant content.
>>
>> Thank you very much in advance for any hint to solve it.
>>
>
>

--
Ryan S. Elliott, Ph.D. and Associate Professor
Aerospace Engineering & Mechanics, University of Minnesota
(612) 624-2376 (626-1558 fax)
http://www.aem.umn.edu/~relliott/
download vCard <http://www.aem.umn.edu/~relliott/relliott.vcf>
----------
[On Christopher Columbus's (later life) suggestion of a "pear-shaped"
earth] ... The willingness to reexamine lifelong beliefs because of
conflicting data takes enormous courage, and contrasts sharply with
recent examples of public discourse in which our political, cultural,
and religious leaders have fit data to preconceived theories.

Donal O'Shea
----------

Jatin Kashyap

unread,
Mar 12, 2018, 1:57:02 PM3/12/18
to openkim
Hello Ryan,

Thank you very much for a quick, and very informative reply. This time, I'm getting a new error as below

Jatins-MacBook-Air:~ kashyap$ kim-api-vX-collections-management install system --sudo EDIP_BOP_Bazant_Kaxiras_Si__MO_958932894036_001
-bash: kim-api-vX-collections-management: command not found 

I had already installed wget and tar according to point # 5 of system requirements section of the install doc. I know it's very trivial mistake but I'm not able to figure it out. Your help will be much appreciated.

Thank you for your time, and efforts.


On Thursday, March 8, 2018 at 5:46:54 PM UTC-5, Jatin Kashyap wrote:

Daniel Karls

unread,
Mar 12, 2018, 2:08:26 PM3/12/18
to ope...@googlegroups.com
Hi Jatin,

You need to replace the 'X' in 'vX' with the current major version of the API you're using.  Check if 'kim-api-v1-collections-management' is on your path and repeat the install command with that.

Dan
--
______________________________________

Daniel S. Karls, Postdoctoral Associate

Aerospace Engineering & Mechanics
University of Minnesota
107 Akerman Hall, 110 Union St SE
Minneapolis, MN 55455
______________________________________

Jatin Kashyap

unread,
Mar 12, 2018, 3:26:48 PM3/12/18
to openkim
Hello Dan,

I repeated the install command after replacing the X with the major version number according to your instructions. Although I'm not sure about the second part of your answer. For the reference, I'm attaching the screenshot of my terminal showing important information.
Thank you for your time.

Daniel Karls

unread,
Mar 12, 2018, 3:35:03 PM3/12/18
to ope...@googlegroups.com
Hi Jatin,

Looks like the screenshot never got attached.  What was the output of doing `kim-api-v1-collections-management install system --sudo EDIP_BOP_Bazant_Kaxiras_Si__MO_958932894036_001`?

The second part of my answer pertains to what your terminal was complaining about.  Your "system path", contained in the shell variable PATH, consists of all of the directories on your machine where your shell (bash, in this case) searches for commands to execute.  You can view your current system path by entering `echo $PATH` (see here for reference).  In this case, your shell was saying that command "kim-api-vX-collections-management" could not be found because it didn't find any executable file with that name in any of those directories.  This is simply because the actual executable file that the KIM API creates during installation is named "kim-api-v1-collections-management" in your case.

Jatin Kashyap

unread,
Mar 12, 2018, 3:53:25 PM3/12/18
to openkim
Hello Dan,

Thank you for a very informative reply. I'm sorry for the attachment. I'm copy-pasting the error here which is basically the same:

Jatins-MacBook-Air:~ kashyap$ kim-api-v1-collections-management install system --sudo EDIP_BOP_Bazant_Kaxiras_Si__MO_958932894036_001
-bash: kim-api-v1-collections-management: command not found

Daniel Karls

unread,
Mar 12, 2018, 4:01:49 PM3/12/18
to ope...@googlegroups.com
On Mon, Mar 12, 2018 at 12:53 PM, Jatin Kashyap <mrjatin...@gmail.com> wrote:
Hello Dan,

Thank you for a very informative reply. I'm sorry for the attachment. I'm copy-pasting the error here which is basically the same:

Jatins-MacBook-Air:~ kashyap$ kim-api-v1-collections-management install system --sudo EDIP_BOP_Bazant_Kaxiras_Si__MO_958932894036_001
-bash: kim-api-v1-collections-management: command not found

Did you remember to issue a `make install` after doing `make` to compile the API?

Message has been deleted

Ryan S. Elliott

unread,
Mar 12, 2018, 4:15:07 PM3/12/18
to ope...@googlegroups.com
Also,

Since you are installing to a non-standard directory you will need to
"activate" (add to your PATH variable) the api.

There is now a utility for doing this:

$ source ./${HOME}/local/bin/kim-api-v1-activate

This will need to be done once in any shell that you want to use the kim-api
utilities within. (Alternatively you put this command in one of your shell
configuration files, such as ${HOME}/.bashrc)


Ryan


On Mon, 12 Mar 2018, Daniel Karls wrote:

> On Mon, Mar 12, 2018 at 12:53 PM, Jatin Kashyap <mrjatin...@gmail.com>
> wrote:
>
>> Hello Dan,
>>
>> Thank you for a very informative reply. I'm sorry for the attachment. I'm
>> copy-pasting the error here which is basically the same:
>>
>> *Jatins-MacBook-Air:~ kashyap$ kim-api-v1-collections-management install
>> system --sudo EDIP_BOP_Bazant_Kaxiras_Si__MO_958932894036_001*
>> *-bash: kim-api-v1-collections-management: command not found*
>>
>
> Did you remember to issue a `make install` after doing `make` to compile
> the API?
>
>

--
Ryan S. Elliott, Ph.D. and Associate Professor
Aerospace Engineering & Mechanics, University of Minnesota
(612) 624-2376 (626-1558 fax)
http://www.aem.umn.edu/~relliott/
download vCard <http://www.aem.umn.edu/~relliott/relliott.vcf>
----------
The secret of joy in work is contained in one word---excellence. To know
how to do something well is to enjoy it.

Pearl S. Buck
----------
Message has been deleted

Ryan S. Elliott

unread,
Mar 13, 2018, 9:38:27 AM3/13/18
to ope...@googlegroups.com
Sorry,
 There is a typo, the correct command should be:


$ source ${HOME}/local/bin/kim-api-v1-activate

Without the “./“ before “${HOME}”


Ryan

Sent from my iPhone

Jatin Kashyap

unread,
Mar 13, 2018, 6:29:01 PM3/13/18
to openkim
Hi Ryan,

Thanks for the help, and it really solved the problem which I was facing while installing KIM API. But now I'm facing problem while making lammps after installing kim package. When I go with the command "make mpi" to recompile the lammps, it throws me following error:

Jatins-MacBook-Air:src kashyap$ make mpi
../../lib/kim/Makefile.lammps:27: *** kim-api-build-config utility is not available.  Something is wrong with your KIM API package setup.  Stop.
../../lib/kim/Makefile.lammps:27: *** kim-api-build-config utility is not available.  Something is wrong with your KIM API package setup.  Stop.
make: *** [mpi] Error 2

Thank you for helping me out here.

Ryan S. Elliott

unread,
Mar 13, 2018, 6:55:33 PM3/13/18
to openkim
> Thanks for the help, and it really solved the problem which I was facing
> while installing KIM API.

I'm glad you were able to get the KIM API working!

> But now I'm facing problem while making
> lammps after installing kim package. When I go with the command "make mpi"
> to recompile the lammps, it throws me following error:
>
> *Jatins-MacBook-Air:src kashyap$ make mpi*
> *../../lib/kim/Makefile.lammps:27: *** kim-api-build-config utility is not
> available. Something is wrong with your KIM API package setup. Stop.*
> *../../lib/kim/Makefile.lammps:27: *** kim-api-build-config utility is not
> available. Something is wrong with your KIM API package setup. Stop.*
> *make: *** [mpi] Error 2*
>

OK, for this I'll need to know the specific version of LAMMPS you are using and
what (if any) modifications you have made to the lammps makefile names
"src/MAKE/Makefile.mpi".

(Any other changes you have made to the lammps files may also be helpful.)


Cheers,

Ryan


Jatin Kashyap

unread,
Mar 13, 2018, 7:27:29 PM3/13/18
to openkim
Hello Ryan,

I'm using "lammps-11Aug17". The only change I had made to lammps is, I had added a new REBO potential (.cpp and .h files of it) to the src/ and then recompiled it which was working without any problem. Other then this I didn't make any changes to it.

Please let me know if you need any other information.
Thank you.

Ryan S. Elliott

unread,
Mar 13, 2018, 7:45:02 PM3/13/18
to openkim
Hi Jatin,

OK. For that version of LAMMPS you'll need to edit the lib/kim/Makefile.lammps
file and change "kim-api-build-config" to "kim-api-v1-build-config" everywhere
in that file.

I think that will fix the error you are having regarding "kim-api-build-config
utility is not available"


However, the Makefile.mpi build uses the mpicxx compiler to build lammps.
Since we used the g++-7 compiler to build the kim-api, I'm not sure if the
lammps build with mpicxx will be successful.

I've never tried to do an mpi build, like this, on MacOS before. I'm afraid
that if we run into problems at this point, it would require rather more
experimentation and time to figure out how to get it to work...

But, maybe it will just work!


Good luck.


Ryan
--
Ryan S. Elliott, Ph.D. and Associate Professor
Aerospace Engineering & Mechanics, University of Minnesota
(612) 624-2376 (626-1558 fax)
http://www.aem.umn.edu/~relliott/
download vCard <http://www.aem.umn.edu/~relliott/relliott.vcf>
----------
In the three books of the Principia, Newton displays in the highest every
ability of a great theorist: (1) to organize, derive by mathematics and
recast known but separated laws and phenomena; (2) to create new
concepts; (3) to obtain detailed numerical predictions and compare them
with measured values.

Truesdell, 1968, p91
----------

Jatin Kashyap

unread,
Mar 14, 2018, 2:37:28 PM3/14/18
to openkim
Hi Ryan,

You're right. That solved the "kim-api-build-config utility is not available" error. But now I'm getting a new error more towards the end of process of building LAMMPS which goes as follows:


ld: warning: ignoring file write_dump.o, file was built for x86_64 which is not the architecture being linked (i386): write_dump.o
ld: warning: ignoring file /usr/local/Cellar/open-mpi/3.0.0_2/lib/libmpi.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/Cellar/open-mpi/3.0.0_2/lib/libmpi.dylib
Undefined symbols for architecture i386:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [../lmp_mpi] Error 1
make: *** [mpi] Error 2


I think it's due to the same compiler incompatibility issue that you had already described. Anyways, given the situation can you please help me with the below questions:

1.) Do you think, there will be no problem if I install Linux in VirtualBox hosted by my MacBook and then try to use KIM models in LAMMPS installed in that Linux OS? If so, then with which linux OS should I go ahead.

2.) I also have access to our university cluster which is having LAMMPS build upon Scientific Linux OS. But I noticed, to install the KIM API sudo command have to be used which can't be used by me on our university cluster since I'm a student. Do you think there is any other option to install KIM API on university cluster(bypassing sudo command) other than asking the admin people?  

Ryan S. Elliott

unread,
Mar 14, 2018, 4:49:35 PM3/14/18
to openkim
On Wed, 14 Mar 2018, Jatin Kashyap wrote:

> Hi Ryan,
>
> You're right. That solved the "kim-api-build-config utility is not
> available" error.

Great.

> 1.) Do you think, there will be no problem if I install Linux in VirtualBox
> hosted by my MacBook and then try to use KIM models in LAMMPS installed in
> that Linux OS? If so, then with which linux OS should I go ahead.

Yes, this will be quite straight foward, and I think probably the best option.


I have just tested this on my mac using the standard Ubuntu64 Artful image
(via vagrant and VirtualBox):

* perform any updates for the box.

* Install some dependencies:

$ sudo apt-get install make python g++ gfortran mpi-default-bin mpi-default-dev fftw-dev

* get the latest lammps:

$ wget http://lammps.sandia.gov/tars/lammps-8Mar18.tar.gz

* unpack it

$ tar xzvf lammps-8Mar18.tar.gz

* change dir

$ cd lammps-8Mar18/src

* build kim-api and install a model of interest (eg: Glue_Ercolessi_Adams_Al__MO_324507536345_001)

$ make lib-kim args="-v kim-api-v1.9.3 -b -a Glue_Ercolessi_Adams_Al__MO_324507536345_001"

* build lammps with kim support

$ make yes-kim
$ make mpi


* add anohter KIM model if desired (eg: Pair_Johnson_Fe__MO_857282754307_002)

$ source ../lib/kim/installed-kim-api-v1.9.3/bin/kim-api-v1-activate

$ kim-api-v1-collections-management install system Pair_Johnson_Fe__MO_857282754307_002


Cheers,


Ryan
Message has been deleted

Ryan S. Elliott

unread,
Mar 16, 2018, 10:39:34 AM3/16/18
to openkim
On Wed, 14 Mar 2018, Jatin Kashyap wrote:

> Thanks a lot for the work. I just followed all the below mentioned steps,
> and it's working without any problem. I just finished running example
> problems successfully.

Great! I'm gald your got it all working.


> Can you please help me with two below mentioned points:
>
> 1.) We don't have to recompile the LAMMPS every-time we add a new model
> and/or driver, right?

Correct, you can add KIM models at anytime and there is no need to recompile
lammps.


> 2.) Running on a virtual or local machine is okay for time being but
> ultimately I've to run the kim models on our university cluster where I
> can't use sudo command. What would you suggest if I want to use kim models
> with the jobs on my university cluster in the given scenerio.

You can do it very much like you did on the VM. There was no use of sudo in
that case. The only complication may be some fiddling with the compiles that
are used to make sure that the kim-api and lammps are built using the same
suite of compilers (c, c++, and forgran).



Cheers,


Ryan

Jatin Kashyap

unread,
Mar 19, 2018, 12:31:39 PM3/19/18
to openkim
I just finished doing it on my university cluster with the help of cluster admin. Yes, I've to load some extra module but I was able to compile it successfully.

Thank you, Ryan & Daniel, for your time, and efforts during this period.
Cheers. 
Reply all
Reply to author
Forward
0 new messages