DEV C++ C语言项目,编译到mciSendString两条代码就报错 求指点!
解决时间 2021-01-03 14:52
- 提问者网友:末路
- 2021-01-03 02:35
代码:
#include
#include
#include
#pragma comment(lib, "Winmm.lib")
int main() {
mciSendString("open \"C:\\WESong.mp3\" alias file", NULL, 0, NULL);
mciSendString("play file", NULL, 0, NULL);
getchar();
return 0;
}
报错信息:
C:\Users\CONAN\Documents\main.o main.c:(.text+0x28): undefined reference to `__imp_mciSendStringA'
C:\Users\CONAN\Documents\main.o main.c:(.text+0x49): undefined reference to `__imp_mciSendStringA'
C:\Users\CONAN\Documents\collect2.exe [Error] ld returned 1 exit status
25 C:\Users\CONAN\Documents\Makefile.win recipe for target '项目2.exe' failed
最佳答案
- 五星知识达人网友:夜风逐马
- 2021-01-03 03:24
不要傻呼呼以为 头文件一甩就完事了,
链接上对应的lib文件才是重点,
一下copy自msdn
The mciSendString function sends a command string to an MCI device.
The device that the command is sent to is specified in the command string.
MCIERROR mciSendString(
LPCTSTR lpszCommand,
LPTSTR lpszReturnString,
UINT cchReturn,
HANDLE hwndCallback
);
Parameters
lpszCommand
......
Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows
95/98: Requires Windows 95 or later.
Header: Declared in
Mmsystem.h.
Library: Use Winmm.lib. ------------- vc把这个链接上 mingw对应是libwinmm.a
Unicode: Implemented
as Unicode and ANSI versions on Windows NT/2000.
#pragma comment(lib, "Winmm.lib") m$自家vc 编译器cl.exe专有 宏指令,别家的不认
编译选项 连接 中添加 -lwinmm 能过通过连接,win7貌似编译连接正确也不能播放,不兼容
全部回答
- 1楼网友:人類模型
- 2021-01-03 03:34
没看懂什么意思?
我要举报
大家都在看
推荐资讯