当前位置:网站首页>Redis source code learning-01_ Debugging redis source code in clion

Redis source code learning-01_ Debugging redis source code in clion

2022-06-09 18:07:00 Galloping dung beetle

cygwin build

Cygwin It just provides something like Linux Environment , There are still some differences in actual use . But it can meet our basic needs .

download

Official website address :https://cygwin.com/install.html
 Insert picture description here

install

  1. Choose default

 Insert picture description here

  1. Select the installation directory , Click next ;

 Insert picture description here

  1. choice “direct connection( Direct connection )“; If you have an agent , Please select the corresponding setting ;

 Insert picture description here

4. Select the image station to download and install online , Change to domestic image source :http://mirrors.163.com/cygwin/
 Insert picture description here

  1. In this step , Select the package you want to install ;

Select the package to be installed :gcc-core、gcc-g++、make、gdb、binutils
 Insert picture description here

As shown in the figure

 Insert picture description here

  1. Click next to start the installation , And wait for the installation , The installation time depends on the network speed and the selected package ;

 Insert picture description here

  1. Waiting for completion
     Insert picture description here

Clion To configure

In fact, just open Clion It will automatically find Cmake,c Compiler environment for , But you still need to set it manually after finding it , Set the entrance at setting Medium toolchian in
 Insert picture description here

clone redis Code

Source code address :https://gitee.com/gy297879328/redis_3.0_study

After opening the project , Everyone should pay attention to the above CMakeList.txt, among , We have been configured with several by default target:
 Insert picture description here

among , Libraries should not run independently , We can run the following three , among :

  • redis-cli,redis client
  • redis-server, Server side
  • redis-example, I added this myself , Mainly hope : It can be like java In the , Start a main Method , To test some tools or something , otherwise , You have to write redis-server In the code of , And then use redis-cli To visit , To trigger our test code . It is mainly similar to an entrance for testing .

redis-example, Let me say a little more , If you look carefully, CmakeList.txt, Maybe I understand :
 Insert picture description here

How to debug

take redis-example give an example :
 Insert picture description here

But the debug, There is a problem , It's a separate meeting cmd window , Not directly Console Medium output ;printf There are also some problems .

however , Use run Way to run , There is no problem .
 Insert picture description here

appendix

Can't find cygwin1.dll

Need from window Entrance access , When you double-click it to execute, it will report missing cywin Error of , Here's a temporary solution ,
That is to go to Cygwin Of bin Directory cygwin1.dll, At this point, if you put it in the gang redis-cli The catalog of , You will find Clion Fail to compile ,
The solution is something else To build a execute The catalog of , hold redis-cli and cygwin1 Copy it all in , Then you can start playing happily redis The source
 Insert picture description here
 Insert picture description here

原网站

版权声明
本文为[Galloping dung beetle]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206091751493407.html