如何解决错误LNK2019:未解析的外部符号

How to solve error LNK2019: unresolved external symbol

本文关键字:符号 外部 LNK2019 何解决 解决 错误      更新时间:2023-10-16

我的老师给了我以下代码来制作一个带有波形可视化的录音机程序。但是,我坚持使用下面显示的错误。

。中国共产党

#include "StdAfx.h"
#include "resource2.h"
using namespace std;

//Globals for sound wave visualistion
int number, length, byte_samp, byte_sec, bit_samp;
static int sampleRate = 11025;
const int NUMPTS = 11025 * 10;
bool mono = TRUE;
bool PLAY = FALSE;
errno_t wavfile;
char * filename;
int s_rate = 11025;
double limit = 10000.0;
FILE * stream;
/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Declare procedures */
int readSample(int number,bool leftchannel);
void SaveWavFile(char *FileName, PWAVEHDR WaveHeader);
void Wav(char *c, HWND hWnd);
/*  Make the class name into a global variable  */
char szAppName[ ] = "Recorder";

资源2.h

#ifndef RESOURCE_H_INCLUDED
#define RESOURCE_H_INCLUDED
#define INP_BUFFER_SIZE 16384
#define IDC_RECORD 1
#define IDC_PLAY 2
#define IDC_STOP 3
#define NUM 20000
//defines for menu
#define APP_SAVE 1003
#define APP_EXIT  1004
#endif // RESOURCE_H_INCLUDED

我一直收到错误:

错误 LNK2019:未解析的外部符号imp__waveOutOpen@24 在函数"long __stdcall WindowProcedure(struct HWND *,无符号整数,无符号整数,长整型)" (?WindowProcedure@@YGJPAUHWND__@@IIJ@Z) 错误LNK2019:未解决 函数中引用的外部符号imp__waveInPrepareHeader@12 "long __stdcall WindowProcedure(struct HWND *,unsigned int,unsigned int,long)" (?WindowProcedure@@YGJPAUHWND__@@IIJ@Z) 1>录音机.obj : 错误 LNK2019:未解析的外部符号imp__waveInOpen@24 在函数"long __stdcall WindowProcedure(struct HWND *,无符号整数,无符号整数,长整型)" (?WindowProcedure@@YGJPAUHWND__@@IIJ@Z)

请告诉我如何解决这个问题,我已经挠头几个小时了。

这不是全部代码,因为其中没有调用这些函数。它们是winmm.dll中定义的Windows函数,因此链接到winmm.lib。具体如何做到这一点取决于您的编译器。

相关文章: