Name mangling causes link errors ... how disable mangling?

G

Guest

I need to use a library supplied by someone else: libjpeg.lib. This is a
plain C library. I do not have the source code. I do have the header *.h
files. When I run dumpbin on the libjpeg.lib, it contains symbols (entry
points) like:

jpeg_read_header

I'm trying to link my program with this library. My program is in Visual
C++. The link fails with link-time errors such as:

unable to find function _cdecl_jpeg_read_header(int, char*) [more mangling
stuff]

Apparently, at compile time my compiler is mangling the library function
names (from the library header files) to include the parameter types.

To fix this, I presume, I need to put some instructions into the library's
header files that say "Treat these as normal C functions without mangling".

Any suggestions on how to make the link successful? Thanks in advance for
any help.
neal
 
W

William DePalo [MVP VC++]

noleander said:
I need to use a library supplied by someone else: libjpeg.lib. This is a
plain C library. I do not have the source code. I do have the header *.h
files. When I run dumpbin on the libjpeg.lib, it contains symbols (entry
points) like:

jpeg_read_header
...

Try this

extern "C"
{
#include "libjpeg.h"
};

Regards,
Will
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top