当前位置:网站首页>UE4/5 无法打开文件“xxx.generated.h”(Cannot open file xxx.generated.h)的解决方法总结
UE4/5 无法打开文件“xxx.generated.h”(Cannot open file xxx.generated.h)的解决方法总结
2022-07-24 05:46:00 【零幺_】
无法打开xxx.generated.h 是UE 开发中常见的问题之一,有时很让人挠头。本文将总结笔者在实际开发中解决这类问题的各种方法,后续有新方法也会在这里添加。
方法一,删除Intermediate 文件夹,并重新生成
第一个解决方法是先删除Intermediate 文件夹,再使用uproject 文件生成VS 工程文件(Generate Visual Studio project files)。需要注意的是,Intermediate 文件夹不仅在主工程目录里有,在各个插件的目录下也有。xxx.h 文件属于哪个目录,我们就删除哪个目录下的Intermediate 文件夹。


我们知道,各种xxx.generated.h 是由UHT(Unreal Header Tool)生成的,并保存在Intermediate文件夹。删除Intermediate文件夹,UHT 会重新生成generated.h 文件。所以这种方法是有效的。
方法二,删除所有生成的文件,再重新生成
UE 工程目录中,有些文件和文件夹是由系统自动生成的。在下面两张图中,我们突出选中了这些文件,同样不要忘了插件里也有这些文件。


删除.vs文件夹、Binaries 文件夹、Intermediate 文件夹、Saved 文件夹、sln文件,不仅能解决xxx.generated.h 文件无法打开的问题,还能解决其他疑难杂症。但是需要注意的是,在删除Binaries 文件夹的时候,一定不要把里面用到的dll 等第三方库给删掉了,否则会出现下面的问题。

方法三:调整模块的依赖关系
如果插件里有多个模块,若没有正确设置这些模块的依赖关系,也会导致xxx.generated.h 无法打开的问题。如下图所示,假设同一个插件内,有两个模块AA 和BB,并且模块AA 依赖BB。如果在模块AA 的Build.cs 中没有设置对BB 的依赖(如下图中的左图所示),或者把对BB 的依赖写在PrivateDependencyModuleNames 里(如下图中的右图所示),也会导致这样的问题。


使用上面的两种设置,就会导致下面的“无法打开文件‘xxx.generated.h’”的问题,解决方法是在PublicDependencyModuleNames 中声明对模块BB 的依赖。这里说明一下PublicDependencyModuleNames 和PrivateDependencyModuleNames 的区别:依赖于模块AA 的其他模块,如主文件目录,只能访问到其PublicDependencyModuleNames 中暴露出来的模块,不能访问PrivateDependencyModuleNames 中声明的模块。

边栏推荐
- Experiment: disk quota operation
- 一个AI玩41个游戏,谷歌最新多游戏决策Transformer综合表现分是DQN的两倍
- Account and authority management
- Special effects - bubble tailing occurs when the mouse moves
- [lvgl layout] grid layout
- Explain the event cycle mechanism and differences between browser and node in detail
- JS - calculate the side length and angle of a right triangle
- Redis基本类型-结合Set
- 安装snownlp包过程出现Requirement already satisfied:及Read timed out.问题解决方法
- 今天聊赖数据库MySQL底层架构设计,你了解多少?
猜你喜欢

Experiment: disk quota operation

Process and planned task management

PyQt5入门——学生管理系统

Kubernetes rapid installation

Redis特殊数据类型-HyperLogLog

Detailed analysis of the process (life cycle) of class loading

kubernetes简介和架构及其原理

MapReduce(一)

Jenkins CI CD

Special effects - when the mouse moves, stars appear to trail
随机推荐
带你深入了解MySQL数据库扣减库存原理
Getting started with redis
String问题
Special effects - starry cosmic background effects
Experiment: disk quota operation
记录PHPSerializer工具类反序列化遇到的坑
DNS domain name resolution service
Secondary processing of template data
JS - mouse and keyboard configuration and browser forbidden operation
Redis.conf详解
[media controller] open source project learning notes (based on Arduino micro development board)
【波形/信号发生器】基于 STC1524K32S4 for C on Keil
Special effects - Cherry Blossom falling background effects
Kubernetes rapid installation
【LVGL(2)】LVGL入门,在CodeBlock上进行模拟以及移植STM32
【LVGL布局】柔性布局
神经网络超参数调整(基于ray包)
Redis分布式缓存学习笔记
Niuke net brush questions
System safety and Application