I am having trouble integrating the OpenSSL libraries into my ardupilot source code to be used in the Rover folder under the GCS_Mavlink.cpp file.
So far I have done:
In the root wscript file, under def configure() added:
cfg.env.INCLUDES_OPENSSL = [‘C:/Users/smt5965/Documents/OpenSSL/include’]
cfg.env.LIB_OPENSSL = [‘crypto’, ‘ssl’]
cfg.env.LIBPATH_OPENSSL = [‘C:/Users/smt5965/Documents/OpenSSL’]
Then, specifically in the wscript file in the Rover folder, added:
‘OPENSSL’ in
bld.ap_program(
program_name=‘ardurover’,
program_groups=[‘bin’, ‘rover’],
use=vehicle + ‘_libs OPENSSL’,
)
I added this as I saw in stack over flow under configure() but I am not sure if this is the correct way to implement:
cfg.check_cfg(
package= ‘openssl’,
args=[‘–cflags’, ‘–libs’],
uselib_store=‘OPENSSL’,
mandatory=TRUE
)
Now I have tried to ./waf rover and build the firmware, however, I always get a file not found error at the beginning of my GCS_Mavlink.cpp in Rover folder, at the line #include <openssl/pem.h>.
This means that the waf system is properly pointing to the correct headers even though it is explicitly stated under the INCLUDES. One other reason is that I have not set a proper build dependency in the build part of the wscript inside the Rover folder itself. I think its a simple fix but I just need to figure out how I can link this external OpenSSL library to my ardupilot source code.
I am now getting this error:
In file included from …/…/…/OpenSSL/include/openssl/pem.h:20,
from …/…/Rover/GCS_Mavlink.cpp:6:
…/…/…/OpenSSL/include/openssl/bio.h:707:17: error: ‘FILE’ was not declared in this scope
707 | BIO *BIO_new_fp(FILE *stream, int close_flag);
| ^~~~
compilation terminated due to -Wfatal-errors.
This means that my OpenSSL library is being correctly found, but I am missing FILE not declared.
I added #include <stdio.h> into my GCS_Mavlink.cpp file, however, I am still getting the same error in Cygwin. Do you know why this is?
All of this seems to be the same on my source code in terms of the posix_compat.h file. I also added #include <stdio.h> into the GCS_Mavlink.cpp file where I am implementing the OpenSSL library, but still get the same FILE error. I am wondering if this is because Stdio.h might be looking on the Windows side meanwhile I am trying to build on Cygwin and cygwin is looking at a potential stdio.h file inside Cygwin?
Seems like OpenSSL will not work since it is such a big system to compile into Pixhawk1. Tried a different library, Tinycrypt, and that worked without errors.