Raymond Raymond

Hadoop build error - Cound not find a SASL library (GSASL (gsasl) or Cyrus SASL (libsasl2)

event 2022-12-11 visibility 423 comment 0 insights toc
more_vert
insights Stats

Issue context

When building Hadoop HDFS native library using CMake on Windows 10, you may encounter the following error:

     [exec] -- Looking for pthread.h - not found
     [exec] -- Found Threads: TRUE
     [exec] -- Performing Test THREAD_LOCAL_SUPPORTED
     [exec] -- Performing Test THREAD_LOCAL_SUPPORTED - Success
     [exec] -- Performing Test PROTOC_IS_COMPATIBLE
     [exec] CMake Error at main/native/libhdfspp/CMakeLists.txt:137 (message):
     [exec]   Cound not find a SASL library (GSASL (gsasl) or Cyrus SASL (libsasl2).
     [exec]   Install/configure one of them or define NO_SASL=1 in your cmake call

Root cause

The issue occurred because there is no SASL or GSASL or Cyrus SASL library exists in the system. SASL is optional when building Hadoop. However environment variable NO_SASL is not set either. 

Solution - build without SASL

One solution is to build without SASL as the error messages suggests. This can be done by adding NO_SASL=1 into CMake arguments.

This can be achieved by changing your Maven command line:

mvn clean package -Dhttps.protocols=TLSv1.2 -DskipTests -DskipDocs -Pnative-win,dist -Drequire.openssl -Drequire.test.libhadoop -Pyarn-ui -Dshell-executable=C:\Git\bin\bash.exe -Dtar -Dopenssl.prefix=C:\vcpkg\installed\x64-windows-static -Dcmake.prefix.path=C:\vcpkg\installed\x64-windows-static -Dwindows.cmake.toolchain.file=C:\vcpkg\scripts\buildsystems\vcpkg.cmake -Dwindows.cmake.build.type=RelWithDebInfo -Dwindows.build.hdfspp.dll=off -Dwindows.no.sasl=1 -Duse.platformToolsetVersion=v142

Refer to source code to understand the details: NO_SASL depends on argument windows.no.sasl.

<arg line="-DNO_SASL=${windows.no.sasl}"/>

Note, this can only work if your HDFS native project file hadoop-hdfs-project/hadoop-hdfs-native-client/pom.xml has the following changes merged in:

[HDFS-16666] Pass CMake args for Windows in pom.xml - ASF JIRA (apache.org) OR HDFS-16666. Pass CMake args for Windows in pom.xml by GauthamBanasandra · Pull Request #4574 · apache/hadoop (github.com)

If not, you can manually make the changes to the file by replacing the cmake command with the following content:

                      <arg line="${basedir}/src/"/>
                      <arg line="-DGENERATED_JAVAH=${project.build.directory}/native/javah"/>
                      <arg line="-DJVM_ARCH_DATA_MODEL=${sun.arch.data.model}"/>
                      <arg line="-DREQUIRE_VALGRIND=${require.valgrind}"/>
                      <arg line="-DHADOOP_BUILD=1"/>
                      <arg line="-DREQUIRE_LIBWEBHDFS=${require.libwebhdfs}"/>
                      <arg line="-DREQUIRE_OPENSSL=${require.openssl}"/>
                      <arg line="-DCUSTOM_OPENSSL_PREFIX=${openssl.prefix}"/>
                      <arg line="-DCUSTOM_OPENSSL_LIB=${openssl.lib}"/>
                      <arg line="-DCUSTOM_OPENSSL_INCLUDE=${openssl.include}"/>
                      <arg line="-DCMAKE_PREFIX_PATH=${windows.cmake.prefix.path}"/>
                      <arg line="-DCMAKE_TOOLCHAIN_FILE=${windows.cmake.toolchain.file}"/>
                      <arg line="-DCMAKE_BUILD_TYPE=${windows.cmake.build.type}"/>
                      <arg line="-DBUILD_SHARED_HDFSPP=${windows.build.hdfspp.dll}"/>
                      <arg line="-DNO_SASL=${windows.no.sasl}"/>
                      <arg line="-DREQUIRE_FUSE=${require.fuse}"/>
                      <arg line="-A '${env.PLATFORM}'"/>
                      <arg line="${native_cmake_args}"/>

2022121152412-image.png

Verify the fix

By using Maven debug mode (option -X), you should be able to see the following logs when building HDFS native client:

Execute:Java13CommandLauncher: Executing 'cmake' with arguments:
'C:\v3.3.4\hadoop-hdfs-project\hadoop-hdfs-native-client/src/'
'-DGENERATED_JAVAH=C:\v3.3.4\hadoop-hdfs-project\hadoop-hdfs-native-client\target/native/javah'
'-DJVM_ARCH_DATA_MODEL=64'
'-DREQUIRE_VALGRIND=false'
'-DHADOOP_BUILD=1'
'-DREQUIRE_LIBWEBHDFS=false'
'-DREQUIRE_OPENSSL=true'
'-DCUSTOM_OPENSSL_PREFIX=C:\vcpkg\installed\x64-windows-static'
'-DCUSTOM_OPENSSL_LIB='
'-DCUSTOM_OPENSSL_INCLUDE=${openssl.include}'
'-DCMAKE_PREFIX_PATH=${windows.cmake.prefix.path}'
'-DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake'
'-DCMAKE_BUILD_TYPE=RelWithDebInfo'
'-DBUILD_SHARED_HDFSPP=off'
'-DNO_SASL=1'
'-DREQUIRE_FUSE=false'
'-A'
'x64'
More from Kontext
comment Comments
No comments yet.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts