当前位置:网站首页>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
边栏推荐
- The table ‘table_ Name 'is full exception troubleshooting and solution
- Cannot retrieve repository metadata processing records
- 产品-Axure9(英文版),中继器(Repeater)实现表格内容的增删查改(CRUD)
- CentOS 7.5 install MySQL 8.0.27---yum
- Data-* attribute usage
- 2. how to install MySQL database in Galaxy Kirin offline mode
- Machine learning 8-artificial neural network
- 《安富莱嵌入式周报》第271期:2022.06.20--2022.06.26
- 面试题 10.10. 数字流的秩
- Shandong University project training (VI) Click event display line chart
猜你喜欢

Cannot retrieve repository metadata processing records

Cannot retrieve repository metadata 处理记录

Anfulai embedded weekly report no. 271: June 20, 2022 to June 26, 2022

About microservices

JWT login authentication

Understanding of strong caching and negotiation caching

How to use idea?

The 8th "Internet +" competition - cloud native track invites you to challenge

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

防汛救援便携式应急通信系统解决方案
随机推荐
信息系统项目管理师---第七章项目成本管理历年考题
WBF: new method of NMS post filter frame for detection task?
【日常训练】535. TinyURL 的加密与解密
[tcapulusdb knowledge base] tcapulusdb doc acceptance - create business introduction
Machine learning 7-Support vector machine
Us judge ruled that the former security director of Uber accused of covering up hacking must face fraud charges
2. add customized related files to the keil5 project established by stm32cubemx
JDBC knowledge
对强缓存和协商缓存的理解
剑指 Offer 34. 二叉树中和为某一值的路径-dfs法
The 8th "Internet +" competition - cloud native track invites you to challenge
金鱼哥RHCA回忆录:DO447构建高级作业工作流--创建工作流作业模板并启动工作流作业
JS text particle dynamic background
Data-* attribute usage
C Primer Plus 第12章_存储类别、链接和内存管理_代码和练习题
如何在树莓派上使用OAK相机?
curl下载示例
Adobe Premiere基础-不透明度(蒙版)(十一)
MySQL -connector/j driver download
保持jupyter notebook在终端关闭时的连接方法