Qbasicnews.com

Full Version: Freebasic and dlls
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
one question, Crysstaafur

i ran the command line you gave me, the whole

Code:
ld -dll -e fb_winhello_entry -o winhello.dll winhello.o -L i:\freebasic\lib -l fb -l crtdll -l kernel32 -l user32 -l gdi32 -subsystem windows

thing, but i keep getting this error back, i believe it's my main problem.

Code:
ld: warning: cannot find entry symbol _WinMainCRTStartup; defaulting to 10001000

I can get it to export functions though
Code:
LIBRARY dll.dll
EXPORTS
ADD@8
FB_DLL_ENTRY@12
fb_End@4
fb_Init@0

thats from pexports dll.dll
The warning may be fine though...does the dll actually work as expected, or is it broke-ass? Big Grin
i tried calling it from vb6.0
crashed ide down to windows. I think it be broke.
Yup...just slightly. Big Grin Maybe when v1ctor comes back, he might be able to give y'all some insight on to how this is all done...please, v1c? Big Grin
ok, when you setup the func exports, what did you tell the fb compiler when you declared the functions (both DllMain and exported functions/subs) in order to mark them for export?

_WinMainCRTStartup
I noticed this change when I compiled as gui all the way.
(fbc.exe -s gui, ld -subsystem windows)
When I was using the fb_programname entry, I might have been compiled (fbc.exe) or in the process of linking (ld.exe) in console mode on accident.

After studying about this on some C sites, a DllMain needs to be called, in the fb code it would be a function named DllMain that contains a select case statement that picks up on whether the dll is loading/unloading a process or thread. Still quite stuck on how to setup it up right, I still get the same entry point error.. I hope you are having better luck..
Smile
winhello.bas uses an entry point like this:
Code:
end WinMain(GetModuleHandle(null), null, Command$, SW_NORMAL)
Perhaps that will offer a clue or two...
in order to export the functions I used the following
Code:
ld --dll -e fb_dll_entry -o dll.dll dll.o -L c:\freebasic\lib -l fb -l crtdll -l kernel32 -l user32 -l gdi32 -subsystem console --export-all-symbols --exclude-symbols fb_DLL_entry,fb_dll_entry

that way it exports everything but the 2 it has trouble with, namely fb_DLL_entry,fb_dll_entry.
In my code i have a dllmain function

Code:
declare function DLLMain (byval instance as integer, reason as integer, unused as integer) as integer
i've used the same thing and made a dll from pure ASM. it works just fine.
do you want the constants and all?
dude... I wrote an fb patch to make DLLs a couple weeks ago, but since v1c's not released a new version yet, it's not out yet... just wait...
cool, thanks for the heads up
Tom, Nek, na_, and DrV -> Thanks for all the help! :bounce:
You guys rock! Smile

Tom -> I wasn't using -export-all-symbols or the -exclude......
Now everything shows up in dependancy walker and I can see each label and their entry points. w00t

Nek -> I changed my source by adding an End statement before calling DllMain I believe that helped too!

fyi: I did not include user32,gdi, or kernel32, I compiled using fbc with -s console, and linked with ld.exe with -subsystem console.

I'll let ya know if it worked here in a bit. (The vb computer is being used atm..)

(update) I tried it in fb first(thank you Nek for makea!!), now that I have access to the dev computer. It died on the spot, so it's also safe to assume my copy will also die in vb. Undecided I am still optimistic, something will come up, no worries here... Smile
Pages: 1 2 3