LIBSSH2 and dso_dlfcn.c: ... undefined reference to `dlopen' - linker

I am trying to compile git2go using static libgit2, openssl, and libssh2. My end goal is to be able to compile a go binary that can be deployed without the need to install these libraries. I found a similar question on SO that I have used to create the following scripts that build the libraries
OPENSSL:
#!/bin/sh
set -ex
INSTALL_PATH="$PWD/install"
SUBMODULE_PATH="$PWD/submodules/openssl"
cd $SUBMODULE_PATH &&
mkdir -p $INSTALL_PATH/lib &&
mkdir -p build &&
# Switch to a stable version
git checkout OpenSSL_1_0_2-stable &&
./config threads no-shared --prefix=$INSTALL_PATH -fPIC -DOPENSSL_PIC &&
make depend &&
make &&
make install
LIBSSH2:
#!/bin/sh
set -ex
INSTALL_PATH="$PWD/install"
SUBMODULE_PATH="$PWD/submodules/libssh2"
# without this, the system's openssl shared object gets linked in
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$INSTALL_PATH/lib/pkgconfig:$INSTALL_PATH/lib64/pkgconfig"
cd $SUBMODULE_PATH &&
mkdir -p $INSTALL_PATH/lib &&
mkdir build
cd build &&
cmake -DTHREADSAFE=ON \
-DBUILD_CLAR=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_C_FLAGS=-fPIC \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DCMAKE_INSTALL_PREFIX=$INSTALL_PATH \
.. &&
cmake --build .
make install
I am applying the following patch to a script in git2go branch next that builds libgit2 in an attempt to ensure that PKG_CONFIG_PATH points to the static openssl and libssh2 libraries
LIBGIT2:
--- build-libgit2-static.sh.orig 2016-04-14 22:49:53.000000000 -0700
+++ build-libgit2-static.sh 2016-04-14 22:52:04.000000000 -0700
## -2,10 +2,12 ##
set -ex
-VENDORED_PATH=vendor/libgit2
+INSTALL_PATH="$PWD/install"
+VENDORED_PATH="$PWD/submodules/git2go/vendor/libgit2"
+export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$INSTALL_PATH/lib/pkgconfig:$INSTALL_PATH/lib64/pkgconfig"
cd $VENDORED_PATH &&
-mkdir -p install/lib &&
+mkdir -p $INSTALL_PATH/lib &&
mkdir -p build &&
cd build &&
cmake -DTHREADSAFE=ON \
## -13,7 +15,8 ##
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_C_FLAGS=-fPIC \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
- -DCMAKE_INSTALL_PREFIX=../install \
+ -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH \
.. &&
cmake --build .
+make install
This setup ultimately creates a local install directory that has all the libraries installed to it. I compile openssl using the above script. Then get the following output when compiling libssh2:
...
Found OpenSSL: (path to project)/install/lib/libssl.a;(path to project)/install/lib/libcrypto.a (found version "1.0.2h-dev")
...
Linking C static library libssh2.a
gmake[3]: Leaving directory `(path to project)/submodules/libssh2/build'
[ 46%] Built target libssh2
gmake[3]: Entering directory `(path to project)/submodules/libssh2/build'
Scanning dependencies of target example-direct_tcpip
gmake[3]: Leaving directory `(path to project)/submodules/libssh2/build'
gmake[3]: Entering directory `(path to project)/submodules/libssh2/build'
[ 48%] Building C object example/CMakeFiles/example-direct_tcpip.dir/direct_tcpip.c.o
Linking C executable example-direct_tcpip
(path to project)/install/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x11): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x24): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x2f): undefined reference to `dlclose'
(path to project)/install/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
dso_dlfcn.c:(.text+0x354): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x412): undefined reference to `dlerror'
(path to project)/install/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
dso_dlfcn.c:(.text+0x484): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x542): undefined reference to `dlerror'
(path to project)/install/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
dso_dlfcn.c:(.text+0x5a9): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x60d): undefined reference to `dlclose'
dso_dlfcn.c:(.text+0x645): undefined reference to `dlerror'
(path to project)/install/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
dso_dlfcn.c:(.text+0x6d1): undefined reference to `dladdr'
dso_dlfcn.c:(.text+0x731): undefined reference to `dlerror'
(path to project)/install/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
dso_dlfcn.c:(.text+0x792): undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
gmake[3]: Leaving directory `(path to project)/submodules/libssh2/build'
gmake[2]: Leaving directory `(path to project)/submodules/libssh2/build'
gmake[1]: Leaving directory `(path to project)(path to project)/submodules/libssh2/build'
gmake[3]: *** [example/example-direct_tcpip] Error 1
gmake[2]: *** [example/CMakeFiles/example-direct_tcpip.dir/all] Error 2
gmake[1]: *** [all] Error 2
make: *** [build-libssh2] Error 2
You can see that the static openssl is being used. Obviously libdl is not getting linked in to libcrypto. The output when compiling openssl has EX_LIBS=-ldl. Should this include the library? I have tried using LDLIBS=-ldl in the openssl install script but still the same error. I have tried nearly every SO answer for the search term libcrypto undefined reference to 'dlopen' to no avail. Any help would be much appreciated

Since I am not familiar with pig-config I switched to Autoconf:
#!/bin/sh
set -ex
INSTALL_PATH="$PWD/install"
SUBMODULE_PATH="$PWD/submodules/libssh2"
mkdir -p $INSTALL_PATH/lib &&
cd $SUBMODULE_PATH &&
./buildconf
./configure --prefix=$INSTALL_PATH --libdir=$INSTALL_PATH/lib64 --with-openssl CFLAGS="-fPIC" LDFLAGS="-m64 -L$INSTALL_PATH/lib -L$INSTALL_PATH/lib64" LIBS=-ldl
make
make install
This successfully compiles.

I found out that adding target_link_libraries(libssh2 ${CMAKE_DL_LIBS}) to src/CMakeLists.txt (as explained here) solves the problem mentioned in the question. Note that I am using libssh2-1.8.0 and latest OpenSSL (5de683d), but I think it's the same story with OpenSSL_1_0_2-stable.
So the LIBSSH2 build code that works is:
# inside libssh2 root
printf '\ntarget_link_libraries(libssh2 ${CMAKE_DL_LIBS})' >> src/CMakeLists.txt
mkdir build && cd build
cmake -DTHREADSAFE=ON \
-DBUILD_CLAR=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_C_FLAGS=-fPIC \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DCMAKE_INSTALL_PREFIX=$INSTALL_PATH \
.. &&
cmake --build .
make install
Note: I also had to add target_link_libraries(libssh2 pthread) because I was getting undefined references to pthread with the latest versions.

Related

Cross Compillation for Raspberry PI

I am trying to cross-compile odas library for Raspberry PI. The code actually builds out of the box on the platform (either Raspberry PI, or Ubuntu box). However, when I am trying to cross compile the same code using this tool chain file (the whole thing started in the previous question):
# Cross-compilation system information
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR "arm")
# Specify the cross compiler
SET(CMAKE_C_COMPILER /home/raspberrypi/opt/x-tools/aarch64-rpi3-linux-gnu/bin/aarch64-rpi3-linux-gnu-gcc)
SET(CMAKE_CXX_COMPILER /home/raspberrypi/opt/x-tools/aarch64-rpi3-linux-gnu/bin/aarch64-rpi3-linux-gnu-g++)
# where is the target environment located
set(CMAKE_SYSROOT /home/raspberrypi/sysroot)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}")
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}")
# adjust the default behavior of the FIND_XXX() commands:
# search programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# search headers and libraries in the target environment
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
I am getting a bunch of errors, like
[1/2] Linking C executable bin/odasserver
FAILED: bin/odasserver
: && /home/raspberrypi/opt/x-tools/aarch64-rpi3-linux-gnu/bin/aarch64-rpi3-linux-gnu-gcc --sysroot=/home/raspberrypi/sysroot -g --sysroot=/home/raspberrypi/sysroot CMakeFiles/odasserver.dir/demo/odasserver/main.obj -o bin/odasserver lib/libodas.so -lfftw3f -lasound -lconfig -lpulse-simple -lpulse -lm -lpthread && :
/home/raspberrypi/opt/x-tools/aarch64-rpi3-linux-gnu/bin/../lib/gcc/aarch64-rpi3-linux-gnu/12.2.0/../../../../aarch64-rpi3-linux-gnu/bin/ld.bfd: lib/libodas.so: undefined reference to `__pthread_create'
/home/raspberrypi/opt/x-tools/aarch64-rpi3-linux-gnu/bin/../lib/gcc/aarch64-rpi3-linux-gnu/12.2.0/../../../../aarch64-rpi3-linux-gnu/bin/ld.bfd: lib/libodas.so: undefined reference to `_dl_wait_lookup_done'
/home/raspberrypi/opt/x-tools/aarch64-rpi3-linux-gnu/bin/../lib/gcc/aarch64-rpi3-linux-gnu/12.2.0/../../../../aarch64-rpi3-linux-gnu/bin/ld.bfd: lib/libodas.so: undefined reference to `_dl_init_static_tls'
/home/raspberrypi/opt/x-tools/aarch64-rpi3-linux-gnu/bin/../lib/gcc/aarch64-rpi3-linux-gnu/12.2.0/../../../../aarch64-rpi3-linux-gnu/bin/ld.bfd: lib/libodas.so: undefined reference to `__pointer_chk_guard_local'
/home/raspberrypi/opt/x-tools/aarch64-rpi3-linux-gnu/bin/../lib/gcc/aarch64-rpi3-linux-gnu/12.2.0/../../../../aarch64-rpi3-linux-gnu/bin/ld.bfd: lib/libodas.so: undefined reference to `_dl_stack_flags'
/home/raspberrypi/opt/x-tools/aarch64-rpi3-linux-gnu/bin/../lib/gcc/aarch64-rpi3-linux-gnu/12.2.0/../../../../aarch64-rpi3-linux-gnu/bin/ld.bfd: lib/libodas.so: undefined reference to `_dl_pagesize'
collect2: error: ld returned 1 exit status
What could be possibly wrong here?
long story short - when creating sysroot folder on the host machine, I was using commands like
sudo rsync -avz rpi#192.168.1.205:/lib .
sudo rsync -avz rpi#192.168.1.205:/usr/include usr
sudo rsync -avz rpi#192.168.1.205:/usr/lib usr
sudo rsync -avz rpi#192.168.1.205:/usr/local usr
Apparently, on the target, some symbolic links were pointing outside of the current directory, for example
/usr/lib/aarch64-linux-gnu/libz.so -> /lib/aarch64-linux-gnu/libz.so.1.2.11
So needed to replace absolute symlinks with relative ones.
Once this was done, then everything was fine and compiling, and running.

Compiling with Mongo C++ driver returns undefined reference to `u_strFromUTF8_66'

I installed Mongo C++ Driver using following shell script,
#!/bin/bash
echo "Building MongoDB Core Dependency"
cd /home &&
wget https://github.com/mongodb/mongo-c-driver/releases/download/1.17.0/mongo-c-driver-1.17.0.tar.gz &&
tar xzf mongo-c-driver-1.17.0.tar.gz &&
cd mongo-c-driver-1.17.0 &&
mkdir cmake-build &&
cd cmake-build &&
cmake -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DCMAKE_BUILD_TYPE=Release .. &&
echo "Installing MongoDB Core Dependency" &&
sudo make install &&
cd /home &&
echo "Downloading MongoDB Driver" &&
git clone https://github.com/mongodb/mongo-cxx-driver.git --branch releases/stable --depth 1 &&
cd mongo-cxx-driver/build &&
echo "Building and Installing MongoDB Driver" &&
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_AND_STATIC_LIBS=ON -DCMAKE_INSTALL_PREFIX=/usr/local &&
make && sudo make install
I compile my app like this (w/ Static Linking),
g++ main.cpp -std=c++11 -ltins -DMONGOCXX_STATIC /
-DBSONCXX_STATIC -DMONGOC_STATIC /
-DBSON_STATIC - I/usr/local/include/libmongoc-1.0 /
-I/usr/local/include/libbson-1.0 -I/usr/local/include/mongocxx/v_noabi /
-I/usr/local/include/bsoncxx/v_noabi -L/usr/local/lib -lmongocxx-static /
-lbsoncxx-static -lmongoc-static-1.0 -lz -lsasl2 -lssl -lcrypto -lrt /
-lresolv -pthread -lbson-static-1.0 /
-lm /usr/lib/x86_64-linux-gnu/librt.so /usr/lib/x86_64-linux-gnu/libm.so /
-pthread -o app
However, The compile process fails with,
/usr/bin/ld: /usr/local/lib/libmongoc-static-1.0.a(mongoc-scram.c.o): in function `_mongoc_sasl_prep_impl':
mongoc-scram.c:(.text+0x61e): undefined reference to `u_strFromUTF8_66'
/usr/bin/ld: mongoc-scram.c:(.text+0x66a): undefined reference to `u_strFromUTF8_66'
/usr/bin/ld: mongoc-scram.c:(.text+0x685): undefined reference to `usprep_openByType_66'
/usr/bin/ld: mongoc-scram.c:(.text+0x6b0): undefined reference to `usprep_prepare_66'
/usr/bin/ld: mongoc-scram.c:(.text+0x702): undefined reference to `usprep_prepare_66'
/usr/bin/ld: mongoc-scram.c:(.text+0x720): undefined reference to `usprep_close_66'
/usr/bin/ld: mongoc-scram.c:(.text+0x739): undefined reference to `u_strToUTF8_66'
/usr/bin/ld: mongoc-scram.c:(.text+0x77a): undefined reference to `u_strToUTF8_66'
/usr/bin/ld: mongoc-scram.c:(.text+0x814): undefined reference to `usprep_close_66'
/usr/bin/ld: mongoc-scram.c:(.text+0x871): undefined reference to `usprep_close_66'
collect2: error: ld returned 1 exit status
make: *** [Makefile:3: all] Error 1
It was worked before on my other machine and not sure why it doesn't work right now.
I even reinstalled Ubuntu and that didn't work out too.
My Ubuntu version is 20.04 and G++ version is 9.3.0
I'm writing this answer as a note to my future self (and other future selves):
If you don't need SASL (which in my case I don't), the easiest way around this problem (but not fixing it) is to change the mongo-c-client cmake flags to include:
-DENABLE_SASL=OFF
this solves my problem, but not actually this problem ...

undefined references to `strerror_s' while building lua-openssl on alpine image

I am trying to build an openresty alpine image with lua-openssl like so
FROM openresty/openresty:alpine-fat
# Set the version
ENV RESTY_CONFIG_OPTIONS_MORE "--with-ngx_http_ssl_module"
EXPOSE 80
EXPOSE 443
RUN ls /usr/local/openresty/nginx/logs
COPY lualib /usr/local/openresty/nginx/lualib
RUN chown -R nobody:root /usr/local/openresty/nginx/lualib
RUN apk add --update \
openssl openssl-dev \
lua5.3 luajit-dev lua-socket \
git
RUN git clone https://github.com/zhaozg/lua-openssl.git /usr/local/lua-openssl; \
cd /usr/local/lua-openssl; \
git checkout e923252b28cff43add6382853cc85ed888c4474b; \
make
But I get the one below and a lot of such errors:
/usr/local/lua-openssl/deps/lua-compat/c-api/compat-5.3.c:74:
undefined reference to strerror_s' ./libopenssl.a(cms.o): In function
compat53_strerror':
/usr/local/lua-openssl/deps/lua-compat/c-api/compat-5.3.c:74:
undefined reference to strerror_s'
./libopenssl.a(compat.o):/usr/local/lua-openssl/deps/lua-compat/c-api/compat-5.3.c:74:
more undefined references tostrerror_s' follow collect2: error: ld
returned 1 exit status make: *** [Makefile:94: openssl.so] Error 1
Am I missing a package?
(1) We grabbed the trusty image instead of alpine-fat.
(2) Overrode the make file with one that uses lcrypto lib to build.
And that is the only setting I know to make this work.
I did not try compiling with MSVC++.
My issue and it's fix is tracked in https://github.com/zhaozg/lua-openssl/issues/138

How fix Error of error of crt1.o,crti.o in Build TinyCCompiler(TCC) from Source?

How fix Error of crt1.o,crti.o in Build TinyCCompiler(TCC) from Source?
https://github.com/LuaDist/tcc
i'm test this at my Desktop system(ubuntu) and also test on server(centos).
at both OS , show error.
Error :
tcc: file '/usr/lib/crt1.o' not found
tcc: file '/usr/lib/crti.o' not found
Details :
guest#Base:~/Gits/tcc-compiler$ ./configure --prefix=build
Binary directory build/bin
TinyCC directory build/lib/tcc
Library directory build/lib
Include directory build/include
Manual directory build/man
Doc directory build/share/doc/tcc
Target root prefix
Source path /home/guest/Gits/tcc-compiler
C compiler gcc
CPU x86-64
Big Endian no
gprof enabled no
cross compilers no
use libgcc no
Creating config.mak and config.h
config.h is unchanged
guest#Base:~/Gits/tcc-compiler$ sudo make
....
....
guest#Base:~/Gits/tcc-compiler$ sudo make install
mkdir -p "build/bin"
install -s -m755 tcc "build/bin"
mkdir -p "build/man/man1"
install tcc.1 "build/man/man1"
mkdir -p "build/lib/tcc"
mkdir -p "build/lib/tcc/include"
install -m644 libtcc1.a "build/lib/tcc"
install -m644 include/stdarg.h include/stddef.h include/stdbool.h include/float.h include/varargs.h include/tcclib.h "build/lib/tcc/include"
mkdir -p "build/share/doc/tcc"
install -m644 tcc-doc.html "build/share/doc/tcc"
mkdir -p "build/lib"
install -m644 libtcc.a "build/lib"
mkdir -p "build/include"
install -m644 libtcc.h "build/include"
guest#Base:~/Gits/tcc-compiler$ cat test2.c
#include <tcclib.h>
int main()
{
printf("Hello World\n");
return 0;
}
Error :
guest#Base:~/Gits/tcc-compiler$ build/bin/tcc test2.c
tcc: file '/usr/lib/crt1.o' not found
tcc: file '/usr/lib/crti.o' not found
$ find /usr/ -name crti*
/usr/mipsel-linux-gnu/lib/crti.o
/usr/lib32/crti.o
/usr/libx32/crti.o
/usr/lib/i386-linux-gnu/crti.o
/usr/lib/x86_64-linux-gnu/crti.o
$ find /usr/ -name crt1*
/usr/mipsel-linux-gnu/lib/crt1.o
/usr/lib32/crt1.o
/usr/libx32/crt1.o
/usr/x86_64-w64-mingw32/lib/crt1.o
/usr/x86_64-w64-mingw32/lib/crt1u.o
/usr/i686-w64-mingw32/lib/crt1.o
/usr/i686-w64-mingw32/lib/crt1u.o
/usr/lib/i386-linux-gnu/crt1.o
/usr/lib/x86_64-linux-gnu/crt1.o
(Full Commands available at https://pastebin.ubuntu.com/26211506/)
how can fix error?
i'm can install tcc using sudo apt install tcc.(without bug and error)
but i want install tcc from source.(this have error)
New Update
in tcc.h file :
#define CONFIG_TCC_CRT_PREFIX CONFIG_SYSROOT "/usr/lib"
i'm change /usr/lib to /usr/lib/x86_64-linux-gnu.
$ build/bin/tcc test.c -run
Hello World
$ /build/bin/tcc test.c
tcc: undefined symbol '__libc_csu_fini'
tcc: undefined symbol '__libc_csu_init'
tcc: undefined symbol '__libc_start_main'
tcc: undefined symbol 'printf'
New Update
#include <tcclib.h>
int main()
{
printf("Hello World\n");
return 0;
}
guest#Base:~/Gits/tcc-try/_build/_install/bin$ ./tcc test.c
test.c:1: include file 'tcclib.h' not found
How fix error of include files not found?!
Related Question : How fix Error of error of include files in TinyCCompiler(TCC)?
The LuaDist project aims to build a complete Lua ecosystem using CMake. So you should use the CMake build system instead of the original makefiles. Typically you would do the following CMake invocation.
$ mkdir _build && cd _build
$ cmake .. -DCMAKE_INSTALL_PREFIX=_install
$ cmake --build . --target install
After this you should have working tcc in _install/bin
Sorry this is not exactly an answer to a question, but initially I had the same problem and this is my solution (Ubuntu 18.04):
git clone https://github.com/TinyCC/tinycc
cd tinycc
./configure
make
make test
cd ..
echo '#include <stdio.h>
int main() {
printf("Hi!\n");
}' > a.c
tinycc/tcc -Btinycc a.c -o a.o
./a.o

Cross compiling OpenSSL - openssl binary cannot be executed

I'm trying to cross compile OpenSSL for PowerPC with the FIPS module. My build host's architecture is not PowerPC. I was able to cross compile the FIPS module just fine. However, when I run make on openssl, during the linking phase, it tries to execute certain binaries to run tests. The issue is that those binaries are produced for the target architecture and, as a result, I get the error "cannot execute binary file". Is there a way to produce executables of these tests on the host architecture rather than the target architecture? Should I be handling this process differently? Here are the following commands I used to build openssl. I replaced certain directories with DIR_HIDDEN.
export FIPS_DIRECTORY="$PWD/../../openssl-fips/tgt/linux-ppc603e/"
export cross="DIR_HIDDEN/powerpc-linux-gnu-"
make clean || exit 1
make dclean || exit 1
./Configure --prefix=$PWD/../tgt/linux-ppc603e linux-ppc fips --with-fipsdir=${FIPS_DIRECTORY}
make depend || exit 1
make CC="$FIPS_DIRECTORY/bin/fipsld" RANLIB="${cross}ranlib" AR="${cross}ar r" LD="$FIPS_DIRECTORY/bin/fipsld" FIPSLD_CC="${cross}gcc" HOSTCC="/usr/bin/gcc" || exit 1
make install || exit 1
I get the following error during the make command:
shlib_target=; if [ -n "" ]; then \
shlib_target="linux-shared"; \
elif [ -n "libcrypto" ]; then \
FIPSLD_CC="/DIR_HIDDEN/openssl/openssl-1.0.1i/../../openssl-fips/tgt/linux-ppc603e//bin/fipsld"; CC=/DIR_HIDDEN/openssl/openssl-1.0.1i/../../openssl-fips/tgt/linux-ppc603e//bin/fipsld; export CC FIPSLD_CC; \
fi; \
LIBRARIES="-L.. -lssl -L.. -lcrypto" ; \
make -f ../Makefile.shared -e \
APPNAME=openssl OBJECTS="openssl.o verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o ec.o ecparam.o x509.o genrsa.o gendsa.o genpkey.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o pkey.o pkeyparam.o pkeyutl.o spkac.o smime.o cms.o rand.o engine.o ocsp.o prime.o ts.o srp.o" \
LIBDEPS=" $LIBRARIES -ldl" \
link_app.${shlib_target}
make[2]: Entering directory `/DIR_HIDDEN/openssl/openssl-1.0.1i/apps'
( :; LIBDEPS="${LIBDEPS:--L.. -lssl -L.. -lcrypto -ldl}"; LDCMD="${LDCMD:-/DIR_HIDDEN/openssl/openssl-1.0.1i/../../openssl-fips/tgt/linux-ppc603e//bin/fipsld}"; LDFLAGS="${LDFLAGS:--DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DB_ENDIAN -DTERMIO -O3 -Wall -DOPENSSL_BN_ASM_MONT -I/DIR_HIDDEN/openssl/openssl-1.0.1i/../../openssl-fips/tgt/linux-ppc603e//include -DSHA1_ASM -DSHA256_ASM -DAES_ASM}"; LIBPATH=`for x in $LIBDEPS; do echo $x; done | sed -e 's/^ *-L//;t' -e d | uniq`; LIBPATH=`echo $LIBPATH | sed -e 's/ /:/g'`; LD_LIBRARY_PATH=$LIBPATH:$LD_LIBRARY_PATH ${LDCMD} ${LDFLAGS} -o ${APPNAME:=openssl} openssl.o verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o ec.o ecparam.o x509.o genrsa.o gendsa.o genpkey.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o pkey.o pkeyparam.o pkeyutl.o spkac.o smime.o cms.o rand.o engine.o ocsp.o prime.o ts.o srp.o ${LIBDEPS} )
/DIR_HIDDEN/openssl/openssl-1.0.1i/../../openssl-fips/tgt/linux-ppc603e//bin/fipsld: line 185: ./openssl: cannot execute binary file
make[2]: *** [link_app.] Error 126
When invoking the make command again and again, I get the same error but for all the applications located in the /test directory of the openssl tarball. Examples include bntest, ectest, and ecdhtest.
I received a similar error when I was cross compiling the FIPS module, but I was able to resolve that by including the host compiler in the HOSTCC variable. A similar trick did not work for the openssl compilation.
Any guidance would be appreciated. Thanks!
I was able to modify the make command to get the process to complete. I was missing the FIPS_SIG environment variable, which points to the incore script. The make command is now:
make FIPS_SIG=$PWD/`find ../../openssl-fips/ -iname incore` CC="$FIPS_DIRECTORY/bin/fipsld" RANLIB="${cross}ranlib" AR="${cross}ar r" LD="$FIPS_DIRECTORY/bin/fipsld" FIPSLD_CC="${cross}gcc"
I still see prints to console that indicate that openssl cannot be executed, but these are warnings and don't halt the makefile. Not really sure why or how this fixed the problem, but I'll take it.

Resources