Closed zaleksa closed 2 years ago
I'd create a custom build configuration file for your platform, then add the search paths for the OpenSSL headers and libraries to the compiler/linker options.
For example, copy the ARM-Linux
configuration file in platform/build/config
, then add -I/path/to/openssl/include
to CXXFLAGS
and -L/path/to/openssl/lib
to LINKFLAGS
. Then cross-compile using the new build configuration.
make -s -j4 DEFAULT_TARGET=shared_release POCO_CONFIG=ARM-Linux-ExtOpenSSL
It would be good to use environment variables for the OpenSSL directories instead of hardcoding them, e.g. -I$(OPENSSL_DIR)/include
You'd then specify OPENSSL_DIR
externally, either as environment variable or when running make
.
make -s -j4 DEFAULT_TARGET=shared_release POCO_CONFIG=ARM-Linux-ExtOpenSSL OPENSSL_DIR=/path/to/openssl
Thank you for the answer.
I've followed your steps, made config file from existing one and changed following lines:
Compiler and Linker Flags CFLAGS = -std=c99 CFLAGS32 = CFLAGS64 = CXXFLAGS = -Wall -Wno-sign-compare -I$(OPENSSL_DIR)/include CXXFLAGS32 = CXXFLAGS64 = LINKFLAGS = -L$(OPENSSL_DIR) LINKFLAGS32 = LINKFLAGS64 =
Then I invoked make command:
$ make -s -j4 LINKMODE=SHARED DEFAULT_TARGET=shared_release POCO_CONFIG=dg100 OPENSSL_DIR=~/armadeus/buildroot/output/build/libopenssl-1.1.1l
Now compiler can find OpenSSL header files, but linker can not link shared libraries libcrypto.so and libssl.so:
ld: cannot find -lssl ld: cannot find -lcrypto collect2: error: ld returned 1 exit status
These libraries are in directory which I assigned to OPENSSL_DIR, while header files are in OPENSSL_DIR/include.
What am I doing wrong?
Thanks in advance, Aleksandar
Are you sure that the libraries are in $(OPENSSL_DIR)
and not in $(OPENSSL_DIR)/lib
?
I think that libraries are in $(OPENSSL_DIR)
There is no lib subdirectory.
Anyway, I tried to compile with $(OPENSSL_DIR)/lib flag in config file, but it failed again.
Looks like LINKFLAGS
is the wrong setting here, as it only applies to linking executables, not shared libraries.
Try adding:
SHLIBFLAGS = -L$(OPENSSL_DIR)
or, add/modify at the end of the file:
SYSLIBS = -L$(OPENSSL_DIR) -lpthread -ldl -lrt
I added SHLIBFLAGS = -L$(OPENSSL_DIR) at the end of Compiler and Linker Flags. Now it can compile libPocoCrypto.so (~/macchina.io/platform/lib/Linux/armv7a/).
But new error occured:
Those missing headers are in OPENSSL_DIR/include/openssl/ directory.
Please look at config file, maybe I'm missing something: dg100.txt
Steps I took to cross-compile macchina.io are:
$ sudo apt install build-essential libssl-dev python
$ make -s -j4 hosttools
$ export CROSS_COMPILE=arm-none-linux-gnueabihf
$ export PATH=~/armadeus/buildroot/output/host/opt/ext-toolchain/bin/:$PATH
$ make -s -j4 LINKMODE=SHARED DEFAULT_TARGET=shared_release POCO_CONFIG=dg100 OPENSSL_DIR=~/armadeus/buildroot/output/build/libopenssl-1.1.1l
$ arm-none-linux-gnueabihf-gcc --version arm-none-linux-gnueabihf-gcc (GNU Toolchain for the A-profile Architecture 10.2-2020.11 (arm-10.16)) 10.2.1 20201103 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ gcc --version gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
NOTE: I do succeed to cross-compile macchina.io but only if I manually copy OpenSSL headers and libs to macchina.io (headers to ~/macchina.io/platform/Crypto/include, libs to ~/macchina.io/platform/lib/Linux/armv7a), which is dirty way, especially for git version control.
Please look at this log file, I'm getting lot of warning messages while compiling V8 engine: compile.log
Thank you in advance Aleksandar
You may also want to add -I$(OPENSSL_DIR)/include
to CFLAGS
.
Unfortunately you'll have to live with the warnings when compiling V8. Or specifically disable them in your build configuration file by adding -Wnodeprecated-copy
to CXXFLAGS
.
Finally I succeeded to cross compile macchina.io with external OpenSSL libraries.
At first I followed your advice to add -I$(OPENSSL_DIR)/include to CFLAGS and CXXFLAGS, -L$(OPENSSL_DIR) to SHLIBFLAGS or SYSLIBS. This way it compiled without errors.
But, then I saw in 'Darwin-clang-libc++' config file that -I$(OPENSSL_DIR)/include is added to SYSFLAGS, and -L$(OPENSSL_DIR)/lib to SYSLIBS. So I tried this way (omitted /lib) and it compiled.
So finally config file looks like this: DG100.txt
Considering V8 compiling, I can live with the warnings. My concern was if I'm doing something wrong, like using wrong gcc version or similiar. Alongside -Wdeprecated-copy warning, there are few more, like:
-Wclass-memaccess -Wcast-function-type -Wimplicit-fallthrough= -Wdeprecated-declarations -Wstringop-overflow= -Wcpp
So I left all warnings to print out while compiling.
Please advise me if you see some issues considering DG100 config file or V8 compile warnings.
Thank you very much, Aleksandar
What are the steps to cross-compile macchina.io with built external OpenSSL libraries?
Should I copy OpenSSL header and lib files to macchina.io/platform/openssl directory, or I need to specify INCLUDE and LIB environment variables, or define POCO_EXTERNAL_OPENSSL macro?
Can you provide some example, shell command or similar?
I am going to use ~/armadeus/buildroot/output/build/libopenssl-1.1.1g library.
When I cross-compile macchina.io, following log appears:
In file included from include/Poco/Crypto/Cipher.h:21, from src/Cipher.cpp:15: include/Poco/Crypto/Crypto.h:28:10: fatal error: openssl/opensslv.h: No such file or directory 28 | #include <openssl/opensslv.h> | ^
~~~~~~~ compilation terminated.macchina.io Version macchina-2021.1-release
Compiler and Version gcc --version gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Operating System and Version System information: Linux (4.19.150) on armv7l