Windows environment CLion debugging SRS streaming media server source code

Environment introduction:
SRS supports CLion of JetBrains, which is compiled based on cmake, uses CLion in the windows environment, remotely debugs SRS through SSH, and the debugging environment is installed on the CentOS 7 virtual machine.
Resource download:
CLion official website download address: https://www.jetbrains.com/zh-cn/clion/ , the version I downloaded is CLion-2022.2.3.exe, windows version.
SRS download address: https://github.com/ossrs/srs , I downloaded srs-4.0release.zip.

Environment construction
1. Start the CentOS 7 virtual machine, and the installation depends on the environment. Do not choose Chinese installation for the centos7 system.

yum install perl-core cmake gcc gcc-c++ gdb -y

The old version of cmake is installed above. If you want to install a new version, you can remove the above cmake and install cmake3.21.1:

wget -c https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1.tar.gz
yum install openssl openssl-devel
tar -zxvf cmake-3.21.1.tar.gz
cd cmake-3.21.1
./bootstrap
make 
make install
ln -s /usr/local/bin/cmake /bin/cmake
cmake --version

2. Decompress the srs source code, use the CLion menu File-Open, and open the srs source code directory. The code downloaded by windows needs to be compiled under linux with LF line breaks.
insert image description here

3. File–>Settings–>Tools–>SSH Configurations, create an SSH link.
insert image description here
4. File–>Settings–>Build, Execution, Deployment–>Toolchains, configure the toolchain, add a Remote Host with the + sign, select the SSH created above, and the cmake, C, and C++ compilers will automatically recognize it. If the version is upgraded, it cannot Automatic identification, you can also remotely browse the directory on the CentOS 7 host, click the up arrow to adjust to the top.
insert image description here

5. After the previous step is OK, go to File–>Settings–>Build, Execution, Deployment–>Deployment to configure remote deployment. A Remote Host (SFTP type, if not, add it manually) is automatically generated here.
insert image description here
Click the Mappings tab, and select the Browse folder button on the right to select the local storage path of the srs source code and the remote storage path of CentOS 7. If the source code has been opened, the local path will be automatically recognized.
insert image description here
6. After the Deployment option is set, right-click the main directory of the project, select Deployment, Upload to, and upload the source code to the remote deployment directory of CentOS 7. After uploading, you can see the source code on CentOS 7.
insert image description here
insert image description here
7. Tools–>Start ssh session, call out the remote linux command line, and compile the SRS source code.

cd /home/chuwei/work/srs/trunk/
sudo yum install libasan#cannot find /usr/lib64/libasan.so.0.0.0报错执行
sudo chmod 777 -R *#部分脚本需要权限才能执行
sudo ./configure
sudo make

insert image description here
8. Right-click the main directory of the project, select Deployment, Download from, select Remote Deployment, and download the compiled file to the local, similar to step 6 above.
9. File–>Settings–>Build, Execution, Deployment–>CMake, you can configure compilation options, build directories, etc.
insert image description here

10. After the download is complete, select the directory trunk/ide/srs_clion, right click and select CMakeLists.txt, load CMake Project, and execute cmake.

sudo chmod 777 -R *#因为远端生成了新的文件,执行cmake前再修改一次权限

Error solution: /objs/st/libst.a not found, the libst library is not compiled correctly, just comment out these lines in CMakeLists.txt (higher version SRS can be compiled normally)

#${SRS_DIR}/objs/srt/lib/libsrt.a
#${SRS_DIR}/src/srt
#AUX_SOURCE_DIRECTORY(${SRS_DIR}/src/srt SOURCE_FILES)

After successfully executing cmake, Run–>Edit Configuratios automatically generates the CMake Application of srs, configures the startup parameters, working directory, and environment variables, and compiles after configuration.
insert image description here
11. Click the green hammer in the upper left corner of the above picture to compile. After the compilation is successful, click the green bug to debug, you can make a breakpoint, clion debugging shortcut keys: F7 to enter the function, F8 to step through the debug, F9 to jump to the next breakpoint .
insert image description here
Compilation error reports undeclared identifier nullptr, cmake cannot use C++11 features correctly, you can add it to the makefile:

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11")

An error is reported that #include <srt/srt.h> cannot be found, you can comment out this line.

Guess you like

Origin blog.csdn.net/weixin_40355471/article/details/127833119