How to make a module?

BlitzMax Forums/BlitzMax Programming/How to make a module?

Tibit(Posted 2006) [#1]
I seem to have forgotten some part of mods making. I just can't get my module to build correctly and be recognized by BlitzMax.

This is how I do it:

I make a folder in pub.mod I call it mymodule.mod (only small chars)

In there I put all the source, the main file is called mymodule.bmx ( It have to be same as the folder name )

In the mymodule.bmx file I have this code:

Module Pub.mymodule
'Imports everything required
Import Brl.Bank
Import Brl.LinkedList
Import Brl.Math
Import Brl.Retro
Import Brl.System

ModuleInfo "Author: "
ModuleInfo "Version: "

Include "Somefile.bmx" which includes the rest of the source for all files in the module.


Next I click WinT + R and type in cmd, I go to the C:/BlitzMax/Bin/ directory.

Now I write:

bmk makemods pub.mymodule

.. nothing happens ..

What did I forget? (Please also suggest if there is an easier way to do this)

I tried to write bmk makemods and that resulted in "all" modules being built.

Also when I built a exe I get a folder called ".bmx"
Can I directly use these files in any way?


assari(Posted 2006) [#2]
I think you need to do
bmk makemods -a pub.mymodule

You left out the -a


Tibit(Posted 2006) [#3]
That worked, thanks, it builds and I get four files :

mymodule.release.win32.x86.a
mymodule.release.win32.x86.i
mymodule.debug.win32.x86.a
mymodule.debug.win32.x86.i

I still have a problem..
If I now try to build a program that uses my module it does not reconize any functions that was in my module?

I tried to import pub.mymodule in a test file and when I compile I get the error "Cannot find interface for pub.mymodule"

I went to my "main" file, called mymodule.bmx. I tried to build it from the IDE and got the compile error "Module does not match commandline module"

Does anyone know what I have missed?


SebHoll(Posted 2006) [#4]
I don't think non-BRL function are recognised by the IDE and so remain white. I.e. all functions in the PUB.MOD folder appear white and functions in the BRL.MOD folder (the native commands) are yellow.


Seb

P.S. I think you get the "Module does not match commandline module" if you try to compile in Blitz a file with a Module XXX line in it. Try commenting it out when compiling and then adding it back in when you run a makemods.


Tibit(Posted 2006) [#5]
I did not mean the functions should be highlighted as "commands", I meant I get a compile error that says a function does not exsist that is in my module, and therefore I should be able to run that function. And when I specify an import (Pub.mymodule) it does not find the module, which I find very strange.

It has worked before.. I must have missed some point or maybe some new feauture I'm unaware of.

"Module does not match commandline module" - Okey so this has nothing to do with my problem, it simply means: You can only build modules from the commandline. Thanks for clearing that up. I do comment it out when I work on the module, was just hoping it might give a clue to the problem.

Perhaps I should not use the pub.mod directory but create a new one for all my modules? Is that a good/bad idea?


Diablo(Posted 2006) [#6]
Perhaps I should not use the pub.mod directory but create a new one for all my modules? Is that a good/bad idea?

I would do this now as when you update blitzmax, it appers that it removes any custom modules in the /pub folder.

If you create your own module folder it means that you will have to opt in the module by using the 'import youname.modulename'.

BTW what version of blitzmax are you using?


assari(Posted 2006) [#7]
Module does not match commandline module
I get this when the module names do not match (b/w import xxx.name and module xxx.name)

Your steps seems to be correct. If all this does not work suggest you go back to basic and do a simple module. As a reminder, there's this tutorial from Botbuilder.


Booticus(Posted 2006) [#8]
Yeah let me second the opinion of keeping your module in a separate directory, as iglass AND maxml got blown away when I did the Bmax 1.20 update. :( Good thing I backup my mod folder every night. Otherwise I'd be kinda bummed.

Wave I cant wait to use TNet in Bmax 1.20!


Brucey(Posted 2006) [#9]
For building modules, I always just use Ctrl-D in the IDE.

The "Module does not match commandline module", as you realised, occurs when you try a "normal" build of the module - that is, Ctrl-B or Ctrl-R - because a normal build creates an exe, not a module .a file.

Ths ""Cannot find interface for pub.mymodule" message is a bit of a pain. I've had it alot when creating modules. One thing I would definetly check is that you use the SAME case for the following :
The name of your .mod folder - "mymodule.mod"
The name of your .bmx file - "mymodule.bmx"
It seems to be important that these are of the same case - I decided to always make mine lowercase from now on. (Well, it is certainly important on Linux/Mac - and after spending an hour debugging bmk, that is what I found fixed my problem with that message)

The case of the import and module names (in your code) do not seem to matter so much... Just make sure you don't have any typos there.

Other than that, I can't think of any other reason it won't import.

HTH


Tibit(Posted 2006) [#10]
Thanks for the help, I will go and test some more.

I have a dual install. I'm trying to compile in 1.20, however I still have 1.16 installed in another directory. (Should not cause any problems should it?). I can run everything fine, the problem at this stage comes when I try to build the module.

A side note, when I click about in the IDE it says Version 1.15beta3, but I assume that was the IDE. I installed 1.18 then I ran the upgrade to 1.20.

I'll also try to move it to my own module directory.


Tibit(Posted 2006) [#11]
It can not find the module. To build it works fine. It is just not found. I tried to create my own mod directory and it is the same thing. I have checked the case of all names, and checked the spelling. I did a test mod with one function and no imports. It built then it was not found when I tried to import that module into an new empty bmx file.


Tibit(Posted 2006) [#12]
I removed Blitzmax and installed a fresh version of 1.18 and then upgrade to 1.20 and now it works, and the about tab says it is version 1.20.

The TNet site is updated. Check it out here