[Freeswitch-users] Compiling c/c++

David Villasmil david.villasmil.work at gmail.com
Sun Jun 14 10:51:08 UTC 2020


Nevermind, i was missing some directives ;)
Regards,

David Villasmil
email: david.villasmil.work at gmail.com
phone: +34669448337


On Sun, Jun 14, 2020 at 1:45 AM David Villasmil <
david.villasmil.work at gmail.com> wrote:

> Hello all,
>
> If anyone can help with my confusion here:
>
> Let's say i'm working on an already existing module.
>
> I've created modules in the past, this is not really my problem. My
> problem comes from an already existing module, let's call it my_module. In
> this module I'm adding a new functionality where i need to decrypt a jwt
> token parameter encrypted in AES.
>
> The existing module main file, the file loaded by the main freeSWITCH
> loader is in C., let's say something like this:
>
> #include <switch.h>
> #include <switch_json.h>
> #include <switch_stun.h>
> #include <jwt.h>
>
> #include "token_crypto.h" <-- This is my addition
>
> ...
> <some stuff goes here>
> at some point i do this:
>
>  plaintext_len = token_decrypt( *token_encoded, plaintext );
>
> my token_crypto.h is
>
> SWITCH_BEGIN_EXTERN_C
>
> #include <stdio.h>
> #include <string.h>
> #include <openssl/ssl.h>
> #include <openssl/evp.h>
> #include <openssl/err.h>
> #include <openssl/bio.h>
> #include <openssl/buffer.h>
> #include <openssl/sha.h>
>
>
> void handleErrors(unsigned char *ciphertext);
> int gcm_decrypt(unsigned char *ciphertext, int ciphertext_len,
>             unsigned char *aad, int aad_len,
>             unsigned char *tag,
>             unsigned char *key,
>             unsigned char *iv, int iv_len,
>             unsigned char *plaintext);
> int token_decrypt( const char token_encoded, unsigned char *plaintext );
>
>
> SWITCH_END_EXTERN_C
>
> And then the actual implementation in token_crypto.cpp
>
> I added the requirement to compile token_crypto in the Makefile.am like
> this:
>
> mod_mymodule_la_SOURCES  = \
>     base64url.cpp \
>     token_crypto.cpp \
>     mod_mymodule.c
>
> The code then compiles ok, but when i try to load it i'm getting:
>
> **/usr/local/freeswitch/mod/mod_mymodule.so: undefined symbol:
> token_decrypt**
>
> I know the linker can't find the compiled references, but i just can't
> figure out how to link it all up...
>
> call me stupid, but help me out 🤔
> Regards,
>
> David Villasmil
> email: david.villasmil.work at gmail.com
> phone: +34669448337
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20200614/18863114/attachment.html>


More information about the FreeSWITCH-users mailing list