Solved

LNK2001 Error. Using a .lib

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

816 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

7 Experts available now in Live!

Get 1:1 Help Now