Thursday 23 June 2016

Undefined reference

Most likely culprit is that you've either not defined the function or you included the library with the definition in the wrong order. [source]

In my case it was a bit more insidious - I was the victim of name mangling. Long story short, be extra careful when mixing C and C++. [solution]

The sad thing is I more or less encountered this problem 6 months ago, but I think I have a better understanding of it now.

Monday 13 June 2016

Miscellaneous VirtualBox Problems

My host is Windows 7 and my guest is Ubuntu Server 16.04

Screen goes black
Initially I thought this was because it was going to sleep or something. I'm still not quite sure what the problem is, but in my case I was able to get the screen back by pressing ALT.
[Source]

Symlinks in a shared folder
I'm running Windows 7, so symlinks are disabled by default due to security concerns. They're also disabled by default in shared folders by VirtualBox - also for security concerns. If you try to create a symlink in a shared folder then you'll get an error like such:
ln: failed to create symbolic link `b': Read-only file system
I did a bunch of stuff and wasted a few hours on this so at this point I'm not sure exactly what I did to get it working. First thing I did was turn on symlinks on the host side, but this may be an optional step.
  1.  Disable UAC [Source], but this may only be needed for Windows 8+
  2. Add yourself to the SeCreateSymbolicLinkPrivilege security policy (secpol.msc -> Local Policies -> User Rights Assignment -> Create symbolic links) [Source], but this may only be needed for non-admin users
  3. Restart/Log off or run gpupdate /force  
Now on the guest side you need to run 
VBoxManage setextradata YOURVMNAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/YOURSHAREFOLDERNAME 1 
For the shared folder name make sure to use the Folder Name as appears when editing the folder through the VirtualBox management program AND NOT THE FOLDER PATH! So if your folder path has spaces in it (e.g. shared folder for vm), your folder name would have underscores instead (e.g. shared_folder_for_vm). Unfortunately there is not indication if you misspell anything past the YOURVMNAME part. But you can check what you entered using:
VBoxManage getextradata YOURVMNAME enumerate
[Source]

Clock skew
Not really an issue for me, but good to know at any rate. [Source]

SSH from host
I couldn't figure out how to copy and paste into the VM through the VirtualBox window so I decided to SSH into it since I can copy and paste into putty. There's a lot of guides for this, but here's a succinct one.

SSH connection lost after sleep
I would lose my connect every time my computer woke up from sleep. The VM would still be running in the background (I run it headless) and new SSH connections could be made, but existing ones would be disconnected and wouldn't be able to reconnect. Apparently this is a known bug. I'm hopeful that the following fixes this:
VBoxManage modifyvm UbuntuServer --natdnshostresolver1 on
[Source]