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

简介: 使用Qt Creator作为Linux IDE,实现Nginx源码编译和断点调试

1、前言


作者本人是桌面软件开发出身,由于以前被vs,qt以及eclipse等IDE宠坏了,导致对Linux vim使用不熟悉。于是我决定使用QtCreator,把nginx源码搞成Qt Creator工程,实现编译和断点调试。



2、环境准备


(1)安装Linux系统,例如CentOS 7,带GNOME桌面环境,gcc v4.8.5,http://mirror.centos.org/


yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel


yum -y install gcc gcc-c++ autoconf automake

yum -y install zlib zlib-devel openssl openssl-devel pcre-devel


yum -y install libGL libGL-devel


yum -y install mesa-libGL-devel mesa-libGLU-devel


yum -y install freeglut-devel


(2)安装qt-opensource-linux-x64-5.9.7.run,http://download.qt.io/official_releases/qt/


(3)使用源码nginx-1.12.2.tar.gz,http://nginx.org/download/


解压并配置nginx源码:

tar -xvf nginx-1.12.2.tar.gz


chmod -R 777 nginx-1.12.2

cd nginx-1.12.2

./configure


make #这个步骤可有可无,不过建议make,验证一下源码是否有效

上述步骤执行完后,在nginx-1.12.2目录下会生成objs文件夹,其中有我们后续会添加到qt工程中的代码文件,需要特别注意;



3、打开QtCreator,新建pro空工程


image.png



4、新建nginxQtProject工程,建立之后的文件夹情况如下,请关注nginxQtProject文件夹里面的.pro文件:


image.png



5、导入相关.c和.h文件


image.png



6、.pro文件清单如下,文件主要来源是src和objs文件夹,注释掉的是编译通不过的文件:

TARGET = nginx
LIBS = -ldl -lpthread -lcrypt -lpcre -lz
#LIBS = -lpthread -lcrypt -lpcre -lcrypto -lcrypto -lz
INCLUDEPATH += \
    ../src/core \
    ../src/event \
    ../src/event/modules \
    ../src/http \
    ../src/http/modules \
    #../src/mail \
    #../src/misc \
    ../src/os/unix \
    ../src/stream \
    ../objs
HEADERS += \
    ../src/core/nginx.h \
    ../src/core/ngx_array.h \
    ../src/core/ngx_buf.h \
    ../src/core/ngx_conf_file.h \
    ../src/core/ngx_config.h \
    ../src/core/ngx_connection.h \
    ../src/core/ngx_core.h \
    ../src/core/ngx_crc.h \
    ../src/core/ngx_crc32.h \
    ../src/core/ngx_crypt.h \
    ../src/core/ngx_cycle.h \
    ../src/core/ngx_file.h \
    ../src/core/ngx_hash.h \
    ../src/core/ngx_inet.h \
    ../src/core/ngx_list.h \
    ../src/core/ngx_log.h \
    ../src/core/ngx_md5.h \
    ../src/core/ngx_module.h \
    ../src/core/ngx_murmurhash.h \
    ../src/core/ngx_open_file_cache.h \
    ../src/core/ngx_palloc.h \
    ../src/core/ngx_parse.h \
    ../src/core/ngx_parse_time.h \
    ../src/core/ngx_proxy_protocol.h \
    ../src/core/ngx_queue.h \
    ../src/core/ngx_radix_tree.h \
    ../src/core/ngx_rbtree.h \
    ../src/core/ngx_regex.h \
    ../src/core/ngx_resolver.h \
    ../src/core/ngx_rwlock.h \
    ../src/core/ngx_sha1.h \
    ../src/core/ngx_shmtx.h \
    ../src/core/ngx_slab.h \
    ../src/core/ngx_string.h \
    ../src/core/ngx_syslog.h \
    #../src/core/ngx_thread_pool.h \
    ../src/core/ngx_times.h \
    ../src/event/ngx_event.h \
    ../src/event/ngx_event_connect.h \
    ../src/event/ngx_event_openssl.h \
    ../src/event/ngx_event_pipe.h \
    ../src/event/ngx_event_posted.h \
    ../src/event/ngx_event_timer.h \
    ../src/http/modules/perl/nginx.xs \
    ../src/http/modules/perl/ngx_http_perl_module.h \
    ../src/http/modules/ngx_http_ssi_filter_module.h \
    ../src/http/modules/ngx_http_ssl_module.h \
    ../src/http/v2/ngx_http_v2.h \
    ../src/http/v2/ngx_http_v2_module.h \
    ../src/http/ngx_http.h \
    ../src/http/ngx_http_cache.h \
    ../src/http/ngx_http_config.h \
    ../src/http/ngx_http_core_module.h \
    ../src/http/ngx_http_request.h \
    ../src/http/ngx_http_script.h \
    ../src/http/ngx_http_upstream.h \
    ../src/http/ngx_http_upstream_round_robin.h \
    ../src/http/ngx_http_variables.h \
    ../src/mail/ngx_mail.h \
    ../src/mail/ngx_mail_imap_module.h \
    ../src/mail/ngx_mail_pop3_module.h \
    ../src/mail/ngx_mail_smtp_module.h \
    ../src/mail/ngx_mail_ssl_module.h \
    ../src/os/unix/ngx_alloc.h \
    ../src/os/unix/ngx_atomic.h \
    ../src/os/unix/ngx_channel.h \
    ../src/os/unix/ngx_darwin.h \
    ../src/os/unix/ngx_darwin_config.h \
    ../src/os/unix/ngx_dlopen.h \
    ../src/os/unix/ngx_errno.h \
    ../src/os/unix/ngx_files.h \
    ../src/os/unix/ngx_freebsd.h \
    ../src/os/unix/ngx_freebsd_config.h \
    ../src/os/unix/ngx_gcc_atomic_amd64.h \
    ../src/os/unix/ngx_gcc_atomic_ppc.h \
    ../src/os/unix/ngx_gcc_atomic_sparc64.h \
    ../src/os/unix/ngx_gcc_atomic_x86.h \
    ../src/os/unix/ngx_linux.h \
    ../src/os/unix/ngx_linux_config.h \
    ../src/os/unix/ngx_os.h \
    ../src/os/unix/ngx_posix_config.h \
    ../src/os/unix/ngx_process.h \
    ../src/os/unix/ngx_process_cycle.h \
    ../src/os/unix/ngx_setaffinity.h \
    ../src/os/unix/ngx_setproctitle.h \
    ../src/os/unix/ngx_shmem.h \
    ../src/os/unix/ngx_socket.h \
    ../src/os/unix/ngx_solaris.h \
    ../src/os/unix/ngx_solaris_config.h \
    ../src/os/unix/ngx_sunpro_atomic_sparc64.h \
    ../src/os/unix/ngx_thread.h \
    ../src/os/unix/ngx_time.h \
    ../src/os/unix/ngx_user.h \
    ../src/stream/ngx_stream.h \
    ../src/stream/ngx_stream_script.h \
    ../src/stream/ngx_stream_ssl_module.h \
    ../src/stream/ngx_stream_upstream.h \
    ../src/stream/ngx_stream_upstream_round_robin.h \
    ../src/stream/ngx_stream_variables.h \
    ../objs/ngx_auto_config.h \
    ../objs/ngx_auto_headers.h
SOURCES += \
    #../src/misc/ngx_cpp_test_module.cpp \
    ../src/core/nginx.c \
    ../src/core/ngx_array.c \
    ../src/core/ngx_buf.c \
    ../src/core/ngx_conf_file.c \
    ../src/core/ngx_connection.c \
    ../src/core/ngx_cpuinfo.c \
    ../src/core/ngx_crc32.c \
    ../src/core/ngx_crypt.c \
    ../src/core/ngx_cycle.c \
    ../src/core/ngx_file.c \
    ../src/core/ngx_hash.c \
    ../src/core/ngx_inet.c \
    ../src/core/ngx_list.c \
    ../src/core/ngx_log.c \
    ../src/core/ngx_md5.c \
    ../src/core/ngx_module.c \
    ../src/core/ngx_murmurhash.c \
    ../src/core/ngx_open_file_cache.c \
    ../src/core/ngx_output_chain.c \
    ../src/core/ngx_palloc.c \
    ../src/core/ngx_parse.c \
    ../src/core/ngx_parse_time.c \
    ../src/core/ngx_proxy_protocol.c \
    ../src/core/ngx_queue.c \
    ../src/core/ngx_radix_tree.c \
    ../src/core/ngx_rbtree.c \
    ../src/core/ngx_regex.c \
    ../src/core/ngx_resolver.c \
    ../src/core/ngx_rwlock.c \
    ../src/core/ngx_sha1.c \
    ../src/core/ngx_shmtx.c \
    ../src/core/ngx_slab.c \
    ../src/core/ngx_spinlock.c \
    ../src/core/ngx_string.c \
    ../src/core/ngx_syslog.c \
    #../src/core/ngx_thread_pool.c \
    ../src/core/ngx_times.c \
    #../src/event/modules/ngx_devpoll_module.c \
    ../src/event/modules/ngx_epoll_module.c \
    #../src/event/modules/ngx_eventport_module.c \
    #../src/event/modules/ngx_kqueue_module.c \
    #../src/event/modules/ngx_poll_module.c \
    ../src/event/modules/ngx_select_module.c \
    #../src/event/modules/ngx_win32_select_module.c \
    ../src/event/ngx_event.c \
    ../src/event/ngx_event_accept.c \
    ../src/event/ngx_event_connect.c \
    #../src/event/ngx_event_openssl.c \
    #../src/event/ngx_event_openssl_stapling.c \
    ../src/event/ngx_event_pipe.c \
    ../src/event/ngx_event_posted.c \
    ../src/event/ngx_event_timer.c \
    #../src/http/modules/perl/ngx_http_perl_module.c \
    ../src/http/modules/ngx_http_access_module.c \
    ../src/http/modules/ngx_http_addition_filter_module.c \
    ../src/http/modules/ngx_http_auth_basic_module.c \
    ../src/http/modules/ngx_http_auth_request_module.c \
    ../src/http/modules/ngx_http_autoindex_module.c \
    ../src/http/modules/ngx_http_browser_module.c \
    ../src/http/modules/ngx_http_charset_filter_module.c \
    ../src/http/modules/ngx_http_chunked_filter_module.c \
    #../src/http/modules/ngx_http_dav_module.c \
    #../src/http/modules/ngx_http_degradation_module.c \
    ../src/http/modules/ngx_http_empty_gif_module.c \
    ../src/http/modules/ngx_http_fastcgi_module.c \
    ../src/http/modules/ngx_http_flv_module.c \
    ../src/http/modules/ngx_http_geo_module.c \
    #../src/http/modules/ngx_http_geoip_module.c \
    ../src/http/modules/ngx_http_gunzip_filter_module.c \
    ../src/http/modules/ngx_http_gzip_filter_module.c \
    ../src/http/modules/ngx_http_gzip_static_module.c \
    ../src/http/modules/ngx_http_headers_filter_module.c \
    #../src/http/modules/ngx_http_image_filter_module.c \
    ../src/http/modules/ngx_http_index_module.c \
    ../src/http/modules/ngx_http_limit_conn_module.c \
    ../src/http/modules/ngx_http_limit_req_module.c \
    ../src/http/modules/ngx_http_log_module.c \
    ../src/http/modules/ngx_http_map_module.c \
    ../src/http/modules/ngx_http_memcached_module.c \
    ../src/http/modules/ngx_http_mp4_module.c \
    ../src/http/modules/ngx_http_not_modified_filter_module.c \
    ../src/http/modules/ngx_http_proxy_module.c \
    ../src/http/modules/ngx_http_random_index_module.c \
    ../src/http/modules/ngx_http_range_filter_module.c \
    #../src/http/modules/ngx_http_realip_module.c \
    ../src/http/modules/ngx_http_referer_module.c \
    ../src/http/modules/ngx_http_rewrite_module.c \
    ../src/http/modules/ngx_http_scgi_module.c \
    ../src/http/modules/ngx_http_secure_link_module.c \
    ../src/http/modules/ngx_http_slice_filter_module.c \
    ../src/http/modules/ngx_http_split_clients_module.c \
    ../src/http/modules/ngx_http_ssi_filter_module.c \
    #../src/http/modules/ngx_http_ssl_module.c \
    ../src/http/modules/ngx_http_static_module.c \
    #../src/http/modules/ngx_http_stub_status_module.c \
    ../src/http/modules/ngx_http_sub_filter_module.c \
    ../src/http/modules/ngx_http_upstream_hash_module.c \
    ../src/http/modules/ngx_http_upstream_ip_hash_module.c \
    ../src/http/modules/ngx_http_upstream_keepalive_module.c \
    ../src/http/modules/ngx_http_upstream_least_conn_module.c \
    ../src/http/modules/ngx_http_upstream_zone_module.c \
    ../src/http/modules/ngx_http_userid_filter_module.c \
    ../src/http/modules/ngx_http_uwsgi_module.c \
    #../src/http/modules/ngx_http_xslt_filter_module.c \
    #../src/http/v2/ngx_http_v2.c \
    #../src/http/v2/ngx_http_v2_filter_module.c \
    #../src/http/v2/ngx_http_v2_huff_decode.c \
    #../src/http/v2/ngx_http_v2_huff_encode.c \
    #../src/http/v2/ngx_http_v2_module.c \
    #../src/http/v2/ngx_http_v2_table.c \
    ../src/http/ngx_http.c \
    ../src/http/ngx_http_copy_filter_module.c \
    ../src/http/ngx_http_core_module.c \
    ../src/http/ngx_http_file_cache.c \
    ../src/http/ngx_http_header_filter_module.c \
    ../src/http/ngx_http_parse.c \
    ../src/http/ngx_http_postpone_filter_module.c \
    ../src/http/ngx_http_request.c \
    ../src/http/ngx_http_request_body.c \
    ../src/http/ngx_http_script.c \
    ../src/http/ngx_http_special_response.c \
    ../src/http/ngx_http_upstream.c \
    ../src/http/ngx_http_upstream_round_robin.c \
    ../src/http/ngx_http_variables.c \
    ../src/http/ngx_http_write_filter_module.c \
    #../src/mail/ngx_mail.c \
    #../src/mail/ngx_mail_auth_http_module.c \
    #../src/mail/ngx_mail_core_module.c \
    #../src/mail/ngx_mail_handler.c \
    #../src/mail/ngx_mail_imap_handler.c \
    #../src/mail/ngx_mail_imap_module.c \
    #../src/mail/ngx_mail_parse.c \
    #../src/mail/ngx_mail_pop3_handler.c \
    #../src/mail/ngx_mail_pop3_module.c \
    #../src/mail/ngx_mail_proxy_module.c \
    #../src/mail/ngx_mail_smtp_handler.c \
    #../src/mail/ngx_mail_smtp_module.c \
    #../src/mail/ngx_mail_ssl_module.c \
    #../src/misc/ngx_google_perftools_module.c \
    ../src/os/unix/ngx_alloc.c \
    ../src/os/unix/ngx_channel.c \
    ../src/os/unix/ngx_daemon.c \
    #../src/os/unix/ngx_darwin_init.c \
    #../src/os/unix/ngx_darwin_sendfile_chain.c \
    ../src/os/unix/ngx_dlopen.c \
    ../src/os/unix/ngx_errno.c \
    #../src/os/unix/ngx_file_aio_read.c \
    ../src/os/unix/ngx_files.c \
    #../src/os/unix/ngx_freebsd_init.c \
    #../src/os/unix/ngx_freebsd_sendfile_chain.c \
    #../src/os/unix/ngx_linux_aio_read.c \
    ../src/os/unix/ngx_linux_init.c \
    ../src/os/unix/ngx_linux_sendfile_chain.c \
    ../src/os/unix/ngx_posix_init.c \
    ../src/os/unix/ngx_process.c \
    ../src/os/unix/ngx_process_cycle.c \
    ../src/os/unix/ngx_readv_chain.c \
    ../src/os/unix/ngx_recv.c \
    ../src/os/unix/ngx_send.c \
    ../src/os/unix/ngx_setaffinity.c \
    ../src/os/unix/ngx_setproctitle.c \
    ../src/os/unix/ngx_shmem.c \
    ../src/os/unix/ngx_socket.c \
    #../src/os/unix/ngx_solaris_init.c \
    #../src/os/unix/ngx_solaris_sendfilev_chain.c \
    #../src/os/unix/ngx_thread_cond.c \
    #../src/os/unix/ngx_thread_id.c \
    #../src/os/unix/ngx_thread_mutex.c \
    ../src/os/unix/ngx_time.c \
    ../src/os/unix/ngx_udp_recv.c \
    ../src/os/unix/ngx_udp_send.c \
    ../src/os/unix/ngx_udp_sendmsg_chain.c \
    ../src/os/unix/ngx_user.c \
    ../src/os/unix/ngx_writev_chain.c \
    ../src/stream/ngx_stream.c \
    ../src/stream/ngx_stream_access_module.c \
    ../src/stream/ngx_stream_core_module.c \
    ../src/stream/ngx_stream_geo_module.c \
    #../src/stream/ngx_stream_geoip_module.c \
    ../src/stream/ngx_stream_handler.c \
    ../src/stream/ngx_stream_limit_conn_module.c \
    ../src/stream/ngx_stream_log_module.c \
    ../src/stream/ngx_stream_map_module.c \
    ../src/stream/ngx_stream_proxy_module.c \
    ../src/stream/ngx_stream_realip_module.c \
    ../src/stream/ngx_stream_return_module.c \
    ../src/stream/ngx_stream_script.c \
    ../src/stream/ngx_stream_split_clients_module.c \
    #../src/stream/ngx_stream_ssl_module.c \
    ../src/stream/ngx_stream_ssl_preread_module.c \
    ../src/stream/ngx_stream_upstream.c \
    ../src/stream/ngx_stream_upstream_hash_module.c \
    ../src/stream/ngx_stream_upstream_least_conn_module.c \
    ../src/stream/ngx_stream_upstream_round_robin.c \
    #../src/stream/ngx_stream_upstream_zone_module.c \
    ../src/stream/ngx_stream_variables.c \
    ../src/stream/ngx_stream_write_filter_module.c \
    ../objs/ngx_modules.c
相关文章
|
1月前
|
应用服务中间件 Linux nginx
【Azure App Service】基于Linux创建的App Service是否可以主动升级内置的Nginx版本呢?
基于Linux创建的App Service是否可以主动升级内置的Nginx版本呢?Web App Linux 默认使用的 Nginx 版本是由平台预定义的,无法更改这个版本。
139 77
|
3月前
|
负载均衡 Ubuntu 应用服务中间件
nginx修改网站默认根目录及发布(linux、centos、ubuntu)openEuler软件源repo站点
通过合理配置 Nginx,我们可以高效地管理和发布软件源,为用户提供稳定可靠的服务。
247 13
|
5月前
|
Ubuntu 应用服务中间件 Linux
Linux下搭建Nginx环境的搭建
Linux下搭建Nginx环境的搭建
115 6
|
5月前
|
应用服务中间件 Linux Shell
Linux 配置 Nginx 服务的详细步骤,绝对干货
Linux 配置 Nginx 服务的详细步骤,绝对干货
191 0
|
5月前
|
应用服务中间件 Linux nginx
Linux下操作Nginx相关命令
Linux下操作Nginx相关命令
|
5月前
|
网络协议 应用服务中间件 Linux
Linux安装nginx
Linux安装nginx
|
5月前
|
前端开发 JavaScript 应用服务中间件
linux安装nginx和前端部署vue项目(实际测试react项目也可以)
本文是一篇详细的教程,介绍了如何在Linux系统上安装和配置nginx,以及如何将打包好的前端项目(如Vue或React)上传和部署到服务器上,包括了常见的错误处理方法。
1596 0
linux安装nginx和前端部署vue项目(实际测试react项目也可以)
|
6月前
|
Windows
QT源码拾贝6-11(qwindowswindow)
这篇文章深入探讨了Qt源码中与窗口激活相关的函数,QDebug运算符重载,vscode的变量提示,Windows常用类型名,获取所有窗体的方法,以及QSharedPointer智能指针的使用。
151 0
QT源码拾贝6-11(qwindowswindow)
|
6月前
|
存储 Java C++
QT源码拾贝0-5(qimage和qpainter)
这篇文章介绍了在Qt源码中qimage和qpainter的使用,包括线程池的使用、智能指针的存储、std::exchange函数的应用、获取类对象的方法以及QChar字节操作。
QT源码拾贝0-5(qimage和qpainter)
|
6月前
|
编解码 开发工具 UED
QT Widgets模块源码解析与实践
【9月更文挑战第20天】Qt Widgets 模块是 Qt 开发中至关重要的部分,提供了丰富的 GUI 组件,如按钮、文本框等,并支持布局管理、事件处理和窗口管理。这些组件基于信号与槽机制,实现灵活交互。通过对源码的解析及实践应用,可深入了解其类结构、布局管理和事件处理机制,掌握创建复杂 UI 界面的方法,提升开发效率和用户体验。
287 13