PDA

View Full Version : Plug-in's created with Borland C++ Builder


dspboy
17th March 2002, 21:39
Does anyone have any advice on how to tweak Borland C++ Builder version 4 to create Winamp plug-in's? I started with the Winamp DSP SDK example and compiled it as a dll in Borland, following the naming convention of dsp_myapp.dll, and copied the dll into the plug-in's directory, but I can't get my dll to show up in the Winamp DSP list. :(

I imagine it either has to do with proper mak file settings, or the fact that Borland requires a windows API called DllEntryPoint in all source files targeted for a dll app. (It refuses to compile otherwise. :mad: ) I replaced the following dllexport macro

#ifdef __cplusplus
extern "C" {
#endif
// this is the only exported symbol. returns our main header.
__declspec( dllexport ) winampDSPHeader *winampDSPGetHeader2()
{
return &hdr;
}
#ifdef __cplusplus
}
#endif

with this code

winampDSPHeader* WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
{
return &hdr;
}

Any help is appreciated! I am not very familiar with MS VC++ projects or mak files.

peter
17th March 2002, 22:13
wrong. you *need* do export winampDSPGetHeader2, otherwise Winamp won't recognize the dll. you can make a fake DllEntryPoint to shut borland linker up.

dspboy
18th March 2002, 00:29
OK, thanks peter. Now please bear with me as I struggle through.

Should my fake DllEntryPoint instantiate the dllexport somehow, or does it automatically get run when Winamp pokes the dll? I tried this, but still did not see my dll in the plug-in list.

#ifdef __cplusplus
extern "C" {
#endif
// this is the only exported symbol. returns our main header.
__declspec( dllexport ) winampDSPHeader *winampDSPGetHeader2()
{
return &hdr;
}
#ifdef __cplusplus
}
#endif

#pragma argused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
{
return 0;
}

Or... it may be an entirely different issue all together. Any thoughts are welcome. Thanks.

dspboy
21st March 2002, 16:51
This is what I have learned so for, and I thought I would share so that others would not have such a painful learning curve. There is a button on the Winamp Preferences window (Winamp version 2) when you select "Plug-ins" from the list called "Flush plug-in name cache". Click this button, and the next time you click DSP/Effect, Winamp will re-populate the plug-in list. In this way, I was able to get my new plug-in to show up in the list. There is no message command for this function in frontend.h, so I don't know how this processes happens on a new install, maybe the NSIS takes care of it somehow.

I still can't get Winamp to recoginize my exported header though, no matter what I try. It is getting thunked, b/c I put a message box in DllEntryPoint to tell me when, but winamp is not getting the header. Actually, it assign's the name of the plug-in the same name as the previous plug-in in the list, but with my filename. I have searched this site, Borland's newsgroups, and comp..everthing newsgroups extensively. Any posts regarding this subject ultimately go unanswered. Maybe I should go next to the developer request section and ask for some more explanation as to how Winamp is using winampDSPGetHeader2 and how it is called. Does this suffice as an official request?

Any suggestions are welcome, expect to go and use MSVC++, I do have a reason for using Borland.

Thanks

RawSoul
31st March 2002, 20:51
/*
Hi

When you export an function like:
extern "C" __declspec(dllexport) winampDSPHeader *winampDSPGetHeader2();

the Builder Linker generantes an exported function named
"_winampDSPGetHeader2" the '_' character makes WinAmp "can't see" the function.

but if you use WINAPI, the linker doesn't add the _ prefix in the function name.

The working definition of the function is that:
*/

#ifdef __cplusplus
extern "C" {
#endif
// this is the only exported symbol. returns our main header.
winampDSPHeader * __declspec( dllexport ) WINAPI winampDSPGetHeader2()
{
return &hdr;
}
#ifdef __cplusplus
}
#endif

// or simply:

extern "C" winampDSPHeader * __declspec(dllexport) WINAPI winampDSPGetHeader2()
{
return &hdr;
}

/*
I hope this helps you.
PS: Sorry for the english, my language is portuguese[BR]...
*/

RawSoul
31st March 2002, 20:59
about the last reply

If it didn't work try to look the export table of the DLL with QuickVew. And have in mind that:

winampDSPGetHeader2 != _winampDSPGetHeader2

This comment might be a little idiot, but some app's that come with the OS help us sometimes...

ShowMessage("That's all!");

RawSoul
1st April 2002, 00:54
After a few hours of research on the internet, I found an doc that explains much better than I this 'name mangling' conventions and techniques for calling BCB DLL's

http://www.bcbdev.com/articles/bcbdll.htm

dspboy
4th April 2002, 02:19
RawSoul, you rule! Thanks so much for your input and time you spent on this problem. The link you found at the Borland Developer Network explains the trouble very well, and is a must read for anyone writing Borland app's that need to export functions to MSVC++ projects, and vice versa.

Unfortunately, from the article, the only way to make a Borland dll play nicely with a MS app, you must have the link libraries for the MS project and re-link them with your dll using MSVC++. Thus, I have finally sold out after 2 weeks of trying to not do the inevitable. :eek: I bit the bullit and bought MSVC++ 6.0. I will still continue to use Borland for some projects though, but at least now I have the tool that I need to do Winamp development. It's really too bad that Borland and Microsoft find it necessary to play these games and cannot agree on a standard.

At least I can get started on my plug-in, finally. :)

thinktink
25th May 2009, 18:29
I had the EXACT same problem as you did but I found the solution after about 30 minutes beating my head on my desk.

#pragma option push
#pragma option -ps
#ifdef __cplusplus
extern "C" {
#endif
winampGeneralPurposePlugin * __declspec( dllexport ) winampGetGeneralPurposePlugin()
{
return &plugin;
}
#ifdef __cplusplus
}
#endif
#pragma option pop

This worked magnificently for me using Borland C++ Builder Pro 5. Should work for all~ish versions.