how to use then extension library?

I wrote a mylib.dll dynamic link library, where I should put the file ?then I can use my extension library, put the file in the root of the project and: local mylib = require (“mylib”) 。but hints that I can’t find the file

Did you start out with the extension template in the native folder? 

I don’t, do you have an example?

Inside your the corona Application folder => Native => Project Template => App => Win32. If you don’t find it let me know and I’ll look for it on my Windows machine (I usually work on a Mac). 

Do you do that? But he still pops up a mistake like this:

44444.png

What should I do to solve this problem? Are there any examples of use that can be referred to?

Ummm… I’ll try to fire up my windows machine today and see what I get.

Thank you. This is the link between extension library and C: http://pic.caigoubao.cc/601048/Desktop.zip

I used VB 2010 compiled lua5.1 static library, and then compile my extension library mylib2, SZ extension library is someone else, there are JSON functions can be used:

Local SZ = require (“SZ”)

STR = “JSON”

Local a = {}

A = sz.json.decode (STR)

The function in my extension library mylib2 is written in C, waiting for your reply.

Sorry, my Windows machine is dead. I don’t have a machine at the moment to help you with. Maybe somebody else will come along with the answer.

On my machine I open up a folder, type %appdata% in the bar, then follow  -> Corona Labs -> Corona Simulator -> Plugins -> plugin  and dump them there.

Actually, in Visual Studio, I add a post-build event along these lines to my project (in this case from luaproc):

set PLUGINS=$(appdata)/Corona Labs/Corona Simulator/Plugins/plugin/ copy "$(OutDir)$(TargetName).dll" "%PLUGINS%luaproc.dll"

You can also find these paths using system.pathForFile() and, off the top of my head, system.PluginsPath.

EDIT : The above is for use in the simulator. For a build you would have to manually bring the file in, so far as I know.

Hello, my corona simulator doesn’t have the folder you said, my file directory is 1 in the diagram, I put them in the position shown in Figure three, and can require to the file, but the prompt file is loaded wrong, mylib2 is my own compiled file, I do not know whether the DLL file has a problem, SZ is I from Another Lua simulator found a file that could be normal require in that simulator, but require in the corona simulator produced the same error hints as I require (“mylib2”). I didn’t know where there was a problem, attached my file, and I hope someone could tell me the right way to use it.

123.jpg

3333.png

the file  :http://pic.caigoubao.cc/601048/Desktop.zip

Hi.

The folder isn’t in Program Files. That %appdata% is a special name that resolves to a folder. So the full path will be something like  C:\Users\ME\AppData\Roaming\Corona Labs\Corona Simulator\Plugin\plugins. I suppose the plugins folder isn’t strictly necessary, depending on what package.cpath and package.loaders contain.

“I used VB 2010 compiled lua5.1 static library”. You should really use the one that comes with Corona. This will be at  %CORONA_ROOT%/Corona/win/lib/lua.lib. Also headers at  %CORONA_ROOT%\Corona\shared\include\lua.

In your code, you probably want __declspec(dllexport) before your luaopen_mylib2 function. Then again, if you only need a sleep function, you can probably just get it from socket, as mentioned here. Probably won’t play well with Corona, though.  :slight_smile:

Do you have the code for sz? That might give you problems if it uses an older runtime (it’s not obvious).

I used the corona lib and the header file, but the compiled mylib2 is still wrong, the following is the lib and header file I used for corona, from the%CORONA_ROOT%/Corona/win/lib/lua.lib. and%CORONA_ROOT%\Corona\shared\include\lua. that you gave me, and what’s wrong, what’s the problem? 1234.png

It’s probably the __declspec part I mentioned. See here for an example, using CORONA_EXPORT , which becomes that on Windows.

Here is an example.

You might also try:

local mylib local ok, lib\_or\_err = pcall(require, "mylib2") if ok then mylib = lib\_or\_err else print("ERROR!", lib\_or\_err end

Emmm… I am not familiar with the C language, I revise the code, use the CORONA_EXPORT, can compile and pass, but still load the error, the error is the same as before, this is my code, look second, if you can, if you can write an example of C code that can be properly loaded to me?

the code:http://pic.caigoubao.cc/601048/code.zip

Hi.

I’ve attached a project that builds as a plugin and puts it in the folder I mentioned above. You will have to manually add this to builds unless it eventually becomes an official plugin.

The project is in the win32 folder and the code in shared (this is stripped down from one of my own plugins).

Tested with:

local mylib2 = require 'plugin.mylib2' mylib2.sleep(3000) mylib2.func()

Emmm… I didn’t find out where your project was…

Whoops, sorry. I always forget the second step in the “Attach Files” process.  :frowning:

Compared to the difference between me and your project, I found the problem, before I compiled the compilation of the debug compiled, the error, to select the release compilation, now I can use it successfully. Emmm. There is another question to ask, that is what I can do to use the plug-in in the post - built exe after I build it into exe with windows, and I want to see examples if I can.

Emmm. I got it! It can be used directly under the EXE folder.

Did you start out with the extension template in the native folder?