centos下搭建hustoj判题机&解决找不到-lm,-lc

发布于 2019-07-13  47 次阅读


我的云服务器都是centos,判题机一直用的学院内的ubuntu。但是近期学院频繁断电,就打算直接在centos下搭建hustoj判题机,并将搭建过程记录下来。

由于服务器已有其他环境,不能使用一键安装脚本。以下是安装过程。

创建用户和目录

稍微修改下安装脚本,只保留创建用户和目录

#!/bin/bash
DBNAME="jol"
DBUSER="jol"
DBPASS="此处填写密码"
CPU=`cat /proc/cpuinfo| grep "processor"| wc -l`

/usr/sbin/useradd -m -u 1536 judge
cd /home/judge/
yum -y install subversion
svn co https://github.com/zhblue/hustoj/trunk/trunk/ src

mkdir etc data log backup

cp src/install/java0.policy  /home/judge/etc
cp src/install/judge.conf  /home/judge/etc
chmod +x src/install/ans2out

if grep "OJ_SHM_RUN=0" etc/judge.conf ; then
	mkdir run0 run1 run2 run3
	chown www run0 run1 run2 run3
fi

sed -i "s/OJ_COMPILE_CHROOT=1/OJ_COMPILE_CHROOT=0/g" etc/judge.conf
sed -i "s/OJ_RUNNING=1/OJ_RUNNING=$CPU/g" etc/judge.conf

chmod 700 backup
chmod 700 etc/judge.conf
chmod 775 -R /home/judge/data && chgrp -R www /home/judge/data
chown www data run0 run1 run2 run3
chmod 755 /home/judge

sed -i "s/OJ_USER_NAME=root/OJ_USER_NAME=$DBUSER/g" etc/judge.conf
sed -i "s/OJ_PASSWORD=root/OJ_PASSWORD=$DBPASS/g" etc/judge.conf

编译判题机

由于服务器上装了宝塔环境,mysql的路径不是默认的,所以将/home/judge/src/core/judged/makefile/home/judge/src/core/judge_client/makefile中的-I和-L后的路径分别修改为/www/server/mysql/include/www/server/mysql/lib ,并将/home/judge/src/core/judged/judged.cc/home/judge/src/core/judge_client/judge_client.cc 中的mysql/mysql.h改成mysql.h,最后直接运行/home/judge/src/core中的make.sh即可。

设置开机自启动

#!/bin/bash
if grep "/usr/bin/judged" /etc/rc.local ; then
	echo "auto start judged added!"
else
	chmod +x /etc/rc.d/rc.local
	sed -i "s/exit 0//g" /etc/rc.d/rc.local
	echo "/usr/bin/judged" >> /etc/rc.d/rc.local
	echo "exit 0" >> /etc/rc.d/rc.local
	
fi

提示找不到-lm,-lc等的解决方法

这个问题折腾了一会,网上找的好多方法都解决不了,最后发现是静态编译的问题,安装静态库即可

yum install glibc-static
yum install libstdc++-static