in response to the thread : http://www.purebasic.fr/english/viewtop ... 13&t=40948, in which j50501313 wished to export a function, not in a dll, but in a regular EXE, it occurred to me that perhaps the simplest way of doing this is to use my coffIT tool.
It is a fact that executables can contain exported functions just like dll's and Purebasic's library functions can call these functions after using OpenLibrary() etc. The problem, however, is that the PB compiler will not presently allow us to export functions inside an EXE.
Two things are needed in order to export a function in an EXE as described...
- When the PB compiler creates the intermediate object (.obj) file (before the link stage), the name of the function to be exported from the final EXE must be placed within the object file's symbol table.
- The linker must be informed that the named function (which it will find in the aforementioned symbol table) is to be placed within the export section of the final EXE. The best way of doing this is by using a 'link file' through the IDE compiler options dialog.
But then it occurs to me that my coffIT tool will do most of this automatically!

What follows in the next couple of posts within this thread are the steps required to complete a basic example of using coffIT to create an EXE containing an exported function. Other programs can then load this EXE via OpenLibrary() and call the functions as if it was a dll etc.
Post to follow...