NO

Author Topic: Unresolved external - help sought  (Read 3621 times)

woolybear

  • Guest
Unresolved external - help sought
« on: May 20, 2009, 07:14:42 PM »
I'm new to Pelles-C although well used to C, Python a good variety of things in between. I'm struggling to get my head around importing DLLs and would welcome any advice on offer.

Essentially I've got a 10 line C test app which calls various functions in windows DLL (msmapi32.dll - Micronetics MSM-Activate API). On compiling I get

POLINK: error: Unresolved external symbol '_msm_initialize'.

i.e. a straight forward linker error. I thought I needed to import the DLL so I tried

polib /OUT:msmapi32.lib /MAKEDEF:msmapi32.def msmapi32.dll

but neither adding the lib nor the def to the project solves it. I've scoured google trying to find an example or some other hint and all seem suggest that these steps are what I need to do but to no avail. I've tried everything I can think of but am ready to hit it with something big and heavy.

In python the ctypes library imports and uses this dll without any difficulty if that helps.

Could some kind soul put me out my misery and give me a clue which incantantation will fix this.

Kind regards

Iain

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Unresolved external - help sought
« Reply #1 on: May 20, 2009, 08:31:52 PM »
Look for MSMOLE.DLL
Those function may be there.
May the source be with you

woolybear

  • Guest
Re: Unresolved external - help sought
« Reply #2 on: May 21, 2009, 12:14:44 AM »
Thanks - aware of MSMOLE for OLE connections but still trying to get my head round how to access a windows DLL successfully. The DEF file all looks to have the right function names suggesting that implib has done it's work... I just can't figure out how to link the darned beast in successfully.

Can anyone point me in the right direction?

Thanks

The Wooly One

jwzumwalt

  • Guest
Re: Unresolved external - help sought
« Reply #3 on: May 21, 2009, 01:54:59 AM »
This is a short article on how to make and access DLL's. Maybe it can help.

http://www.c.neatinfo.com/public/4-tutors/DLL-in%20C%20&%20C++.doc

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Unresolved external - help sought
« Reply #4 on: May 21, 2009, 05:06:13 AM »
With PEView.exe you can look at exe/dll to see exported functions.
http://www.magma.ca/~wjr/
Microsoft's MSMAPI32.DLL doesn't have msm_initialize function.
May the source be with you

woolybear

  • Guest
Re: Unresolved external - help sought
« Reply #5 on: May 21, 2009, 05:24:23 PM »
Thanks for the replies one and all. Some useful suggestions. In the end I found it boiled down to:

1. Use the implib utility with the /OUT parameter to generate a LIB file from the DLL

2. Ignore the temptation to make a DEF file with implib /DEF. Adding it to the project just caused compiler confusion.

3. Add the LIB file to the project properties on the linker tab.

4. And the key bit... preface all function prototypes with __stdcall e.g. int __stdcall msm_initialize();

Those 4 steps made it work nicely. The rest of my woes were buggy example code and all the other delights of codesmithery.

Thanks again

The Wooly One