使用Qt Creator作为Linux IDE,实现Redis源码编译和断点调试(2)

7、编译通过,运行会报错:


09:26:00: Starting /root/Downloads/nginx/nginx-1.12.2/build-nginxQtProject_firecat-Desktop_Qt_5_9_7_GCC_64bit-Debug/nginx...

nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (2: No such file or directory)

2018/11/04 09:26:00 [emerg] 13081#0: open() "/usr/local/nginx/conf/nginx.conf" failed (2: No such file or directory)

09:26:00: /root/Downloads/nginx/nginx-1.12.2/build-nginxQtProject_firecat-Desktop_Qt_5_9_7_GCC_64bit-Debug/nginx exited with code 1


解决办法:手动新建/usr/local/nginx/logs和conf路径,把配置文件拷贝过来。


另外,html文件夹(里面有两个文件)也记得拷贝到/usr/local/nginx/路径下。



8、我们终于可以执行断点调试,大功告成!

使用Qt Creator作为Linux IDE,实现Redis源码编译和断点调试(2)



nginx启动之后,在浏览器输入http://localhost/,即可看到index.html网页。



9、附录:完整的Qt工程源码下载


https://download.csdn.net/download/libaineu2004/10763167



---


参考文献:https://blog.csdn.net/zileqide/article/details/76736668


查看nginx是否启动成功


netstat -lnpt | grep nginx


或者ps -ef |grep nginx 查看nginx进程是否启动


或者netstat -nalp|grep 80 查看80端口的进程


终止nginx

kill -9 <nginx进程号>(一般有2~3个进程,通过netstat -lnpt | grep nginx命令可以查询进程号)


例如kill -9 36533


2、源码准备


使用黄建宏的带中文注释的版本,https://github.com/huangz1990/redis-3.0-annotated


我们解压源码,先使用gcc编译,主要目的是把deps库编译出来


[root@localhost redis_study]# chmod -R 777 redis-3.0-annotated-unstable

[root@localhost redis_study]# cd redis-3.0-annotated-unstable/

[root@localhost redis-3.0-annotated-unstable]# make

3、和nginx源码不同,redis的结构更复杂,因为nginx的编译结果是单一的执行文件,而redis会生成N多个执行文件:


redis-server


redis-cli


redis-benchmark


redis-check-aof


redis-check-dump


redis-sentinel


所以,我们新建的Qt Creator必须是多个子项目类型:

使用Qt Creator作为Linux IDE,实现Redis源码编译和断点调试(2)



4、redisQtProject.pro,firecat这里只关注最主要的redis-server和redis-cli两个执行程序


TEMPLATE = subdirs

CONFIG += ordered

SUBDIRS += \

   redis-server \

   redis-cli

common.pri,因为前面已经把deps的库编译好了,这里只需要添加库依赖即可

 
isEmpty(PREFIX_SRC) {
    PREFIX_SRC = ../../src
}
 
isEmpty(PREFIX_DEPS) {
    PREFIX_DEPS = ../../deps
}
 
LIBS = -ldl -lpthread -lcrypt -lpcre -lz
LIBS += "$$PREFIX_DEPS/hiredis/libhiredis.a"
LIBS += "$$PREFIX_DEPS/lua/src/liblua.a"
 
INCLUDEPATH += \
    #$$PREFIX_SRC/ \
    $$PREFIX_DEPS/hiredis \
    #$$PREFIX_DEPS/hiredis/adapters \
    $$PREFIX_DEPS/jemalloc/include/ \
    $$PREFIX_DEPS/jemalloc/include/jemalloc/internal \
    #$$PREFIX_DEPS/jemalloc/include/msvc_compat \
    $$PREFIX_DEPS/linenoise \
    $$PREFIX_DEPS/lua/src \
    $$PREFIX_DEPS/lua/etc
 
HEADERS += \
    $$PREFIX_SRC/adlist.h \
    $$PREFIX_SRC/ae.h \
    $$PREFIX_SRC/anet.h \
    $$PREFIX_SRC/asciilogo.h \
    $$PREFIX_SRC/bio.h \
    $$PREFIX_SRC/cluster.h \
    $$PREFIX_SRC/config.h \
    $$PREFIX_SRC/crc64.h \
    $$PREFIX_SRC/dict.h \
    $$PREFIX_SRC/endianconv.h \
    $$PREFIX_SRC/fmacros.h \
    $$PREFIX_SRC/help.h \
    $$PREFIX_SRC/intset.h \
    $$PREFIX_SRC/lzf.h \
    $$PREFIX_SRC/lzfP.h \
    $$PREFIX_SRC/pqsort.h \
    $$PREFIX_SRC/rand.h \
    $$PREFIX_SRC/rdb.h \
    $$PREFIX_SRC/redis.h \
    $$PREFIX_SRC/redisassert.h \
    $$PREFIX_SRC/release.h \
    $$PREFIX_SRC/rio.h \
    $$PREFIX_SRC/sds.h \
    $$PREFIX_SRC/sha1.h \
    $$PREFIX_SRC/slowlog.h \
    $$PREFIX_SRC/solarisfixes.h \
    $$PREFIX_SRC/testhelp.h \
    $$PREFIX_SRC/util.h \
    $$PREFIX_SRC/version.h \
    $$PREFIX_SRC/ziplist.h \
    $$PREFIX_SRC/zipmap.h \
    $$PREFIX_SRC/zmalloc.h \
    $$PREFIX_DEPS/linenoise/linenoise.h

redis-server.pro

TARGET = redis-server
 
include(../common.pri)
 
SOURCES += \
    $$PREFIX_SRC/adlist.c \
    $$PREFIX_SRC/ae.c \
    $$PREFIX_SRC/ae_epoll.c \
    $$PREFIX_SRC/ae_evport.c \
    $$PREFIX_SRC/ae_kqueue.c \
    $$PREFIX_SRC/ae_select.c \
    $$PREFIX_SRC/anet.c \
    $$PREFIX_SRC/aof.c \
    $$PREFIX_SRC/bio.c \
    $$PREFIX_SRC/bitops.c \
    $$PREFIX_SRC/blocked.c \
    $$PREFIX_SRC/cluster.c \
    $$PREFIX_SRC/config.c \
    $$PREFIX_SRC/crc16.c \
    $$PREFIX_SRC/crc64.c \
    $$PREFIX_SRC/db.c \
    $$PREFIX_SRC/debug.c \
    $$PREFIX_SRC/dict.c \
    $$PREFIX_SRC/endianconv.c \
    $$PREFIX_SRC/hyperloglog.c \
    $$PREFIX_SRC/intset.c \
    $$PREFIX_SRC/lzf_c.c \
    $$PREFIX_SRC/lzf_d.c \
    $$PREFIX_SRC/memtest.c \
    $$PREFIX_SRC/multi.c \
    $$PREFIX_SRC/networking.c \
    $$PREFIX_SRC/notify.c \
    $$PREFIX_SRC/object.c \
    $$PREFIX_SRC/pqsort.c \
    $$PREFIX_SRC/pubsub.c \
    $$PREFIX_SRC/rand.c \
    $$PREFIX_SRC/rdb.c \
    #$$PREFIX_SRC/redis-benchmark.c \
    #$$PREFIX_SRC/redis-check-aof.c \
    #$$PREFIX_SRC/redis-check-dump.c \
    #$$PREFIX_SRC/redis-cli.c \
    #$$PREFIX_SRC/redis.c \
    $$PREFIX_SRC/release.c \
    $$PREFIX_SRC/replication.c \
    $$PREFIX_SRC/rio.c \
    $$PREFIX_SRC/scripting.c \
    $$PREFIX_SRC/sds.c \
    $$PREFIX_SRC/sentinel.c \
    $$PREFIX_SRC/setproctitle.c \
    $$PREFIX_SRC/sha1.c \
    $$PREFIX_SRC/slowlog.c \
    $$PREFIX_SRC/sort.c \
    $$PREFIX_SRC/syncio.c \
    $$PREFIX_SRC/t_hash.c \
    $$PREFIX_SRC/t_list.c \
    $$PREFIX_SRC/t_set.c \
    $$PREFIX_SRC/t_string.c \
    $$PREFIX_SRC/t_zset.c \
    $$PREFIX_SRC/util.c \
    $$PREFIX_SRC/ziplist.c \
    $$PREFIX_SRC/zipmap.c \
    $$PREFIX_SRC/zmalloc.c \
    $$PREFIX_DEPS/linenoise/linenoise.c
 
SOURCES += \
    $$PREFIX_SRC/redis.c


redis-cli.pro文件类似,这里不再赘述。


5、我们终于可以执行断点调试,大功告成!

使用Qt Creator作为Linux IDE,实现Redis源码编译和断点调试(2)



6、附录:完整的Qt工程源码下载


https://download.csdn.net/download/libaineu2004/10763933






上一篇:DispactherServlet请求流程解析(一)


下一篇:C语言编译流程