DEV C++ C语言项目,编译到mciSendString两条代码就报错 求指点!
代码:#include<windows.h>#include<mmsystem.h>#include<stdio.h>#pragmacomment(lib,"Winmm....
代码:
#include <windows.h>
#include <mmsystem.h>
#include <stdio.h>
#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 展开
#include <windows.h>
#include <mmsystem.h>
#include <stdio.h>
#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 展开
1个回答
展开全部
不要傻呼呼以为 头文件一甩就完事了,
链接上对应的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貌似编译连接正确也不能播放,不兼容
链接上对应的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貌似编译连接正确也不能播放,不兼容
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询