aws / amazon-chime-sdk-cpp

Apache License 2.0
13 stars 5 forks source link

Chime Signaling SDK for C++ compiling issues #10

Closed SantosLV closed 1 year ago

SantosLV commented 1 year ago

Hi guys,

I am getting the following compilation errors:


Chime/amazon-chime-sdk-cpp/chime-sdk-signaling-cpp/build/_deps/libwebsockets-src/lib/tls/openssl/openssl-server.c:300:4: error:
implicit conversion changes signedness: 'size_t' (aka 'unsigned long') to 'long' [-Werror,-Wsign-conversion]                                                    
                       (size_t)
                       ^~~~~~~~
Chime/amazon-chime-sdk-cpp/chime-sdk-signaling-cpp/build/_deps/libwebsockets-src/lib/tls/openssl/openssl-server.c:309:4: error:
implicit conversion changes signedness: 'size_t' (aka 'unsigned long') to 'long' [-Werror,-Wsign-conversion]                                                    
                       (size_t)
                       ^~~~~~~~
Chime/amazon-chime-sdk-cpp/chime-sdk-signaling-cpp/build/_deps/libwebsockets-src/lib/tls/openssl/openssl-server.c:272:5: error:
implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]                                               
                               (size_t)

I am on Linux x86_64 machine running Ubuntu 20.04.5 LTS. Both libssl and libcrypto are from Ubuntu repos.

However, I am able to build the sdk without any issue if I disable the following option:

#define LWS_WITH_BORINGSSL -> in file lws_config.h line 145

I even tried to use BoringSSL, but I get the same results.

Is this behaviour expected, or is something that I am missing? Some missing configuration? Is there any issue if I use the sdk with #define LWS_WITH_BORINGSSL disabled?

Thanks

hokyungh commented 1 year ago

Hi @SantosLV, thank you for reporting the issue. It might be due to setting boringssl to true as seen in here.

You might want to pass -DLWS_WITH_BORINGSSL=OFF to turn it off or change the CMakeLists file to turn it off explicitly.

It is little weird that it didn't work with boring ssl though, would you be able to share the command you have used to build? Does it resemble something like

cmake -S . -B build -DLWS_OPENSSL_LIBRARIES="<boringssl_-ocation>/libssl.a;<boringssl-location>/libcrypto.a" -DLWS_OPENSSL_INCLUDE_DIRS=<ssl-header-location> -DCMAKE_TOOLCHAIN_FILE="./cmake/toolchains/LinuxClang.cmake"

?

We'll update the documentation as well to explicitly state this.

SantosLV commented 1 year ago

Yeap,

the command I used was

cmake -S . -B build -DLWS_OPENSSL_LIBRARIES="boringssl/build/ssl/libssl.a;boringssl/build/crypto/libcrypto.a" -DLWS_OPENSSL_INCLUDE_DIRS=boringssl/include/openssl -DCMAKE_TOOLCHAIN_FILE="./cmake/toolchains/LinuxClang.cmake"

and I get the same errors.

Also-DLWS_WITH_BORINGSSL=OFF does not solve the issue.

What solves the issue for me was when I disable the option in CMakeLists.txt.

Thanks for your support @hokyungh .

hokyungh commented 1 year ago

Hi glad changing the CMakeLists solved the issue. For DLWS_OPENSSL_INCLUDE_DIRS could you pass boringssl/include/? without openssl

SantosLV commented 1 year ago

Yeap, boringssl/include/, solves the issue.

But then I got a linking error:

Linking C shared library libwebsockets.so
/usr/bin/ld: boringssl/build/crypto/libcrypto.a(bcm.c.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
clang: error: linker command failed with exit code 1 (use -v to see invocation)
hokyungh commented 1 year ago

Would you be able to provide OS/version you are running and how you installed boringssl? As seen in the demo, we directly uses boringssl from webRTC built artifacts.

SantosLV commented 1 year ago

I am using Ubuntu 20.04.5 LTS. As for boringssl, I clone it from here https://github.com/google/boringssl

hokyungh commented 1 year ago

That's very interesting. Could you add -fPIC flag when building boringssl or use the one from WebRTC as described in the demo?

SantosLV commented 1 year ago

Adding -fPIC flag solves the issue!! :)

Thanks for your support!!

hokyungh commented 1 year ago

cool glad it worked! Will close the issue. Feel free to open issues if you experience any problem.