First off, what type of module are you making? Are you making a module that is pure blitzmax code? Are you editing an already existing module that uses C/C++/ObjC? Are you making a module to interface to a DLL?
Mingw
In windows:
First off, to compile modules you will need to have mingw (at least on a windows computer) and have the paths for it set up. For anyone who doesn't know, enviornment paths allow you or other programs to use common programs by simply referencing the name of the program.
Mingw is pretty much multi purpose when used in conjunction with blitzmax. It allows blitzmax to compile non-bmx code into modules (automated), and allows you to use dlls in blitzmax after writing a wrapper/declerations in .bmx. Get it from here
Then, you've gotta set your enviornment paths for it. Go to control panel, System, Advanced tab, click "Enviornment variables", in the new window that pops up there is a listbox labeled "System Variables". Within this, scroll down to a variable named "Path". Select it, click edit. Move to the end of the text, and add a semicolon (;), and paste in the path to your mingw bin directory.
In Mac and Linux:
I'm not sure about mac and linux but most linux distributions will have a copy of gcc (GNU Compiler Collection) which is what BlitzMax requires to compile mixed language modules.
Make your own module
Ok, let's say we decide to make our own module. Open up the default IDE or a 3rd party IDE, and create a new file. First off, I like to declare my modules as Strict:
Next, declare the ModuleInfo, which is basically just misc info about the module:
Just for an example we'll use a very, very simple function, of course you can use anything you would write in a normal blitzmax file as the contents. Like, Globals, Constants, Functions, Methods, Types, Arrays, Fields, etc.
Using non bmx files
You can simply do this:
Using dlls
Linking to dlls is detailed here
Mingw
In windows:
First off, to compile modules you will need to have mingw (at least on a windows computer) and have the paths for it set up. For anyone who doesn't know, enviornment paths allow you or other programs to use common programs by simply referencing the name of the program.
Mingw is pretty much multi purpose when used in conjunction with blitzmax. It allows blitzmax to compile non-bmx code into modules (automated), and allows you to use dlls in blitzmax after writing a wrapper/declerations in .bmx. Get it from here
Then, you've gotta set your enviornment paths for it. Go to control panel, System, Advanced tab, click "Enviornment variables", in the new window that pops up there is a listbox labeled "System Variables". Within this, scroll down to a variable named "Path". Select it, click edit. Move to the end of the text, and add a semicolon (;), and paste in the path to your mingw bin directory.
In Mac and Linux:
I'm not sure about mac and linux but most linux distributions will have a copy of gcc (GNU Compiler Collection) which is what BlitzMax requires to compile mixed language modules.
Make your own module
Ok, let's say we decide to make our own module. Open up the default IDE or a 3rd party IDE, and create a new file. First off, I like to declare my modules as Strict:
StrictThen, define the module name using the Module command:Strict Module Bot.FirstModuleThis also restricts compilation so you cannot attempt to compile it using standard methods
Next, declare the ModuleInfo, which is basically just misc info about the module:
Strict Module Bot.FirstModule ModuleInfo "Name: My First Module" ModuleInfo "Description: Cool eh?" ModuleInfo "License: Public Domain" ModuleInfo "Authors: Bot Builder" ModuleInfo "CustomAttr: See!"Now, we declare the modules our module will use:
Strict Module Bot.FirstModule ModuleInfo "Name: My First Module" ModuleInfo "Description: Cool eh?" ModuleInfo "License: Public Domain" ModuleInfo "Authors: Bot Builder" ModuleInfo "CustomAttr: See!" Import BRL.StandardIO 'Print stuffNOTE: This doesn't actually import it, yet. It just insures that the other module will be imported into the program. So if you import this module the other will also be imported.
Just for an example we'll use a very, very simple function, of course you can use anything you would write in a normal blitzmax file as the contents. Like, Globals, Constants, Functions, Methods, Types, Arrays, Fields, etc.
Strict Module Bot.FirstModule ModuleInfo "Name: My First Module" ModuleInfo "Description: Cool eh?" ModuleInfo "License: Public Domain" ModuleInfo "Authors: Bot Builder" ModuleInfo "CustomAttr: See!" Import BRL.StandardIO 'Print stuff Function SayHello(Name$) Print "Hi "+Name$ EndFunctionNow, this is just to demonstrate usage of the private flags which prevent some elements of a file not to be available from the outside:
Strict Module Bot.FirstModule ModuleInfo "Name: My First Module" ModuleInfo "Description: Cool eh?" ModuleInfo "License: Public Domain" ModuleInfo "Authors: Bot Builder" ModuleInfo "CustomAttr: See!" Import BRL.StandardIO 'Print stuff Function SayHello(Name$) Print Greeting+" "+Name$+"!!!" EndFunction Private Const Greeting$="Hi"You wont be able to access this externally. Finally, time to save our file. Create a directory inside mods called "bot.mod". This is the directory I will probably use for all my mods. Then, within that create a directory called "firstmodule.mod". Finally, save the source as "firstmodule.bmx". Keep in mind its important that its the same name. Then, start up the command prompt. You can also do this by going Ctrl-Alt-Delete, and in the task manager go File->New Task and type "cmd" and hitting enter. In side this, type "cd C:\BlitzMaxBeta101\bin", or, whatever your bin path is. Then, type "bmk makemods -r bot.firstmodule" this will compile the module in release mode. Make a new file:
SayHello("Everyone")and run. Hopefully it will display:
Hi Everyone!!!
Using non bmx files
You can simply do this:
Import "TheFile.C" Extern 'Add "win32" if its a win32 dll Function MyFunctionIWantToUse:ReturnType(params:types) 'ETC End Extern
Using dlls
Linking to dlls is detailed here