Solved

LNK2001 Error. Using a .lib

Posted on 2002-07-11
2
407 Views
Last Modified: 2010-05-19
I am trying to use a .lib file to play mp3's for a project I am working on. It is the libmad.lib file. I am getting the error below when using it in a MSVC++ MFC Dialog project, but not in the standard MAD player console project that comes with the library. I have all of the librarys included in the project. I should also mention that the libmad.lib library is written in C and not CPP. What should I check for, I've been looking for a while now and my brain is fried.

GUIDlg.obj : error LNK2001: unresolved external symbol "void __cdecl player_finish(struct player *)" (?player_finish@@YAXPAUplayer@@@Z)
GUIDlg.obj : error LNK2001: unresolved external symbol "int __cdecl player_run(struct player *,int,char const * * const)" (?player_run@@YAHPAUplayer@@HQAPBD@Z)
GUIDlg.obj : error LNK2001: unresolved external symbol "int (__cdecl*__cdecl audio_output(char const * *))(union audio_control *)" (?audio_output@@YAP6AHPATaudio_control@@@ZPAPBD@Z)
GUIDlg.obj : error LNK2001: unresolved external symbol "void __cdecl player_init(struct player *)" (?player_init@@YAXPAUplayer@@@Z)
Debug/GUI.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.

Thanks,
John
0
Comment
Question by:jsaxon2
2 Comments
 
LVL 22

Accepted Solution

by:
ambience earned 100 total points
ID: 7148170
that can be because you are writing code in C++ (cpp) file, i think the console project that you are mentioning must be a .c file.

you can get around that problem by supressing name mangling for all the imported API. for e.g. if you are using the following prototype

void __cdecl player_finish(struct player *);

you should change that to

extern "C"
{
void __cdecl player_finish(struct player *);
};

and that should supress C++ name mangling. If the API comes from some header you can do something like

extern "C"
{
#include "header.h"
}

hope this helps
0
 
LVL 3

Author Comment

by:jsaxon2
ID: 7148227
extern "C"
{
#include "audio.h"
#include "player.h"
}

is exactly what I needed. Thanks a million.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now