当前位置:网站首页>Using protobuf to link MySQL in unrealeengine plug-in
Using protobuf to link MySQL in unrealeengine plug-in
2022-06-29 18:53:00 【shuizhidaoniaaa】
UnrealEngine Used in plug-ins protobuf link mysql
This chapter completes the requirements : Complete the project plug-in , Can provide customized protobuf agreement
step : compile protobuf, New plug-in import protobuf Library and use , The project project calls the open interface of the plug-in
Get ready
First read the following official tutorial
Plug in creation and use best practices - Module and engine architecture
modular
Third party Library
Game module
matters needing attention
UE4 Debugging third-party libraries
The main points of
The module is UE4 The building blocks of . The engine is implemented as a collection of a large number of modules , The game provides its own modules to expand itself .
Module is through C# Declared by the source file , extension .build.cs
UE4 The compiler does not support the use of by default debug Version of the third-party library .( The default option can be changed )
The default generated runtime option is /MD, namely Multithreading Dll[/MD]. If the link library appears XXX Mismatches : value “0” Mismatch value “2”, Most of them are runtime version errors
Multithreading [/MT]:0
Multithreaded debugging [/MTd]:1
Multithreading DLL[/MD]:2
Multithreaded debugging DLL[/MDd]:3
A profound
Connect mysql library unreal Connect mysql
compile protobuf
Pit point :protobuf according to README It compiles lib Static library , Most online compilation tutorials are also /MT edition
reference protobuf compile
use cmake-gui Generate vs engineering , Note the options checked during generation ,runtime=off,test=off, shared_lib=on, Then compile and generate libprotobuf.dll that will do
Writing a plug-in
First write a simple plug-in , Skilled students can directly build the file hierarchy in the file manager , Write a document from scratch , Unskilled opening ue Editor ,Edit->Plugins->New Plugin->Blank Create an empty plug-in , I'm going to call it TestProtobuf. Run after the construction , Run through ok
stay Public New folder under folder Include,Library( convenience , Build everywhere ok), There is something missing in it
Add the following two lines to build.cs file . Note that the library is not copied to Binaries Under the folder , Not applicable to package release .
PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "Private", "Include"));
PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, "Private", "Library", "libprotobuf.lib"));
PS: The folder location has nothing to do with the actual private and public containment , Only for the sake of specification, private files are placed in Private Under the folder , Put the public in Public Under the folder . You can do it test: stay Public Under the folder , take protobuf Source code google Folders and generated pb.h The files are in the same directory , stay Build.cs Use... In the document PrivateIncludePaths.Add(), At this time, you can also compile
Pit point : Generated ph.h It's using <>, use PrivateInclude… after , If ph.cc And google Problems with the relative location of folders can cause a lot of trouble
Pit point : Sometimes external symbolic link errors will be reported after compilation , Characteristic is StartupModule Function error for . Because the export library should be in class Back plus PLUGINNAME_API, Otherwise, the plug-in will not be linked to . Keep in mind that modules compile into libraries
Here's something to do test, Class adds only one function
TestData.proto
syntax = "proto3";
message Account {
string name = 1; // Account name
string password = 2; // password
int32 loginType = 3; // Landing type ,0 register 1 land
}
class TESTPROTOBUF_API FTestProtobufModule : public IModuleInterface
{
public:
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
void SetAccount(const FString& name, const FString& password, const int32& loginType);
Account account;
};
void FTestProtobufModule::SetAccount(const FString& name, const FString& password, const int32& loginType)
{
account.set_name(TCHAR_TO_ANSI(*name));
account.set_password(TCHAR_TO_ANSI((*password)));
account.set_logintype(loginType);
}
test
At this point, the plug-in is written . Let's start with build.cs Import module inside . Here we use the above small test ox knife mysql Example , Test in the blueprint library
UCLASS()
class TESTPLUGIN_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category="MySQL")
static bool TestMySQL();
UFUNCTION(BlueprintCallable, Category="MySQL")
static void TestProtobuf();
};
void UMyBlueprintFunctionLibrary::TestProtobuf()
{
FTestProtobufModule ProtobufModule;
ProtobufModule.SetAccount("hui", "test", 0);
}
Pit point : If protobuf Library error , First think about whether there is reference protobuf compile , add to #define PROTOBUF_USE_DLLS
边栏推荐
- JDBC Codes connexes
- JS text particle dynamic background
- sql server备份以及还原的命令操作
- Shandong University project training (VII) add navigation bar to select city
- Machine learning 8-artificial neural network
- centos 7.5安装mysql 8.0.27----yum
- 【TcaplusDB知识库】TcaplusDB运维单据介绍
- Cannot retrieve repository metadata processing records
- How to use idea?
- Interview question 10.10 Rank of digital stream
猜你喜欢

Adobe Premiere基础-不透明度(蒙版)(十一)

markdown知识轻轻来袭
![报错[warning] Neural network inference was performed on socket ‘RGB’, depth frame is aligned to socket](/img/8a/ebad75daa581e22d50dddde49e1fac.jpg)
报错[warning] Neural network inference was performed on socket ‘RGB’, depth frame is aligned to socket

踩坑记:JSON.parse和JSON.stringify

Redis (I) -- getting started with redis (2) -- redis data type

mysql -connector/j驱动下载

数据仓库模型分层ODS、DWD、DWM实战

Know that Chuangyu has helped the energy industry in asset management and was selected into the 2021 IOT demonstration project of the Ministry of industry and information technology

Notes on spintronics - zhangshufeng

Adobe Premiere foundation - time remapping (10)
随机推荐
How to use the oak camera on raspberry pie?
面霸篇:MySQL六十六问,两万字+五十图详解!
[Nanjing University] information sharing of the first and second postgraduate entrance examinations
Svg circle drawing path animation
Sd6.23 summary of intensive training
Fastdfs
SD6.22集训总结
深度学习---三好学生各成绩所占权重问题(2)
数据仓库模型分层ODS、DWD、DWM实战
The table ‘table_ Name 'is full exception troubleshooting and solution
About microservices
Sister Juan takes you to learn database -- 5-day sprint Day1
Adobe Premiere Basics - common video effects (cropping, black and white, clip speed, mirroring, lens halo) (XV)
C Primer Plus Chapter 12_ Storage categories, links, and memory management_ Codes and exercises
Understanding of strong caching and negotiation caching
程序员资源推荐指南
Notes on spintronics - zhangshufeng
MySQL - clear data in the table
关于微服务
【TcaplusDB知识库】TcaplusDB运维单据介绍