【项目】基于C++搭建的OJ系统

一、功能总览

1.1 项目介绍

  • 实现一个类似牛客、leetcode的在线OJ系统,用户可以选择试题,并提交代码,通过网络传输,上传到服务器后台,后台对代码进行编译运行,并把测试结果反馈给客户端浏览器
    在这里插入图片描述

1.2 环境搭建

  1. 利用cpp-httplib开源库:搭建一个http服务,不需要关心 tcp 和 http 的建立和 url 解析过程,只要注册对应的方法。
克隆仓库:git clone https://gitee.com/iqxg/cpp-httplib.git
  1. 升级gcc,cpp-httplib库依赖 C++ 11 中的正则表达式,而 Centos7 自带的 gcc4.8 正则表达式有 bug。
1.下载高版本gcc:bash中输入以下命令
sudo yum -y install centos-release-scl
sudo yum -y install devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-binutils

2.设置默认启动高版本gcc
  打开文件
	vim ~/.bash_profile
  在最后添加:
	scl enable devtoolset-7 bash
  重启gcc
	source ~/.bash_profile
  1. 下载Jsoncpp
yum install jsoncpp
yum install jsoncpp-devel
  1. 下载谷歌ctemplate,boost
sudo yum install -y snappy-devel boost-devel zlib-devel.x86_64 python-pip
sudo pip install BeautifulSoup4
git clone https://gitee.com/HGtz2222/ThirdPartLibForCpp.git
cd ./ThirdPartLibForCpp/el7.x86_64/
sh install.sh

1.3 cpp-httplib库测试

#include <iostream>
#include <string>
#include "httplib.h"
int main()
{
   
  // 1.创建一个Server类对象
  httplib::Server http_svr;
  // 2.注册Get方法
  http_svr.Get("/index", [](const httplib::Request& req, httplib::Response& resp){
   
      std::cout << req.method << " " << req.path << " " << req.version << std::endl;
      std::string html = "<html>this is Linux~~<html>";
      resp.set_content(html, "text/html");
      }
  • 3
    点赞
  • 33
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值