I am trying to build codecbox.js on Ubuntu 18.04, which involves building FFmpeg with emcc.
At some stage of the build process, FFmpeg's configure script tries to process the following code:
#include <wels/codec_api.h>
#include <stdint.h>
long check_WelsGetCodecVersion(void) { return (long) WelsGetCodecVersion; }
int main(void) {
int ret = 0;
ret |= ((intptr_t)check_WelsGetCodecVersion) & 0xFFFF;
return ret;
}
and I get a linker error:
wasm-ld: error: /.../codecbox.js/build/dist/lib/libopenh264.so: undefined symbol: __stack_chk_guard
It seems to be related to Stack Smashing Protector compiler feature. I tried to inspect my libopenh264.so file with nm but nm tells me File format not recognized. However, using grep, I found out that there was a __stack_chk_guard symbol in this file.
I tried to rebuild libopenh264 by adding -fno-stack-protector and -U_FORTIFY_SOURCE to the CFLAGS and the LDFLAGS but that did not change anything:
grep __stack_chk_guard libopenh264.so
still answers
Binary file libopenh264.so matches
I then tried to build the piece of code shown above by adding the same options -fno-stack-protector and -U_FORTIFY_SOURCE to emcc, but it did not change anything either.
Any idea how to get rid off the problem?
I had not rebuilt libopenh264 completely.
Adding
-fno-stack-protectorand-U_FORTIFY_SOURCEto theCFLAGS, theCXXFLAGSand theLDFLAGSthen doingmake cleanandmakesolved the problem: libopenh264.so no longer embedded symbol__stack_chk_guard.