Building luasec as native extensions

Yeah, this is correct. While it looks nicer, it’s not a requirement on our end. Like Björn said – either from the dashboard (Tab called ‘Community page’ next to ‘Settings’), or directly from defold.com/community/assets (the “Add your Asset” button. Check out the manual if you get stuck (or just ask here in the forum, of course).

1 Like

Ok guys, I’ll do it as soon as possible. Thank you. :slight_smile:

2 Likes

I’m trying to make your luasec and crypto module work for linux now that Defold supports native extensions for this platform. But I’m currently stuck with the same issue @sonountaleban were having, duplicate symbols (RSA_free, AES_cbc_encrypt etc). Does anyone know how to fix it?

I have downloaded the OpenSSL repo, but what do I need to do before I build it?
C and C++ is outside my current skillset so all help is greatly appreciated.

EDIT: Nvm, I just did a simple search & replace through the entire project. I was looking for a less “hacky” solution, but this is good enough for now

2 Likes

I agree that it feels a bit hacky but it’s the most straight forward solution since there is currently no way for you to modify what’s being used by the engine.

PS Don’t forget to contribute back to the original repo with the Linux version of libcrypto and libssl that you built!

4 Likes

Also, our work with native extensions is by no means finished yet. We are actively working towards making these things a lot easier to work with, without unnecessary tweaks needed by our users.

4 Likes

I made a script for Mac (and Windows) to replace those symbols, do you want it?

G.

2 Likes

Thanks, but it’s alright. I did my own pythonscript.

I made a pull request for defold-luasec to fix crashing in HTML5. Check it out?

Yay, I had that on my list of things to do this week! I recently extracted my lua-websocket compatible async client from DefNet into a separate project and at the same time upgraded lua-websocket to a version that handles secure websockets, thus the need for LuaSec.

1 Like

@britzl Do you have any example to use the secure websockets? Thanks

There’s nothing special with how secure web sockets are created from the clients perspective. The handshake will happen in the websocket client code. Check the Defold client for Colyseus for use of websockets and luasec: https://github.com/gamestdio/colyseus-defold

1 Like

Actually, I do not know how to pass the ssl_params to the async websocket client, the colyseus client example does not use secure websockets either.

@sonountaleban How do you fix the duplicate symbols issue and get lib openssl built with Defold native extension? I tried to use you libs in my native extension and get ‘Undefined symbols’ errors, so it would be great if you can share you build process. Thanks in advance.

Well, I saw that there wasn’t a way to pass the SSL parameters to the async websocket client. Sorry about that! I’ve upgraded the lib so that it handles the parameters: https://github.com/britzl/defold-websocket/blob/master/websocket/client_async.lua#L171-L174

Note: I wasn’t able to get wss:// working on HTML5 builds. It seems to still want to connect to ws:// but with port 443.

@joshua.winters In our next release, we have renamed our internal libcrypto functions, so that you should be able to use vanilla OpenSSL without getting “Duplicate symbols”.

2 Likes

This is really a great news for me! Thanks @Mathias_Westerdahl for the update.

1 Like

Hi there,

I’m kinda in desperate mode here. I can’t compile my project anymore when adding luasec as a dependency. It takes forever to build and never launches (waited +15minutes to be sure, and it won’t compile), even from an empty project including luasec as dependency.

At first I thought it was an editor issue, since it started to happen after upgrading to v1-2-134. Then I’ve downgraded to v1-2-133, without success. Same problem. :sob:

Unfortunately, I can’t see any useful information in the editor log files.

Video recording (my cursor was indicating “loading”, it doesn’t show in the recording):

I’d appreciate if you could give me any direction since I’m pretty lost at this point.
Thanks a lot!

2 Likes

Hmm, it builds just fine for me. Do you use any other native extensions? Could you please try another one? Can you reach https://build.defold.com/?

1 Like

Hey @britzl, thanks for replying. It seems I was having issues with my internet service provider, my upload rate was close to zero last week. Do Defold upload every build to https://build.defold.com? Cheers!

No, it should cache the engine once it is built. If you change a native extension then you need to rebuild (and this will send to our build server).

2 Likes