1

I've been trying to link to a third-party DLL. I've tried in 3 different ways: by compiling C in Cygwin, by compiling C++ in Visual Studio and by compiling C# in Visual Studio. Everytime I compile the programs, I get the following errors:

Cygwin: undefined reference to '__imp__IEC61850_Create'

Visual S: LNK2019: unresolved external symbol '__imp__IEC61850_Create'

As you might have gathered, I am trying to call the function 'IEC61850_Create' which is found in the DLL, but it always shows up in errors with the '__imp__' prefix. As the DLL is third-party, I can't view the source. In other places I have searched, people usually talk about an accompanying .o or .lib file. In this case, the only resource I have is the .dll.

Has anyone else experienced something like this, or know how I can link to the library? I can provide sample code if needed.

Thanks.

1 Answers1

1

You really need to link to the .lib file, because only it has the __imp__ stubs needed for static linking.

However, what you can do is to create a .def file and use lib to convert it into a .lib file.

Alternatively you can create a dummy project with empty functions to create a .dll and a .lib file, link to the .lib file, but then use the real .dll with the actual program.

For more information you could read Microsoft KB Article 131313.

Neil
  • 54,642
  • 8
  • 60
  • 72