Pelles C forum

Pelles C => General discussions => Topic started by: alorent on April 07, 2006, 01:40:36 AM

Title: Problem linking with library
Post by: alorent on April 07, 2006, 01:40:36 AM
Hello,

I have tried PellesC to link with a library created by MASM. The library exports functions without the underscore in front of the function.

But when I declare the function under Pelles C, it automatically puts the underscore in front of the function, so the linker do not find the function.

extern void __declspec(dllexport) __cdecl MyFunction(void)

Pelles C try to links with "_MyFunction" and it's not found. Because the name is "MyFunction" (without the underscore)

How can I avoid Pelles C from putting the underscore?

Thanks.
Title: Re: Problem linking with library
Post by: rdtsc on March 19, 2010, 10:37:05 PM
I just spent many hours researching a similar situation, so for others, I present a work-around.

I wanted to use the free Win 2k/NT/XP "io.dll" ring-0 driver from http://geekhideout.com/iodll.shtml for fast parallel port access under windows. This may be similar to "giveio.dll" etc.

However, in Pelle's C, at link time it refused to natively link to the DLL because the exported functions do not contain a leading underscore. No combination of declaration or function type would enable linking, even using .DEF files. Furthermore, POLIB would give no error when making a .lib file from this library, however a verbose link would show that zero functions were being found in the generated .lib file. It would have been nice if POLIB had an \ADDUND switch, but there is another way...

The author of io.dll above gives a C/C++ method which bypasses this by using LoadLibrary at run-time. Check it out.
Title: Re: Problem linking with library
Post by: TimoVJL on March 20, 2010, 07:30:15 AM
Try polib.exe -def:io.def -out:iodll.lib

Code: [Select]
LIBRARY io.dll
EXPORTS
ClrPortBit @7
GetPortBit @5
IsDriverInstalled @1
LeftPortShift @3
NotPortBit @6
PortDWordIn @9
PortDWordOut @12
PortIn @11
PortOut @14
PortWordIn @10
PortWordOut @13
ReleasePort @2
RightPortShift @4
SetPortBit @8