Solved

LNK2001 Error. Using a .lib

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

762 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

19 Experts available now in Live!

Get 1:1 Help Now