链接到 smpeg 库
Linking against smpeg library
我正在尝试使用 SDL 和 smpeg 制作准系统媒体播放器。目前我唯一的代码如下:
// Header file for SDL
#include "SDL.h"
// This is the header file for the library
#include "smpeg.h"
// Link in the needed libraries
#pragma comment( lib, "sdlmain.lib")
#pragma comment( lib, "sdl.lib")
#pragma comment( lib, "smpeg.lib")
#include "SDL_Movie.h"
int main(int argc, char* argv[])
{
return 0;
}
然而,当我尝试使用以下命令编译此代码时出现错误:
g++ sdltest.cpp `pkg-config --clflags --libs sdl2` && ./a.out
Error is: fatal error: smpeg.h: No such file or directory
我认为这是 smpeg 库的链接错误,我尝试了以下链接命令:
-lSDL2_smpeg
-lSDL_smpeg
-lsmpeg
-libsmpeg
请注意,我已经使用我的包管理器安装了我认为正确的库:
sudo apt-get install libsmpeg-dev
我应该如何以不同的方式链接它?
在我的 Debian Stretch 盒子上 libsmpeg-dev
将 smpeg.h
header 粘贴在 /usr/include/smpeg/
中,而不是 /usr/include/
。
所以要么将 -I/usr/include/smpeg/
传递给 g++
,要么切换到 #include <smpeg/smpeg.h>
。
请参阅 GCC C preprocessor documentation 了解它如何搜索 header 个文件。
我正在尝试使用 SDL 和 smpeg 制作准系统媒体播放器。目前我唯一的代码如下:
// Header file for SDL
#include "SDL.h"
// This is the header file for the library
#include "smpeg.h"
// Link in the needed libraries
#pragma comment( lib, "sdlmain.lib")
#pragma comment( lib, "sdl.lib")
#pragma comment( lib, "smpeg.lib")
#include "SDL_Movie.h"
int main(int argc, char* argv[])
{
return 0;
}
然而,当我尝试使用以下命令编译此代码时出现错误:
g++ sdltest.cpp `pkg-config --clflags --libs sdl2` && ./a.out
Error is: fatal error: smpeg.h: No such file or directory
我认为这是 smpeg 库的链接错误,我尝试了以下链接命令:
-lSDL2_smpeg
-lSDL_smpeg
-lsmpeg
-libsmpeg
请注意,我已经使用我的包管理器安装了我认为正确的库:
sudo apt-get install libsmpeg-dev
我应该如何以不同的方式链接它?
在我的 Debian Stretch 盒子上 libsmpeg-dev
将 smpeg.h
header 粘贴在 /usr/include/smpeg/
中,而不是 /usr/include/
。
所以要么将 -I/usr/include/smpeg/
传递给 g++
,要么切换到 #include <smpeg/smpeg.h>
。
请参阅 GCC C preprocessor documentation 了解它如何搜索 header 个文件。