Beta 2.50: Compile to library with Code module or Class module

corwin42

Expert
Licensed User
Longtime User
I just did a first simple test of the "Compile to library" feature.

I created a simple project with all available module types and put some dummy methods in them. Whenever I try to compile a class module or a code module into a library and then try to include my library to a project (or call refresh) on the libraries tab I get the error in the attached image.
 

Attachments

  • 2013-01-02_000307.png
    2013-01-02_000307.png
    16 KB · Views: 424

corwin42

Expert
Licensed User
Longtime User
It's just a very simple project with some empty subs.

I noticed that the dexer produces an error if a module name includes an underscore (_). Don't know if this was the same in older versions of the IDE but perhaps the IDE should prevent this. Renamed all modules so the project compiles correct but the library still gives the error.
 

Attachments

  • Beta250LibExample.zip
    7.5 KB · Views: 275
Upvote 0

corwin42

Expert
Licensed User
Longtime User
You are correct with the underscore names. I tried to add the lib to the same project which does not work. But If I try to add it to another project I still get the error if I enable the checkbox on the TestLib library on the libraries register.
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
Using the lastest 2.50Beta 2, I get the following error trying to compile a test project with a library I just created. icscontrols is the name of the class module. Any idea what I am missing?

Parsing code. 0.00
Compiling code. 0.07
Compiling layouts code. 0.01
Generating R file. 0.77
Compiling generated Java code. Error
javac 1.6.0_26
src\b4a\example\main.java:227: cannot find symbol
symbol : class icscontrols
location: package b4a.example
public b4a.example.icscontrols _nb = null;
^
1 error

UPDATE


Windows was protecting the xtralibs folder from being written to, so the lib did not exist even with it showing in the library tab. Even with a refresh on the library tab it still was showing and checked but the files were never written because of the folder properties. A manual copy of the files corrected the issue.
 
Last edited:
Upvote 0

bluedude

Well-Known Member
Licensed User
Longtime User
How to call a sub in a compiled library

Hi,

I have created a library from a B4A project with a code module that contains a sub. How can I call this sub in a project referencing my library?

I'm trying to do "Dim test as" but nothing of my library shows up.

How does this work with classes compiled to a library?

Cheers.
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
Here is a quote from Erel that tells how to access subs in modules in a generated lib.

You should right click on the libraries list and choose Refresh after an update when updating a referenced library.. - CallSub / CallSubDelayed - The first parameter for these keywords is a reference to the target module. When working with modules that reside in a library you should pass the module reference and not the module name as string (this is the better way to reference all modules in all cases). - Code obfuscation - Libraries can be obfuscated during library compilation. Strings will not be obfuscated in this mode.
 
Upvote 0

bluedude

Well-Known Member
Licensed User
Longtime User
Mm, unclear. Not sure what the difference is between Module reference and module name. I know I see a library name in my library list, is that what is talked about?
So basically these libraries work different because you can only use CallSub etc.?

A sample would really help (class and code module)
 
Upvote 0

bluedude

Well-Known Member
Licensed User
Longtime User
Tried that but does not work. Should I declare something first to get to the library? The library is in my library file list with a name called ttTest. In there is a code module that is called codeTest. And in there is a sub called MyTest.

So can we also transform classes like for example a custom seekbar to a library and use them?

Cheers,
 
Upvote 0

bluedude

Well-Known Member
Licensed User
Longtime User
Test and mylibtest

Hi,

Hereby I share the sample. Test is the lib and mylibtest is a B4A project, i'm sure I do something stupid.

Cheers.
 

Attachments

  • Test.zip
    6.1 KB · Views: 276
  • mylibtest.zip
    5.8 KB · Views: 263
Upvote 0

bluedude

Well-Known Member
Licensed User
Longtime User
Ok, the CallSub confused me :)

First tried to do a declaration for the library but now I realize that is not needed.

That works of course!

Cheers,
 
Upvote 0
Top