mac vagrantでGLUTのGUIの立ち上げ方法


#include <GL/glut.h>

void display(void){


int main(int argc, char *argv[]){
	glutInit(&argc, argv);
	return 0;

$ ./app
freeglut (./app): failed to open display ”


$ exit
$ vagrant halt

2. Vagrantfileにssh.forward_x11を追記します。


Vagrant.configure("2") do |config| = "ubuntu/bionic64" "private_network", ip: ""
  config.ssh.forward_x11 = true // 追加
config.ssh.forward_x11 (boolean) – If true, X11 forwarding over SSH connections is enabled. Defaults to false.

X Window Systemとは、UNIX系OSで標準的に用いられるウィンドウシステム。

-> MacユーティリティでXQuartzを起動し、terminalから再度実行

$ ./app
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
X Error of failed request: GLXBadContext
Major opcode of failed request: 149 (GLX)
Minor opcode of failed request: 6 (X_GLXIsDirect)
Serial number of failed request: 43
Current serial number in output stream: 42
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 149 (GLX)
Minor opcode of failed request: 24 (X_GLXCreateNewContext)
Value in failed request: 0x0
Serial number of failed request: 42
Current serial number in output stream: 43

$ sudo ldconfig -p | grep -i (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/ (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/ (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/ (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/ (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/ (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/ (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/ (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/


Try the following: 1) ensure you are running up-to-date Xquartz. 2) in a terminal, defaults write org.macosforge.xquartz.X11 enable_iglx -bool true 3) restart xquartz. This worked for me to get a simple java app running. I tried "glxgears" and it starts, but the gears don't turn. I presume they're supposed to

$ defaults write org.macosforge.xquartz.X11 enable_iglx -bool true

$ ./app


Virtual Boxのハードウェア構成の見方

ここでは、amazon linux2のハードウェア構成を確認します。

### Oracle Virtual box マネージャを起動
OS:Linux 2.6 / 3.x / 4.x 64-bit
システム メインメモリー:1024MB
アクセラレーション: VT-x/AMD-V、ネステッドページング 、PAE/NX, KVM 準仮想化
ディスプレイ: ビデオメモリー16MB、グラフィックコントローラ VBoxVGA
ストレージ: box-disk001.vmdk(25.00GB)
ネットワーク アダプタ: Intel PRO/1000MT Desktop(NAT)

### CPU

1CPU, メインメモリ1GBだと、t2.microと同じくらいのスペック

Amazon Linux 2のVagrant boxでshutdownできない時

vagrant boxesからamazon linux 2を入れて、環境構築をする

>mkdir amzn2
>cd amzn2
>vagrant init gbailey/amzn2

Vagrantfile "private_network", ip: ""

>vagrant up
>vagrant status
>vagrant ssh
$ exit

>vagrant halt

>vagrant status
default running (virtualbox)


config.vm.guest = :amazonを追加 = "gbailey/amzn2"
  config.vm.guest = :amazon

>vagrant halt
>vagrant status
default poweroff (virtualbox)



まずvagrant boxes

まず、trusty64のvagrant fileを作ります。
mac:myvagrant mac$ mkdir Ubuntu
mac:myvagrant mac$ ls
MyCentOS Ubuntu
mac:myvagrant mac$ cd ubuntu
mac:ubuntu mac$ vagrant init ubuntu/trusty64
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`` for more information on using Vagrant.


  # "forwarded_port", guest: 80, host: 8080 "forwarded_port", guest: 80, host: 8080

mac:ubuntu mac$ vagrant reload
==> default: VM not created. Moving on…
mac:ubuntu mac$ vagrant up

mac:ubuntu mac$ vagrant ssh
Welcome to Ubuntu 14.04.6 LTS (GNU/Linux 3.13.0-170-generic x86_64)

* Documentation:

System information as of Sun Oct 27 12:59:04 UTC 2019

System load: 0.49 Processes: 81
Usage of /: 3.6% of 39.34GB Users logged in: 0
Memory usage: 25% IP address for eth0:
Swap usage: 0%

Graph this data and manage this system at:

0 updates can be installed immediately.
0 of these updates are security updates.

New release ‘16.04.6 LTS’ available.
Run ‘do-release-upgrade’ to upgrade to it.

vagrant@vagrant-ubuntu-trusty-64:~$ ip a
1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:bb:97:37 brd ff:ff:ff:ff:ff:ff
inet brd scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:febb:9737/64 scope link
valid_lft forever preferred_lft forever
vagrant@vagrant-ubuntu-trusty-64:~$ hostname -I

mac:ubuntu mac$ vagrant ssh-config
Host default
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /Users/mac/MyVagrant/Ubuntu/.vagrant/machines/default/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL



Check whether the Chef Client / Chef Solo exists in the instance or the expected version when starting Vagrant, and if not, automatically install it on the instance using Chef’s omnibus installer.

# -*- mode:ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config| = "<your_box_name_here>" :private_network, ip: ""

  config.omnibus.chef_version = "11.4.0"

  config.vm.provision :chef_solo do |chef|
      chef.cookbooks_path = "./cookbooks"
      chef.add_recipe "apache"

vagrant ssh-config


>vagrant ssh-config
Host default
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile C:/Users/hoge/MyVagrant/Cent/.vagrant/machines/default/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL


>vagrant ssh-config > ssh.config

>scp -F ssh.config vagrant@default:package-lock.json ./
package-lock.json 100% 11KB 11.5KB/s 00:00



mount -r /ev/cdrom /media/cdrom

mount is a command to do or mount work which embeds a disk device in the directory of Linux and makes it usable.
Today, the disk device ranges from CD, DVD, Blue-ray Disc, external hard disk, USB memory and so on. Disk devices are called file systems on Linux. All of them can be set to be usable with the mount command.

Basic of “mount”
The way to check the current mounting status is easy as follows.

[vagrant@localhost tests]$ mount
/dev/mapper/VolGroup-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
vagrant on /vagrant type vboxsf (uid=500,gid=500,rw)

The current mounting status is displayed. Information on where called a mount point is located, the type of the file system whether other read / write is possible, and the like are displayed.

-r option: read-only
The -r option is an option to mount read-only and the format is as follows.

$mount -r -t ${type} ${device} ${mount directory}

The command to mount the device /dev/cdrom read-only on the mount point/media/cd is as follows.

$ mount -r -t iso9660 /dev/cdrom /media/cd
mount -r /dev/cdrom /media/cdrom

VBoxManage storageattach CentOS-6.4-x86_64-minimal

Assign virtual DVD drive
Like the virtual hard disk, assign a virtual DVD drive. The installation media specifies Cent-6.4- x86 – minimal.iso.

$ VBoxManage storageattach CentOS-6.4-x86_64-minimal --storagectl SATA --port 2 --type dvddrive --medium I:/ISO/CentOS/CentOS-6.4-x86_64-minimal.iso
$ VBoxManage storageattach ${guest-os} \
  --storagectl IDE \
  --port 1 \
  --device 0 \
  --type dvddrive \
  --medium ${iso}