我使用windows 7运行visual 2010并使用Cc编写。
下面是我的代码片段。当条件满足(温度高于上限)时,我想从我的计算机上播放一个wav文件。我查看了论坛,复制了以前的海报格式,如果我仍然有同样的问题的话。我得到以下错误:
1>lab4TemperatureController.obj : error LNK2019:函数"void __cdecl activateAlarm(int,int)“中引用的未解析外部符号_imp_PlaySoundA@12 (?activateAlarm@@YAXHH@Z) 2010\Projects\lab6\lab6TemperatureControlTime\Debug\lab3temperaturesensor.exe :致命错误LNK1120: 1未解决的外部因素
以下是我的CPP中包含的头文件
#include "stdafx.h"
#include "lab4temperatureController.h"
#include <conio.h>
#include "console.h"
#include <iostream>
#include <Windows.h>这是我的函数,调用播放声音
void activateAlarm(int channelID, temperature_t temperature)
{
int key = 0;
if ((temperatureChannel[channelID].currentTemperature > temperatureChannel[channelID].highLimit) | (temperatureChannel[channelID].currentTemperature < temperatureChannel[channelID].lowLimit))
PlaySound(TEXT("C:\\Users\\Hassman\\Documents\\Visual Studio 2010\\Projects\\lab6\\lab6TemperatureControlTime\\lab3temperaturesensor\\untitled"),NULL,SND_FILENAME);
sensorLog();
if (_kbhit())
key = _getch();
if ((key == 'P') | (key == 'p'))
{
silenceBeep();
}
}发布于 2013-03-25 21:22:41
在生成可执行输出文件时,您似乎忘记了将对象文件与包含该函数实现的库链接起来。
根据MSDN图书馆的说法,使用PlaySound需要与Winmm.lib链接。
https://stackoverflow.com/questions/15624918
复制相似问题