install.sh 753 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. function cd_dir {
  3. local dir_path=$1
  4. # 检查目录是否存在
  5. if [ ! -d "$dir_path" ]; then
  6. echo "Directory $dir_path does not exist. Creating..."
  7. mkdir -p "$dir_path"
  8. fi
  9. cd "$dir_path" || exit
  10. }
  11. # 安装包检测
  12. function check_and_install {
  13. for package_name in "$@"
  14. do
  15. if ! dpkg -l $package_name &> /dev/null
  16. then
  17. echo "$package_name not found. Installing..."
  18. sudo apt-get update
  19. sudo apt-get install $package_name -y
  20. else
  21. echo "$package_name already installed."
  22. fi
  23. done
  24. }
  25. cd_dir build
  26. cmake ..
  27. sudo make install -j8
  28. cd ..
  29. sudo cp src/nanomsg /usr/local/include -rf
  30. sudo cp src/nnxx /usr/local/include -rf