Creating an import lib from a dll

dumpbin /exports somelib.dll > exports.txt
echo LIBRARY some > somelib.def
echo EXPORTS >> somelib.def
for /f "skip=19 tokens=4" %name in (exports.txt) do echo %name >> somelib.def
lib /def:somelib.def /out:somelib.dll.lib /machine:somelib.dll

To get the value for machine do dumpbin /headers somelib.dll | findstr machine
The options in the for command mean skip the first 19 lines and then output the 4th field which is the name of the exported function.

git line ending handling on a project that is using multiple platforms

# for osx and linux this uses lf in the repo and will convert any cr/lf to lf on commit.
git config --global core.autocrlf input

# for windows if you want your working copy to use cr/lf this will covert on checkout.
git config --global core.autocrlf true

# for windows if you want your working copy to use what comes from the remote
# and to convert windows cr/lf to just lf on commit.
git config --global core.autocrlf input

# for windows only dev's you can keep both the wc and the remote as cr/lf.
git config --global core.autocrlf false

Upgrading Windows subsystem for Linux

I’m running Windows 10 Enterprise and using ubuntu 14.04 trusty which is what you get when you install the software.

I wanted 16.04 (xenial) which is available on the early release channel from MS but I’m not a subscriber.
The command to do this is simple: do-release-upgrade.
If it doesn’t work due to screen, then apt-get remove screen and reinstall after the upgrade.

Hope this helps,

-Martin

sudo: no tty present and no askpass program specified

After upgrading Windows subsystem for Linux from Ubuntu 14.04 to 16.04 I was getting the following:
mjs@IMAGE:/mnt/c/Users/mjs/Desktop$ sudo hostname localhost
sudo: unable to resolve host IMAGE
sudo: no tty present and no askpass program specified

The hostname needed to be set to localhost and I obviously needed to be able to enter a password.
But, in order to hostname, I needed to either use sudo or su.
I tried su and the password was set but not what it was prior to the upgrade 🙁

man sudo came to the rescue as man pages so often do.

mjs@IMAGE:/mnt/c/Users/mjs/Desktop$ sudo -S -h localhost hostname localhost
[sudo] password for mjs:
mjs@IMAGE:/mnt/c/Users/mjs/Desktop$

-h localhost solves the hostname problem by temporarily specifying the hostname.
-S requests that sudo use stdin for the password request which solves the askpass problem.

The next task was to edit /etc/hostname to contain localhost to make it permanent and to use sudo to change the root password.

Hope this helps,

-Martin