Integrate blockchain related libraries

#1

Hello everyone,

i would like to ask the steps to follow in order to be able to integrate the following library into my code. https://github.com/steemlua/steem-api
I am building a game that interacts with the Steem blockchain in many ways and for that i need to integrate the right libraries to be able to interact in the right way.

Thanks in advance.

Regards
Elia

1 Like

#2

Hi! Exciting project! Your first step is to transform the cpp file in that repo into a native extension.

A native extension has a specific file and folder structure that you need to adhere to for it to work with our build servers and the engine itself. You should be able to transfer a lot of the code without making any changes at all, but the setup of Lua bindings etc may need to be adjusted somewhat.

The entry point for native extension documentation with links to examples etc can be found here:

1 Like

#3

Thanks for the answer ! I’ll give it a try and reach back here if i need some more help !

0 Likes

#4

i have been tinkering around but it seem that i am missing something…is there a way someone could just check if i had all the right set ups and maybe try to build the project and give me some advices ? (like granting access to the project, etc…)

Thanks in advance

0 Likes

#5

What kinds of errors are your seeing? Put the project on GitHub or share it here so that we can take a look.

0 Likes

#6

I have just created a repo on my GitHub Account (Private repo since it is not working till now). I need the name oh who will be checking the repo in order to add it to the collaborators of the repo. Thus is need a username, full name or email address.

Thanks

0 Likes

#7

You can invite me: https://github.com/britzl

0 Likes

#8

Just added you !
this is the invitation link !

https://github.com/Electronics-world/Steemlua-native-extension-for-Defold-Engine/invitations

Thanks in advance !

0 Likes

#9

Thank you for the invite. I took a look and can offer the following advice:

You need to start by structuring the code so that Defold can use it as a native extension. I wrote above that:

The code in the repository doesn’t follow the recommended folder structure. Please read the manual and restructure your files and code to follow the required format:

Also take a look at the example extension to get started:

Click “Use this template” to get a copy of the extension as a new repository of your own:

Once you have your own copy of the template project you can start by adding the code from the steem library into the project.

1 Like

#10

I have removed all the tinkering part i did with all the files and sub folders and have put your suggested template in my project and tried to build it. That extension should be fine to build since it is a ready made simple native extension. I did it just for testing purpose and still i get errors…

below aswell the project struture

struc
I am sorry if my issues may seem those of a beginner…but i am very new to Defold but wanted to learn a bit

0 Likes

#11

These events are new in Defold 1.2.166. What version are you using?
If you not using that version yet, or not using those events, simply remove those cases:

        case dmExtension::EVENT_ID_INCONIFYAPP:
            dmLogInfo("OnEventMyExtension - EVENT_ID_INCONIFYAPP\n");
            break;
        case dmExtension::EVENT_ID_DEICONIFYAPP:
            dmLogInfo("OnEventMyExtension - EVENT_ID_DEICONIFYAPP\n");
            break;
0 Likes

#12

version: 1.2.165

I tried searching for those events to see what is the use cases of them but could not find any result in my search.

I just removed the cases for now and the project builds well now !
I will take it from there and start adapting my code to fit in the sample extension !
You guys are incredible…fast answering very precise in what you provide. In other forums i might have to wait from a minimum of 4 to 5 hours up to 24h to get a partial answer.

Thanks !

3 Likes

#13

Yeah, it seems the enums doesn’t end up in the documentation (I’ll ping @britzl since he knows a bit more about the doc system)

1 Like

#14

I think i might need some intensive Defold and Lua classes ! LOL

i have been adding the dependencies and libraries and code, etc… now again error on build.

my extension needs, in order to build:

libcurl 7.54
lua5.3

I have them and have put the needed files for those libraries in the project.

image

image

now i am getting below errors:

What could be wrong in a library file taken as it is ? Are there things i might need to modify in the library file ? (to adapt them to Defold Engine)

this is where LUAMOD_API is defined in luaconf.h

image

(EDIT)= i found a topic regarding above issue but have no clue on what to do in this case…

thanks

0 Likes

#15

What? No. This will not work. Defold uses LuJIT 2.1-beta3. Trying to add another Lua version will not work.

I think getting this to work is going to be very hard for you. I’m sure it is possible, but you will need to make a bunch of changes to the library and that will require quite a bit of knowledge of C/C++.

1 Like

#16

Ok then i might abort this operation for now and look for other ways to integrate this extension.

is it possible to integrate some python or javascript or node.js libraries ?

0 Likes

#17

You can use JavaScript in HTML5 builds.

Which platform are you targeting for your project?

0 Likes

#18

My targets will be at the beginning: HTML5, Android and iOS

However i would like aswell to target Windows and MacOS.

I may start with HTML5 and Android as a first step then think about the rest later when i get a working environment with the initial 2.

What do you suggest ?

Thanks

0 Likes

#19

Since you target multiple platforms then your best bet is to use a C/C++ library, ie what you started with.

0 Likes

#20

There is a chance you could make it work if you package it as a shared library (DLL/dylib) and fiddle with symbol visibility so that Steem’s Lua isn’t visible to Defold’s object files.

But
a) getting that right alone on each platform might be complicated
b) Defold native extensions don’t officially support shared libraries, so you’d have to go through the hoops and do it with dlopen(). There are a few NEs in the ecosystem that do that, like FMOD or Steamworks, if you need examples, but it’s not a trivial task.

0 Likes