Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build issue, compiling on Ubuntu Linux 64* recipe for target *** failed #420

Closed
Seager1989 opened this issue Mar 23, 2020 · 12 comments
Closed
Assignees

Comments

@Seager1989
Copy link

Bug description
I am a beginner on the OpenFAST and try to make it on a virtual box based Ubuntu Linux 64 bit system. I assigned 11G RAM for this system and using the following cmake command and them make. The errors with the feature of 'receipe for targer *** failed'.

CMAKE:
$ cmake .. -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_BUILD_TYPE=Debug
Then,
$ make install

The detailed error information:
"
[ 15%] Linking Fortran executable inflowwind_driver
../nwtc-library/libnwtclibs.so: undefined reference to lsame_' ../nwtc-library/libnwtclibs.so: undefined reference to sggev_'
../nwtc-library/libnwtclibs.so: undefined reference to dgemm_' ../nwtc-library/libnwtclibs.so: undefined reference to dposv_'
../nwtc-library/libnwtclibs.so: undefined reference to spptrf_' ../nwtc-library/libnwtclibs.so: undefined reference to dpptrf_'
../nwtc-library/libnwtclibs.so: undefined reference to sgetri_' ../nwtc-library/libnwtclibs.so: undefined reference to dgesv_'
../nwtc-library/libnwtclibs.so: undefined reference to dgetrf_' ../nwtc-library/libnwtclibs.so: undefined reference to sgesvd_'
../nwtc-library/libnwtclibs.so: undefined reference to sgemm_' ../nwtc-library/libnwtclibs.so: undefined reference to dgbsv_'
../nwtc-library/libnwtclibs.so: undefined reference to sgetrs_' ../nwtc-library/libnwtclibs.so: undefined reference to sgetrf_'
../nwtc-library/libnwtclibs.so: undefined reference to dggev_' ../nwtc-library/libnwtclibs.so: undefined reference to xerbla_'
../nwtc-library/libnwtclibs.so: undefined reference to sgbsv_' ../nwtc-library/libnwtclibs.so: undefined reference to sgesv_'
../nwtc-library/libnwtclibs.so: undefined reference to sposv_' ../nwtc-library/libnwtclibs.so: undefined reference to dgesvd_'
../nwtc-library/libnwtclibs.so: undefined reference to dgetrs_' ../nwtc-library/libnwtclibs.so: undefined reference to dgetri_'
collect2: error: ld returned 1 exit status
modules/inflowwind/CMakeFiles/inflowwind_driver.dir/build.make:148: recipe for target 'modules/inflowwind/inflowwind_driver' failed
make[2]: *** [modules/inflowwind/inflowwind_driver] Error 1
CMakeFiles/Makefile2:1040: recipe for target 'modules/inflowwind/CMakeFiles/inflowwind_driver.dir/all' failed
make[1]: *** [modules/inflowwind/CMakeFiles/inflowwind_driver.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
"

I checked some similar issues including increase RAM, using RelWithDebInfo build type, and change to debug mode, but they can not work on this problem.

It is appreciated if someone to can give suggestions to fix this issue? Thanks

@Seager1989 Seager1989 changed the title Bug report, compiling on Ubuntu Linux 64* receipe for targer *** failed Build issue, compiling on Ubuntu Linux 64* receipe for targer *** failed Mar 23, 2020
@andrew-platt
Copy link
Collaborator

The functions that it is not finding during linking are from the LAPACK and BLAS libraries. Do you have those installed, and did CMake successfully find them?

This might help with installing them: https://askubuntu.com/questions/623578/installing-blas-and-lapack-packages

@Seager1989
Copy link
Author

The functions that it is not finding during linking are from the LAPACK and BLAS libraries. Do you have those installed, and did CMake successfully find them?

This might help with installing them: https://askubuntu.com/questions/623578/installing-blas-and-lapack-packages

Thank you!
I have them installed as following shown,

seager1989@seager1989-VirtualBox:/usr/local/lib$ ls
hdf5 libgmock.a libgtest.a liblapack.a python3.6
libblas.a libgmock_main.a libgtest_main.a libyaml-cpp.a

I specified their directory during Cmake and it also did not work with the same error. I also noticed some warnings during Cmake (WARNING: Target "icedynlib" requests linking to directory "/usr/local/lib". Targets may link only to libraries. CMake is dropping the item).

Cmake:
$cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=ON -DBLAS_LIBRARIES="/usr/local/lib" -DLAPACK_LIBRARIES="/usr/local/lib"

$make install
(In addition to errors, this also worked with warning: Warning: ‘__builtin_memset’: specified size 18446744073709551598 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
/home/seager1989/Downloads/openfast/modules/nwtc-library/src/ModMesh.f90:3323:0:

                  ErrMsg = 'MeshExtrapInterp1:'//TRIM(ErrMsg)

)

Error:
[ 15%] Linking Fortran executable inflowwind_driver
../nwtc-library/libnwtclibs.so: undefined reference to lsame_' ../nwtc-library/libnwtclibs.so: undefined reference to sggev_'
../nwtc-library/libnwtclibs.so: undefined reference to dgemm_' ../nwtc-library/libnwtclibs.so: undefined reference to dposv_'
../nwtc-library/libnwtclibs.so: undefined reference to spptrf_' ../nwtc-library/libnwtclibs.so: undefined reference to dpptrf_'
../nwtc-library/libnwtclibs.so: undefined reference to sgetri_' ../nwtc-library/libnwtclibs.so: undefined reference to dgesv_'
../nwtc-library/libnwtclibs.so: undefined reference to dgetrf_' ../nwtc-library/libnwtclibs.so: undefined reference to sgesvd_'
../nwtc-library/libnwtclibs.so: undefined reference to sgemm_' ../nwtc-library/libnwtclibs.so: undefined reference to dgbsv_'
../nwtc-library/libnwtclibs.so: undefined reference to sgetrs_' ../nwtc-library/libnwtclibs.so: undefined reference to sgetrf_'
../nwtc-library/libnwtclibs.so: undefined reference to dggev_' ../nwtc-library/libnwtclibs.so: undefined reference to xerbla_'
../nwtc-library/libnwtclibs.so: undefined reference to sgbsv_' ../nwtc-library/libnwtclibs.so: undefined reference to sgesv_'
../nwtc-library/libnwtclibs.so: undefined reference to sposv_' ../nwtc-library/libnwtclibs.so: undefined reference to dgesvd_'
../nwtc-library/libnwtclibs.so: undefined reference to dgetrs_' ../nwtc-library/libnwtclibs.so: undefined reference to dgetri_'
collect2: error: ld returned 1 exit status
modules/inflowwind/CMakeFiles/inflowwind_driver.dir/build.make:148: recipe for target 'modules/inflowwind/inflowwind_driver' failed
make[2]: *** [modules/inflowwind/inflowwind_driver] Error 1
CMakeFiles/Makefile2:1040: recipe for target 'modules/inflowwind/CMakeFiles/inflowwind_driver.dir/all' failed
make[1]: *** [modules/inflowwind/CMakeFiles/inflowwind_driver.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2

@andrew-platt
Copy link
Collaborator

What happens if you specify the full paths for the libraries:
$cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=ON -DBLAS_LIBRARIES="/usr/local/lib/libblas.a" -DLAPACK_LIBRARIES="/usr/local/lib/liblapack.a"

The '__builtin_memset' memory warning can be safely ignored (it's a false positive due to the way the code is structured). We haven't had a chance to modify that so it doesn't occur yet.

@Seager1989
Copy link
Author

What happens if you specify the full paths for the libraries:
$cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=ON -DBLAS_LIBRARIES="/usr/local/lib/libblas.a" -DLAPACK_LIBRARIES="/usr/local/lib/liblapack.a"

The '__builtin_memset' memory warning can be safely ignored (it's a false positive due to the way the code is structured). We haven't had a chance to modify that so it doesn't occur yet.

If to do so, the error was changed to the 'libnwtclibs.so' as below details. I do not know if this helps.

[ 7%] Linking Fortran shared library libnwtclibs.so
/usr/bin/ld: /usr/local/lib/liblapack.a(spotrf2.o): relocation R_X86_64_PC32 against symbol `spotrf2_' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
modules/nwtc-library/CMakeFiles/nwtclibs.dir/build.make:563: recipe for target 'modules/nwtc-library/libnwtclibs.so' failed
make[2]: *** [modules/nwtc-library/libnwtclibs.so] Error 1
CMakeFiles/Makefile2:981: recipe for target 'modules/nwtc-library/CMakeFiles/nwtclibs.dir/all' failed
make[1]: *** [modules/nwtc-library/CMakeFiles/nwtclibs.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2

@Seager1989 Seager1989 changed the title Build issue, compiling on Ubuntu Linux 64* receipe for targer *** failed Build issue, compiling on Ubuntu Linux 64* recipe for target *** failed Mar 23, 2020
@andrew-platt
Copy link
Collaborator

Oh! I missed the -DBUILD_SHARED_LIBS=ON option passed to CMake. The libblas.a and liblapack.a are static archives, not shared libs. So it cannot be compiled this way. You need the .so versions for shared object linking.

I suspect you need to install the full set of libraries as outlined in the link above.

@Seager1989
Copy link
Author

Oh! I missed the -DBUILD_SHARED_LIBS=ON option passed to CMake. The libblas.a and liblapack.a are static archives, not shared libs. So it cannot be compiled this way. You need the .so versions for shared object linking.

I suspect you need to install the full set of libraries as outlined in the link above.

I tried to do so to install the BLAS and LAPACK by the following command.
$sudo apt-get install libblas-dev checkinstall
$sudo apt-get install liblapack-dev checkinstall

I tried three ways to specify their directory:

  1. -DBLAS_LIBRARIES="/usr/lib/x86_64-linux-gnu/blas/libblas.a" -DLAPACK_LIBRARIES="/usr/lib/x86_64-linux-gnu/lapack/liblapack.a"
  2. -DBLAS_LIBRARIES="/usr/lib/x86_64-linux-gnu/blas" -DLAPACK_LIBRARIES="/usr/lib/x86_64-linux-gnu/lapack"
  3. -DBLAS_LIBRARIES="/usr/lib/x86_64-linux-gnu" -DLAPACK_LIBRARIES="/usr/lib/x86_64-linux-gnu"

They presented the same error as I mentioned at the beginning.
[ 15%] Linking Fortran executable inflowwind_driver
../nwtc-library/libnwtclibs.so: undefined reference to sdot_' ../nwtc-library/libnwtclibs.so: undefined reference to dtrmm_'
../nwtc-library/libnwtclibs.so: undefined reference to snrm2_' ../nwtc-library/libnwtclibs.so: undefined reference to dswap_'
../nwtc-library/libnwtclibs.so: undefined reference to dgemm_' ../nwtc-library/libnwtclibs.so: undefined reference to dger_'
../nwtc-library/libnwtclibs.so: undefined reference to dtpsv_' ../nwtc-library/libnwtclibs.so: undefined reference to sspr_'
../nwtc-library/libnwtclibs.so: undefined reference to sswap_' ../nwtc-library/libnwtclibs.so: undefined reference to daxpy_'
../nwtc-library/libnwtclibs.so: undefined reference to stpsv_' ../nwtc-library/libnwtclibs.so: undefined reference to saxpy_'
../nwtc-library/libnwtclibs.so: undefined reference to dnrm2_' ../nwtc-library/libnwtclibs.so: undefined reference to srot_'
../nwtc-library/libnwtclibs.so: undefined reference to sscal_' ../nwtc-library/libnwtclibs.so: undefined reference to dcopy_'
../nwtc-library/libnwtclibs.so: undefined reference to dscal_' ../nwtc-library/libnwtclibs.so: undefined reference to strmm_'
../nwtc-library/libnwtclibs.so: undefined reference to ddot_' ../nwtc-library/libnwtclibs.so: undefined reference to isamax_'
../nwtc-library/libnwtclibs.so: undefined reference to stbsv_' ../nwtc-library/libnwtclibs.so: undefined reference to sgemm_'
../nwtc-library/libnwtclibs.so: undefined reference to scopy_' ../nwtc-library/libnwtclibs.so: undefined reference to dsyrk_'
../nwtc-library/libnwtclibs.so: undefined reference to dtrsm_' ../nwtc-library/libnwtclibs.so: undefined reference to idamax_'
../nwtc-library/libnwtclibs.so: undefined reference to dtbsv_' ../nwtc-library/libnwtclibs.so: undefined reference to strmv_'
../nwtc-library/libnwtclibs.so: undefined reference to dtrmv_' ../nwtc-library/libnwtclibs.so: undefined reference to dgemv_'
../nwtc-library/libnwtclibs.so: undefined reference to sgemv_' ../nwtc-library/libnwtclibs.so: undefined reference to sger_'
../nwtc-library/libnwtclibs.so: undefined reference to strsm_' ../nwtc-library/libnwtclibs.so: undefined reference to dspr_'
../nwtc-library/libnwtclibs.so: undefined reference to ssyrk_' ../nwtc-library/libnwtclibs.so: undefined reference to drot_'
collect2: error: ld returned 1 exit status
modules/inflowwind/CMakeFiles/inflowwind_driver.dir/build.make:149: recipe for target 'modules/inflowwind/inflowwind_driver' failed
make[2]: *** [modules/inflowwind/inflowwind_driver] Error 1
CMakeFiles/Makefile2:1040: recipe for target 'modules/inflowwind/CMakeFiles/inflowwind_driver.dir/all' failed
make[1]: *** [modules/inflowwind/CMakeFiles/inflowwind_driver.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2

@andrew-platt
Copy link
Collaborator

@rafmudaf do you have any thoughts here?

@rafmudaf
Copy link
Collaborator

I suggest removing any lapack and blas libraries you installed manually and leave the ones installed from apt-get. Then, delete your build directory and start over. I think your most recent issue is that CMake is still configured to look for the math libraries in the first location.

You could read the CMake section of the docs to understand this more.

@Seager1989
Copy link
Author

I suggest removing any lapack and blas libraries you installed manually and leave the ones installed from apt-get. Then, delete your build directory and start over. I think your most recent issue is that CMake is still configured to look for the math libraries in the first location.

You could read the CMake section of the docs to understand this more.

Thank you for your suggestions!

Actually, each time, I remove the content in build folder as I rebuilt the OpenFAST.

As you suggested, I removed the other lapack and blas, but the code was still running with the same error. Then, I try to run a single "$cmake .. " and it was working. I do not know why?

To find the reason for this weird phenomenon, I ran the following five setups by adding the options one by one (with the build folder removed each time).
##install
cmake ..

##install1
##adding the building test:
cmake .. -DCMAKE_INSTALL_PREFIX="/home/seager1989/Downloads/openfast/install1" -DBUILD_TESTING=ON

##install2
##adding the building test and shared libs:
cmake .. -DCMAKE_INSTALL_PREFIX="/home/seager1989/Downloads/openfast/install2" -DBUILD_TESTING=ON -DBUILD_SHARED_LIBS=ON

##install3
##adding the building test and shared libs and build type:
cmake .. -DCMAKE_INSTALL_PREFIX="/home/seager1989/Downloads/openfast/install3" -DBUILD_TESTING=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
#######openfast_postlib.dir/src/FAST_Subs.f90.o#####to solw to build this object

##install4##Running with the same error##
##adding the building test and shared libs and build type and path:
cmake .. -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX="/home/seager1989/Downloads/openfast/install4" -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBLAS_LIBRARIES="/usr/lib/x86_64-linux-gnu/blas" -DLAPACK_LIBRARIES="/usr/lib/x86_64-linux-gnu/lapack"

  1. I am curious why adding the blas and lapack lead to this error? Besides the one specified in the directory, there is no any other blas and lapack libraries in my system.

  2. Now, the OpenFAST was build correctly. The only problem is too slow to build the whole package. It may need about half an hour to build it. I do not know why. To update the cmake to the latest, I manually installed it to a location and created a link in the '/usr/bin.' Hope this helpful.

Do you have any suggestions for these two? Thank you and be safe!

@andrew-platt
Copy link
Collaborator

  1. CMake does a search for existing compatible libraries. It is likely finding some that are installed somewhere you haven't seen. You can check which set of BLAS and LAPACK libraries CMake in the cmakecache.txt in your build directory.
  2. OpenFAST is a large code base and it is a rather slow process to build it in release mode on a single core. One way you can partially speed this up is to use make -j# openfast where # is the number of cores you have given the virtual machine (-j4 for 4 cores). Compiling Debug will be faster, but will be slower in runtime.

@Seager1989
Copy link
Author

  1. CMake does a search for existing compatible libraries. It is likely finding some that are installed somewhere you haven't seen. You can check which set of BLAS and LAPACK libraries CMake in the cmakecache.txt in your build directory.
  2. OpenFAST is a large code base and it is a rather slow process to build it in release mode on a single core. One way you can partially speed this up is to use make -j# openfast where # is the number of cores you have given the virtual machine (-j4 for 4 cores). Compiling Debug will be faster, but will be slower in runtime.

Thank you, Andy,
I checked the cache file. It used a file in the last level directory as follows, but the lib file is the libblas.so and liblapack.so and not the file of '*.a'.
The file used in the 'cmakecache.txt':
LAPACK_lapack_LIBRARIES:FILEPATH=/usr/lib/x86_64-linux-gnu/libblas.so

The directory used before:
DLAPACK_LIBRARIES="/usr/lib/x86_64-linux-gnu/lapack/liblapack.a"

Also, Thank you Rafael for all of your help.
@rafmudaf

@andrew-platt
Copy link
Collaborator

Excellent. It looks like we can close this then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants