gpt4 book ai didi

FFmpeg 6.0 won't work because the header files can't connect or interact with each other. How do I fix the files?(FFmpeg 6.0无法工作,因为头文件无法相互连接或交互。我如何修复这些文件?)

转载 作者:bug小助手 更新时间:2023-10-28 09:34:38 25 4
gpt4 key购买 nike



I am creating a win32 API C++ application with Microsoft Visual Studio 2022 in a .sln file. I've got quite far in basic functionalities & decided to try out video decoding & playing; I've practiced this before but not with C++. So, I looked to see good libraries & found FFmpeg. Of course, I thought this would be quite straightforward - just import the headers & code, right? No. Firstly, the FFmpeg I'm using is one of the pre-built binaries. The 'ffmpeg-master-latest-win64-gpl-shared.zip' From the BtbN Github repository. I decompressed it with WinRar & placed the files in Program Files (x86). Later on, I realised my mistake of placing it with 32-bit programs since it's a 64-bit build. So I transferred it to Program Files. Even after this though my issue persists. The issue being that the .h files of FFmpeg cannot communicate with each other. For some reason, they can't navigate to where the header files are. I am quite sure the reason for this may have something to do with where I save the files, the directory. Nowhere on the FFmpeg website can I see where you're expected to have the file directory at. I am sure there's a preset file path that is expected. Maybe I've named the FFmpeg folder incorrectly? Or maybe it's not meant to go in Program Files? The current directory for the FFmpeg folder for me is: C:\Program Files\FFmpeg. Below I will provide pictures of the errors I get where the code can't connect to other .h files as well as the file path. I'll also provide my code.

我正在使用Microsoft Visual Studio 2022在.sln文件中创建一个win32 API C++应用程序。我在基本功能上已经走得很远了,决定尝试视频解码和播放;我以前练习过这个,但没有用C++。所以,我看了看好的库,找到了FFmpeg。当然,我认为这将是非常简单的-只需导入头和代码,对吗?不。首先,我使用的FFmpeg是预构建的二进制文件之一。The 'ffmpeg-master-latest-win64-gpl-shared.zip'从BtbN Github仓库.我用WinRar解压并将文件放在Program Files(x86)中。后来,我意识到我的错误,把它与32位程序,因为它是一个64位的建设。所以我把它转到了程序文件里即使在这之后,我的问题仍然存在。问题是FFmpeg的.h文件无法相互通信。由于某些原因,它们无法导航到头文件所在的位置。我很确定这可能与我保存文件的位置有关,目录。在FFmpeg网站上,我看不到你应该把文件目录放在哪里。我相信有一个预设的文件路径是预期的。也许我命名的FFmpeg文件夹错误?或者它不应该被放入程序文件中FFmpeg文件夹的当前目录是:C:\Program Files\FFmpeg。下面我将提供图片的错误,我得到的代码不能连接到其他.h文件以及文件路径。我还将提供我的代码。


#include <Windows.h> //imports the main win32 API library
#include <tchar.h> //imports macros for handling Unicode & ASCII char sets
#include <CommCtrl.h> //defines the common control classes
#include <stdio.h> //imports the standard C library
#include <WinUser.h>
#include <Richedit.h>
#include <iostream>
#include <fstream>
#include <string>

extern "C"
{
#include <C:\\Program Files\\FFmpeg\\include\\libavformat\\avformat.h>
#include <C:\\Program Files\\FFmpeg\\include\\libavutil\\imgutils.h>
#include <C:\\Program Files\\FFmpeg\\include\\libswscale\\swscale.h>
#include <C:\\Program Files\\FFmpeg\\include\\libavutil\\avassert.h>
}

#pragma comment(lib, "Comctl32.lib") //tells the linker to include Comctl32.lib in the .exe
#pragma comment(lib, "C:\\Program Files\\FFmpeg\\lib\\avcodec.lib")
#pragma comment(lib, "C:\\Program Files\\FFmpeg\\lib\\avformat.lib")
#pragma comment(lib, "C:\\Program Files\\FFmpeg\\lib\\avutil.lib")
#pragma comment(lib, "C:\\Program Files\\FFmpeg\\lib\\swscale.lib")

#define EDIT_CONTROL 1
#define OPEN_FILE_BTN 2
#define SAVE_FILE_BTN 3
#define EMBOLDEN_BTN 4
#define ITALICISE_BTN 5
#define SCROLL_CONTAINER 6
#define FILEMENU_OPEN_FILE_BTN 7
#define ADD_ROW_BTN 8
#define CELL_1_ID 9
#define CELL_2_ID 10
#define CELL_3_ID 11
#define SCROLL_CONTAINER_TBL 12
// 946 0759 0609 | 163 739

HINSTANCE g_hInstance;
HWND g_hWndMain, g_hWndTabs, openFileBtn, saveFileBtn, hOpenFileEdit, hScrollContainer, hEditControl, tabHandle, emboldenBtn, italiciseBtn, FilemenuOpenFileBtn, tableContainer, tblHeaderOne,
tblHeaderTwo, tblHeaderThree, addRowBtn, hAddRowDialogue, hWnd, hWndCell1Label, hWndCell1Edit, hWndCell2Label, hWndCell2Edit, hWndCell3Label, hWndCell3Edit, hWndOkButton, hWndCancelButton, hRow, hCell1, hCell2, hCell3,
hWMP, OpenMp4Btn, hWMPContainer, hPlayBtn;
HMENU hMenu, hSubMenu;
bool isBold = false, isItalic = false;


const int startX = 0;
const int startY = 60;
const int ROW_HEIGHT = 20;
const int CELL_WIDTH = 110;
static int numRows = 1;
static int numCols = 3;

LRESULT CALLBACK WindowProcessMessages(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK AddRowDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);

int WINAPI wWinMain(
_In_ HINSTANCE currentInstance,
_In_opt_ HINSTANCE previousInstance,
_In_ LPWSTR cmdLine,
_In_ int cmdCount)
{
const wchar_t* CLASS_NAME = L"Windows App";
WNDCLASS wc{};
wc.hInstance = currentInstance;
wc.lpszClassName = CLASS_NAME;
wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.lpfnWndProc = WindowProcessMessages;
RegisterClass(&wc);

g_hWndMain = CreateWindow(CLASS_NAME, L"Windows App",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
800, 600,
nullptr, nullptr, nullptr, nullptr);

if (g_hWndMain == NULL) {
return 0;
}

// Initialize common controls
INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_TAB_CLASSES;
InitCommonControlsEx(&icex);

// Create tab control
g_hWndTabs = CreateWindow(WC_TABCONTROL, L"",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | TCS_SINGLELINE,
0, 0, 800, 600,
g_hWndMain, nullptr, currentInstance, nullptr);

if (g_hWndTabs == NULL) {
return 0;
}

// Add tabs to tab control, seperate tab later
TCITEM tcitem;
tcitem.mask = TCIF_TEXT;

wchar_t buf1[] = L"Table View";
tcitem.pszText = buf1;
TabCtrl_InsertItem(g_hWndTabs, 0, &tcitem);

wchar_t buf2[] = L"Text Files";
tcitem.pszText = buf2;
TabCtrl_InsertItem(g_hWndTabs, 1, &tcitem);

wchar_t buf3[] = L"mp4 Files";
tcitem.pszText = buf3;
TabCtrl_InsertItem(g_hWndTabs, 2, &tcitem);



//original location of button intitialisation


ShowWindow(g_hWndMain, SW_SHOWDEFAULT);
UpdateWindow(g_hWndMain);

MSG msg{};
while (GetMessage(&msg, nullptr, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}


I severely doubt my code has anything to do with the issue though. It's probably directory-based. I just placed wWinmain here to keep with the character limit.

不过,我严重怀疑我的代码与这个问题有任何关系。它可能是基于目录的。我把wWinmain放在这里只是为了符合字符限制。


The .h files can't find each other
The file path for the FFmpeg files


更多回答

It doesn't matter where you put the header files (although Program Files is a pretty poor choice). What matters is that you tell your compiler where you have put them. In Visual Studio this means editing the project settings and adding locations to 'Additional Include Directories'.

将头文件放在哪里并不重要(尽管Program Files是一个非常糟糕的选择)。重要的是你要告诉你的编译器你把它们放在哪里了。在Visual Studio中,这意味着编辑项目设置并将位置添加到“其他包含目录”。

Also not this, #include <C:\\Program Files\\FFmpeg\\include\\libavformat\\avformat.h>, it should be #include <avformat.h> Tell the compiler where the header files are, that will solve all your header file problems.

也不是这样,#INCLUDE,它应该是#INCLUDE告诉编译器头文件在哪里,这将解决所有的头文件问题。

I tried doing something similar to this ( though I never noticed a field called additional include directories ) In additional library directories, I tried adding the path to FFmpeg & then including the .h files & .lib files. Though for some reason, this seemed to cause the windows.h library not to get recognised even though it’s declared on the first line. Also, I still think there may e an error with the directory Ffmpeg is placed in or it’s file name, as Ffmpeg would have a specific directory location for it’s headers right? Also, where should I put FFmpeg, if not Program Files? @john

我尝试在其他库目录中执行与此类似的操作(尽管我从未注意到一个称为附加包含目录的字段),我尝试将路径添加到FFmpeg&然后包括.h文件和.lib文件。尽管出于某种原因,这似乎导致windows.h库不被识别,即使它在第一行中被声明。另外,我仍然认为可能是Ffmpeg所在的目录或它的文件名有错误,因为Ffmpeg会有一个特定的目录位置作为它的头,对吗?另外,如果不是Program Files,我应该把FFmpeg放在哪里?@John

You add the directory containing the header files not the header file name. Not sure why that would give you problems with windows.h

添加的目录包含头文件,而不是头文件名。我不确定为什么这会给您的Windows带来问题。

Never mind, I added the wrong directory path & I was placing the path to the include folder in the additional library directories filed for the linker not the additional include directories under the C/C++ section

没关系,我添加了错误的目录路径&我将Include文件夹的路径放在链接器的其他库目录中,而不是C/C++部分下的其他Include目录中

优秀答案推荐
更多回答

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com