• Welcome to Theos PowerBasic Museum 2017.

uFMOD in PowerBasic?

Started by Bob Range, July 19, 2009, 05:24:56 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bob Range

I am looking into using the uFMOD http://ufmod.sourceforge.net/ XM player library in PB. I have a feeling that I will have to convert the ASM source code of uFMOD to PowerBasic Inline ASM, because from what I recall, you can no longer "Link" .OBJ files to PB (deprecated after PB/DOS?). Not really sure on that...

Once compiled, the uFMOD library is in the form of a .OBJ file, which isn't that just definition info?

How should I go about doing this? uFMOD can either use the winmm.dll driver or DirectSound (part of DirectX).

Off Topic: Love the WINAPI 1.14 :)

José Roca

 
The link that you have provided says that uFMOD can be compiled as a .DLL. You can use DLLs with PowerBASIC.

Bob Range

I was kinda hoping for a way of doing this that didn't require me to package up a dependency... This library can be "Linked" in other compilers, to remove the need for a dependency. I guess the only way to use this in PowerBasic is to use the DLL?

José Roca

Yes, the current versions of the PB compilers doesn't support static linking.

Bob Range

Thats what I found looking through documentation and other forum posts. So I guess my only two options are:

1) Use a DLL
2) Convert the ASM of uFOD to PB Inline ASM

Any ideas if Static Linking will be in future versions of PB?

José Roca

 
Several users have requested static linking, but only Mr. Bob Zale can decide.

Theo Gottwald

Just for me to know ... do you think its a heavy job to enable "static linking" in a Compiler, or can it be done "in an hour" ?

Edwin Knoppert

It depends on what you expect.
Real static linking is not only attaching a block of code but also obtain the codefragments requested from a library.
I can have a static lib from 1MB but if i need that single feature it will obtain that part only.

Static linking in PB is done through embedding a dll and initialize it but is far from desire since it remains large.

So you can speculate about how internals must work, global variables etc are a pain, they are outside the function you request.
Iow, it's really a specific compiler task to make this all work imo.

Bob Range

So lets say that I need to be able to use this library in a program, without the DLL! I need everything self contained. Would I be better off using something like MASM32? Would it be convert uFMOD to PowerBasic? This is just a limitation of the current PB Compiler...

James C. Fuller

Quote from: Edwin Knoppert on July 19, 2009, 10:32:10 PM
Real static linking is not only attaching a block of code but also obtain the codefragments requested from a library.
I can have a static lib from 1MB but if i need that single feature it will obtain that part only.

This depends on how the library was created. Many people assume if they compile several functions into an obj file and then add them to a library, the linker will only include the functions needed. This is not true. The whole obj module will be include. To get function granularity you need to compile each function separately and then add all the function obj modules to the library.

James

 

Edwin Knoppert


James C. Fuller

Quote from: Edwin Knoppert on July 20, 2009, 12:33:16 PM
LCC does..


I do not have the time or inclination to pursue this further but I am skeptical.
I did some pretty exhaustive testing with FreeBASIC (GCC) and that was not the case.
LCC must truly be an innovator.

James
 

Bob Range

I compiled this using FASM/Microsoft Incremental Linker to produce the DLL.

Download Here: http://www.megashare.gr/file/1011/ufmodlib-rar.html

The DLL is very tiny only 9kb...

Bob Range

Well seeing as this DLL is very small and not overly complex, I have decided to pack the DLL + EXE with PECompact. Now I just need to write an INC to declare the uFMOD equates and functions... I will post this file once I have finished... Having to convert a C header file to PB... :P