Solved

LNK2001 Error. Using a .lib

Posted on 2002-07-11
2
411 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

697 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