Install bare metal Linux dual booting with Windows

Installing Fedora is very straight forward, but

  • When clicking some avi suffix video file, I was prompted a GStreamer page, but no link to install missing plugins.

However I learnt

  • One disk must have its own EFI partition. For nowaday notebook usually has an SSD and an HDD, while SSD already has an EFI partition, when we have to install the second OS in HDD, the HDD must allocate an EFI partition too.
  • When we burn OS iso image into U-disk using UltraIso tool, we must select "RAW" mode, not others like "HDD+" mode.

'vboxdrv': Key was rejected by service

sudo dnf update
sudo dnf install mokutil

mkdir /root/signed-modules
cd /root/signed-modules
openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=VirtualBox/"
chmod 600 MOK.priv

mokutil --import MOK.der

#After rebooting system

for modfile in $(dirname $(modinfo -n vboxdrv))/*.ko; do
  echo "Signing $modfile"
  /usr/src/kernels/$(uname -r)/scripts/sign-file sha256 \
                                /root/signed-modules/MOK.priv \
                                /root/signed-modules/MOK.der "$modfile"
done

To play avi, rmvb files and so on,

dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
dnf install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
dnf install vlc

Not set default editor to nano in cscope,

cd /etc/profile.d
mv nano-default-editor.sh nano-default-editor.sh0

No sound?

vi /etc/pulse/default.pa
	load-module module-alsa-sink device=dmix
	load-module module-alsa-source device=dsnoop
reboot

This method doesn't go very well, but I know the reason, I had replaced pipewire with pulseaudio while pipewire is the next generation.

Update grub,

grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

refer to:
https://www.tecmint.com/install-vmware-workstation-in-linux/
https://stackoverflow.com/questions/61248315/sign-virtual-box-modules-vboxdrv-vboxnetflt-vboxnetadp-vboxpci-centos-8
https://www.videolan.org/vlc/download-fedora.html
https://blog.csdn.net/weixin_41446370/article/details/116711350
http://blog.sina.com.cn/s/blog_628ba3e00102xvnk.html
https://blog.csdn.net/wujuncheng1996/article/details/83546929
https://mirror.tuna.tsinghua.edu.cn/help/rpmfusion/

video_tdr_failure nvlddmkm.sys

不一定是显卡烧了。不要用Windows Update安装显卡驱动。

先彻底将显卡驱动卸载干净。右键点击“此电脑” -> “管理” -> “设备管理器” -> “显示适配器” -> 右键点击“NVIDIA GeForce XXX” -> “卸载设备” -> 勾选“尝试删除此设备的驱动程序” -> “卸载”。

再到英伟达官网下载英文版驱动安装:

https://www.nvidia.com/download/index.aspx?lang=en-us

我的配置是1050 Ti, ok, it's already cost me an arm and a leg.
下载的驱动名是
511.23-notebook-win10-win11-64bit-international-dch-whql.exe
安装后至今没出现什么问题。

另外,确定蓝屏原因的方法:

  1. 启动 windbg,菜单file -> symbol file path输入:

    1
    
    SRV*c:\temp*http://msdl.microsoft.com/download/symbols

    然后确定。

  2. windbg菜单file -> open crash dump,选择C:\Windows\MEMORY.DMP后,等待

    1
    
    Use !analyze -v to get detailed debugging information...

    字样出现后,点击“!analyze -v”超链接,可看到nvlddmkm.sys出现,说明是显卡驱动那里崩了。

确定蓝屏DUMP文件路径的方法:

右键点击“此电脑” -> “属性” -> “高级系统设置” -> “高级” -> “启动和故障恢复”中“设置” -> “写入调试信息”……

refer to:
https://social.technet.microsoft.com/Forums/windows/th-TH/f2212753-9cf5-4659-9c55-258329b0ff48/31995324793401323631?forum=vistazhchs

ue4 memo

Terms,

1
2
3
4
5
6
7
8
9
10
11
12
XGE
RHI: Render Hardware Interface
IncrediBuild
fastbuild
反射系统
蓝图系统
UBT: Unreal Build Tool
UHT: Unreal Heading Tool
CDO: Class Default Object
NM: Net Mode
LLM: Low Level Mem
GEngineIni: ThirdPerson01/Saved/Config/Windows/Engine.ini

Apis

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, FString::Printf(TEXT("Hello, %s."), TEXT("Euhat")));
 
TRACE_OBJECT_EVEN
UE_TRACE_CHANNELEXPR_IS_ENABLED(ObjectChannel)
 
FD3D11DynamicRHI::RHIBeginFrame
 
UWorld
	PlayerControllerList
		PlayerController_0
			AGameplayDebuggerCategoryReplicator
	for (ULevel* Level : InWorld->GetLevels())
		Level->Actors
			WorldInfo_0			{AWorldSettings}
			Brush_0				{ABrush}
			LightmassImportanceVolume_0	{ALightmassImportanceVolume}
			AtmosphericFog_1		{AAtmosphericFog}
			SkySphereBlueprint		AActor *
			SphereReflectionCapture		{ASphereReflectionCapture}
			NetworkPlayerStart		{APlayerStart}
			DocumentationActor1		{ADocumentationActor}
			Linear_Stair_StaticMesh		{AStaticMeshActor}
			Bump_StaticMesh			{AStaticMeshActor}
			LeftArm_StaticMesh		{AStaticMeshActor}
			RightArm_StaticMesh		{AStaticMeshActor}
			Ramp_StaticMesh			{AStaticMeshActor}
			CubeMesh_5			{AStaticMeshActor}
			LightSource_0			{ADirectionalLight}
			PostProcessVolume_0		{APostProcessVolume}
			SkyLight_0			{ASkyLight}
			Floor_1				{AStaticMeshActor}
			Wall7_4				{AStaticMeshActor}
			Wall9				{AStaticMeshActor}
			Wall10				{AStaticMeshActor}
			Wall11				{AStaticMeshActor}
			TextRenderActor_1		{ATextRenderActor}
			AMyActor_9			{UE4Editor-ThirdPerson01-0013-Win64-Debug.dll!AAMyActor}
			DefaultPhysicsVolume_0		{ADefaultPhysicsVolume}
			GameplayDebuggerPlayerManager_0	{UE4Editor-GameplayDebugger-Win64-Debug.dll!AGameplayDebuggerPlayerManager}
			ThirdPersonGameMode_C_0		{AGameModeBase}
			GameSession_0			{AGameSession}
			ParticleEventManager_0		{AParticleEventManager}
			GameNetworkManager_0		{AGameNetworkManager}
			ThirdPersonCharacter_167	{ACharacter}
			ThirdPersonExampleMap_C_0	{ALevelScriptActor}
			GameStateBase_0			{AGameStateBase}
			AbstractNavData-Default		{UE4Editor-NavigationSystem-Win64-Debug.dll!AAbstractNavData}
			PlayerController_0		{APlayerController}
			PlayerState_0			{APlayerState}
			PlayerCameraManager_0		{APlayerCameraManager}
			CameraActor_0			{ACameraActor}
			HUD_0				{AHUD}
 
AActor
	RootComponent
	OwnedComponents : TSet<UActorComponent*>
	InstanceComponents 
	Children
 
UActorComponent
	OnRegister
	CreateRenderState
	OnCreatePhysicsState
	OnUnregister
	DestroyRenderState
	OnDestroyPhysicsState
	TickComponent
	PrimaryComponentTick.bCanEverTick
	PrimaryComponentTick.SetTickFunctionEnable(true)
	MarkRenderStateDirty
 
USceneComponent : UActorComponent
	SetupAttachment
	AttachToComponent
 
	FTransform
 
UPrimitiveComponent : USceneComponent
	ShouldCreatePhysicsState
 
	Box Component
	Capsule Component
	Mesh Component
	Skeletal Mesh Component
 
UDrawFrustumComponent : UPrimitiveComponent

stat

1
2
3
stat unit
stat SceneRendering
stat gpu

LineTraceSingle

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void AMyCharacter::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
 
	const float TRACE_LINE_LENGTH = 1000.0f;
	FRotator actorRotator = GetActorRotation();
	const FRotator YawRotation(0, actorRotator.Yaw, 0);
	const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
	FVector lineStartPos = GetActorLocation();
	FVector lineEndPos = lineStartPos + TRACE_LINE_LENGTH * Direction;
	TArray<AActor*> arrayIgnoreActor;
	FHitResult outResult;
	if (UKismetSystemLibrary::LineTraceSingle(GetWorld(), lineStartPos, lineEndPos, 
			ETraceTypeQuery::TraceTypeQuery1, true, arrayIgnoreActor, 
			EDrawDebugTrace::ForDuration, outResult, true, 
			FLinearColor::Red, FLinearColor::Green, 0.1f))
	{
		FString locationString = outResult.Location.ToString();
		UE_LOG111(LogTemp, Error, TEXT("location = %s"), *locationString);
	}
}

refer to:
https://www.cnblogs.com/fjz13/p/5956393.html
https://blog.csdn.net/qq_29523119/article/details/85957072

unicode in ctex

在英文Windows中,特别是使用了“用utf8提供全球语言支持”时,系统会把所有保存为GBK的api忽略掉,此时CTex只会识别utf8的文档,而utf16不会被编译识别。

同时在tex文件头部documentclass后要申明本文档为utf8格式。

%!Mode:: "TeX:UTF-8"
\documentclass[UTF8]{article}
\usepackage{CTEX}
\begin{document}
这是一个CTEX的utf-8编码例子,{\kaishu 这里是楷体显示},{\songti 这里是宋体显示},{\heiti 这里是黑体显示},{\fangsong 这里是仿宋显示},{\lishu 这里是隶书显示},{\youyuan 这里是幼圆显示}。
\end{document}

refer to:
冰原狼
https://www.pianshen.com/article/97651577419/

debug ue4 completely

The default "Debug Editor" mode will produce a beast of UE4Editor that we can't debug it thoroughly, for vs2022 needs over 10G memory to load relative pdbs and retrieve debug information, eventually our computer is over burden, and vs2022 corrupts, so we never so much as trigger a debug point.

After several mends, vs2022 IDE still corrupts at beginning of debugging, so we have to seek help from WinDbg or QtCreator.

There are two main causes why UE4Editor is so big:

  • The original build tool action is 'Modular' which generates many dlls and every dll contains a portion of the same low level library code. So we change the action to 'Monolithic':

    ue\Engine\Source\Programs\UnrealBuildTool\Configuration\TargetRules.cs

    ...
    		public TargetLinkType LinkType
    		{
    			get
    			{
    //				return (LinkTypePrivate != TargetLinkType.Default) ? LinkTypePrivate : ((Type == global::UnrealBuildTool.TargetType.Editor) ? TargetLinkType.Modular : TargetLinkType.Monolithic);
    				return (LinkTypePrivate != TargetLinkType.Default) ? LinkTypePrivate : ((Type == global::UnrealBuildTool.TargetType.Editor) ? TargetLinkType.Monolithic : TargetLinkType.Monolithic);
    			}
    			set
    			{
    				LinkTypePrivate = value;
    			}
    		}
    ...
    

    But I have tried building in monolithic mode, it's a suicide, literately, there are many duplicated symbols generated which fail the building. We have to return to modular mode.

  • Every call on logging macro carves '__FILE__' or '__FUNCTION__' in the binary which will also inflate the executable. So we change these macros to nonsense:

    ue\Engine\Source\Runtime\Core\Public\Misc\Build.h

    ...
    #define EUHAT_MINIMIZE 1
    
    #if UE_BUILD_DEBUG
    #if EUHAT_MINIMIZE
    	#ifndef DO_GUARD_SLOW
    		#define DO_GUARD_SLOW			0
    	#endif
    	#ifndef DO_CHECK
    		#define DO_CHECK			0
    	#endif
    	#ifndef DO_ENSURE
    		#define DO_ENSURE			0
    	#endif
    	#ifndef STATS
    		#define STATS				((WITH_UNREAL_DEVELOPER_TOOLS || !WITH_EDITORONLY_DATA || USE_STATS_WITHOUT_ENGINE || USE_MALLOC_PROFILER || FORCE_USE_STATS) && !ENABLE_STATNAMEDEVENTS)
    	#endif
    	#ifndef ALLOW_DEBUG_FILES
    		#define ALLOW_DEBUG_FILES		1
    	#endif
    	#ifndef ALLOW_CONSOLE
    		#define ALLOW_CONSOLE			0
    	#endif
    	#ifndef NO_LOGGING
    		#define NO_LOGGING			0
    	#endif
    #else
    	#ifndef DO_GUARD_SLOW
    ...
    

    We should notice NO_LOGGING is false, I attempted to set it true, but a lot of errors occured.

    At the end of ueDbg\Engine\Source\Runtime\Core\Public\Logging\LogMacros.h

    ...
    #if EUHAT_MINIMIZE
    	#undef UE_LOG
    	#undef UE_LOG_CLINKAGE
    	#undef UE_CLOG
    	#undef UE_SUPPRESS
    	#undef UE_SECURITY_LOG
    
    	#define UE_LOG(CategoryName, Verbosity, Format, ...) 
    	#define UE_LOG_CLINKAGE(CategoryName, Verbosity, Format, ...) 
    	#define UE_CLOG(Condition, CategoryName, Verbosity, Format, ...) 
    	#define UE_SUPPRESS(...) {}
    	#define UE_SECURITY_LOG(...)
    #endif
    

And if we wanna debug inline functions, modify this place:

ue\Engine\Saved\UnrealBuildTool\BuildConfiguration.xml

<?xml version="1.0" encoding="utf-8" ?>
<Configuration xmlns="https://www.unrealengine.com/BuildConfiguration">
	<BuildConfiguration>
		<bAllowXGE>true</bAllowXGE>
		<bUseInlining>0</bUseInlining>
	</BuildConfiguration>
</Configuration>

'bAllowXGE' means to turn on IncreBuild, while the prerequisite is we have very big memory.

There are still some nasty things to do:

  1. Invoking empty macro is considered as a warning 4390, existing unused variables is considered as warning 4101, they will cease ue4 compilation.

    ue\Engine\Source\Runtime\Core\Public\Windows\WindowsPlatformCompilerSetup.h

    #pragma warning (error: 4100      4102 4103                          4109           4112 4113 4114 4115 4116 4117      4119 4120 4121 4122 4123 4124 4125      4127      4129 4130 4131 4132 4133                4137 4138           4141 4142 4143 4144 4145 4146                4150      4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164      4166 4167 4168                4172      4174 4175 4176 4177 4178 4179 4180 4181 4182 4183      4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197      4199)
    
    #pragma warning (error:      4301 4302 4303           4306      4308 4309 4310           4313 4314 4315 4316      4318 4319      4321 4322 4323 4324 4325 4326 4327 4328 4329 4330           4333 4334 4335 4336 4337 4338      4340           4343 4344      4346      4348                4352 4353      4355 4356 4357 4358 4359           4362      4364      4366 4367 4368 4369                     4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384           4387      4389      4391 4392 4393 4394 4395 4396 4397 4398 4399)
    

    ue\Engine\Source\Programs\UnrealBuildTool\Platform\Windows\VCToolChain.cs

    ...
    			// Set warning level.
    			if (Target.WindowsPlatform.Compiler != WindowsCompiler.Intel)
    			{
    				// Restrictive during regular compilation.
    				// Euhat Modified
    				//Arguments.Add("/W4");
    				Arguments.Add("/wd4101");
    				Arguments.Add("/W0");
    			}
    ...
    			// Prevents the linker from displaying its logo for each invocation.
    			Arguments.Add("/NOLOGO");
    			// Euhat modified
    			Arguments.Add("/FORCE:MULTIPLE");
    ...
    

    'FORCE:MULTIPLE' means just to pick the first one of the same name symbols instead of complaining as a link error.

  2. ue\Engine\Plugins\Slate\SlateInsights\Source\SlateInsights\Private\SlateInsightsModule.cpp

    //IMPLEMENT_MODULE((UE::SlateInsights::FSlateInsightsModule), SlateInsights);
    
  3. ue\Engine\Source\Runtime\AudioMixer\Public\AudioMixerDevice.h

    		// make it public
    		FAudioPlatformDeviceInfo PlatformInfo;
    

    ue\Engine\Plugins\Media\BinkMedia\Source\BinkMediaPlayer\Private\BinkMediaPlayerPCH.h

    ...
    			//return mix->GetNumDeviceChannels();
    			return mix->PlatformInfo.NumChannels;
    ...
    //DECLARE_LOG_CATEGORY_EXTERN(LogBink, Log, All);
    ...
    

    ue\Engine\Plugins\Media\BinkMedia\Source\BinkMediaPlayer\Private\BinkMediaPlayerModule.cpp

    //DEFINE_LOG_CATEGORY(LogBink);
    
  4. ue\Engine\Plugins\Runtime\AR\Microsoft\HoloLensAR\Source\HoloLensTargetPlatform\HoloLensTargetPlatform.Build.cs

    bEnableUndefinedIdentifierWarnings = false;
    

The last thing kept in mind is don't build the whole resolution, for simultaneous compilations of projects can easily run out of memory. Just right click Engine/EU4 and build UE4Editor only.

ps: We use UnrealEngine-4.27.2-release.zip in this article.

build qt source in vs2022 win11

Don't download qt source in tar.xz format, for in Windows, if we unzip it using 7zip, some deep file paths may be truncated, for example, ECMFindModuleHelpersStub.cmake referred by FindEGL.cmake in qtbase\cmake\3rdparty\extra-cmake-modules\find-modules.

This time I download qt-everywhere-src-6.2.2.zip.

In preparation, as to README.md, ActivePerl must be installed, it sucks, we must have an account of it. However, we can find another perl alternative, Strawberry Perl portable edition.

When we build, qt source root path should be short enough like d:\qt.

bld.bat

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
set curpath=%CD%
set vspath=D:\cext\Program Files\Microsoft Visual Studio\2022\Enterprise
set perlpath=D:\work\open\strawberry-perl-5.32.1.1\perl\bin
set clangpath=D:\work\open\libclang
set installpath=D:\cext\Qt
 
call "%vspath%\VC\Auxiliary\Build\vcvars64.bat"
 
set oldpath=%path%
set path=%path%;%perlpath%
 
if not exist %curpath%\bld @mkdir %curpath%\bld
 
cd %curpath%\bld
 
cmake.exe ^
	-G "Ninja" ^
	-DCMAKE_INSTALL_PREFIX:PATH=%curpath%\bld ^
	-DCMAKE_BUILD_TYPE="Debug" ^
	-DFEATURE_clang="ON" ^
	-DCMAKE_PREFIX_PATH="%clangpath%" ^
	-DCMAKE_MAKE_PROGRAM="%vspath%\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" ..
 
cmake --build . --parallel
rem cmake --install . --prefix %installpath%
 
if 0 == 1 (
	rem if we build QtDoc, we must add clang path to system path, otherwise we will get exit code 0xc0000135.
	set path=%path%;%clangpath%\bin
	cmake --build . --target docs
)
 
set path=%oldpath%
cd ..

Modify paths at the beginning of above bld.bat and put the batch file in the qt source root directory, then execute it.

ps1: all in one release of qt is like below url, but we should know all in one is not available since Qt 5.15.
http://download.qt.io/archive/qt/5.9/5.9.2/qt-opensource-linux-x64-5.9.2.run
And we need download online installer for Qt above 5.15 if we don't want to build from scratch:
https://download.qt.io/official_releases/online_installers/

Refer to:
https://ninja-build.org/
https://strawberryperl.com/releases.html
https://github.com/Kitware/CMake/releases/download/v3.22.1/cmake-3.22.1-windows-x86_64.msi

https://download.qt.io/development_releases/prebuilt/libclang/
https://download.qt.io/archive/qt/6.2/6.2.2/single/qt-everywhere-src-6.2.2.zip
https://download.qt.io/official_releases/qtcreator/6.0/6.0.1/qt-creator-opensource-windows-x86_64-6.0.1.exe

https://stackoverflow.com/questions/14807294/how-to-install-cmake-c-compiler-and-cxx-compiler
https://www.cnblogs.com/gearslogy/p/7435202.html

custom widget in qt

TstUsrCtrl.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#pragma once
 
#include <qwidget>
 
class TstUsrCtrl : public QWidget
{
	Q_OBJECT
 
	QPoint oldPos_;
	QPoint curPos_;
 
public:
	explicit TstUsrCtrl(QWidget *parent = nullptr);
	~TstUsrCtrl();
 
	void paintEvent(QPaintEvent* event);
	void mousePressEvent(QMouseEvent* event);
	void mouseMoveEvent(QMouseEvent* event);
	void mouseReleaseEvent(QMouseEvent* event);
	void mouseToPosition(QMouseEvent* event);
};
</qwidget>

Read more