Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Romans_I_XVI
Roku Guru

How to use custom libraries?

So this is a fairly basic question I think...

I wanted to try and create a custom BrightScript library. According to this ...
https://sdkdocs.roku.com/display/sdkdoc ... tLibraries
... all I have to do is put the .brs file in the package's root directory. However, when I try to load it by calling
Library "test.brs"

I get this
*** ERROR compiling /pkg:/source/main.brs:
Error loading file. (compile error &hb9) in pkg:/source/main.brs(2) 'test.brs'

It doesn't matter if I point to my file, or I point to a file that doesn't exist, the error message is the same.

I've used things such as the v30/bslDefender.brs in the past with no problem but never my own. Anyone else done this sucessfully?
0 Kudos
3 REPLIES 3
RokuKC
Roku Employee
Roku Employee

Re: How to use custom libraries?

"Romans_I_XVI" wrote:
So this is a fairly basic question I think...

I wanted to try and create a custom BrightScript library. According to this ...
https://sdkdocs.roku.com/display/sdkdoc ... tLibraries
... all I have to do is put the .brs file in the package's root directory. However, when I try to load it by calling
Library "test.brs"

I get this
*** ERROR compiling /pkg:/source/main.brs:
Error loading file. (compile error &hb9) in pkg:/source/main.brs(2) 'test.brs'

It doesn't matter if I point to my file, or I point to a file that doesn't exist, the error message is the same.

I've used things such as the v30/bslDefender.brs in the past with no problem but never my own. Anyone else done this sucessfully?


I believe that documentation is incorrect, and was written prior to the Roku platform, or at least prior to Roku firmware from the last several years.

The Library statement is to support system and external includes only.

For your own internal use, just put test.brs under your source directory and it will be implicitly included.

In other words, there's no difference between a "library" file and any other BrightScript source file in this context.
0 Kudos
Romans_I_XVI
Roku Guru

Re: How to use custom libraries?

Alright that's what I needed to know, thanks.

It's unfortunate that there isn't stronger behavior, for instance it'd be cool if it supported remote hosted libraries. Such as...
Library "http://example-site.com/bslSomething.brs"


Oh well. Thanks again.
0 Kudos
EnTerr
Roku Guru

Re: How to use custom libraries?

"Romans_I_XVI" wrote:
It's unfortunate that there isn't stronger behavior, for instance it'd be cool if it supported remote hosted libraries. Such as...
Library "http://example-site.com/bslSomething.brs"

Now that would be a perfect way to circumvent going through that pesky app submission review process, wouldn't it?
If so, that line above will be the only brightscript in the bundle - everything else we'll deem a "library".
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.