<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>day34 — Gerrit Niezen</title>
    <link>https://gerritniezen.com/tag:day34</link>
    <description>Maker of open-source software and hardware.</description>
    <pubDate>Fri, 20 Nov 2026 21:51:18 +0000</pubDate>
    <image>
      <url>https://i.snap.as/aMPXpIot.png</url>
      <title>day34 — Gerrit Niezen</title>
      <link>https://gerritniezen.com/tag:day34</link>
    </image>
    <item>
      <title>Getting a Node.js library using libmtp working on Windows</title>
      <link>https://gerritniezen.com/getting-a-node-js-library-using-libmtp-working-on-windows?pk_campaign=rss-feed</link>
      <description>This is a follow-on to Part 1 and Part 2 of my adventures in connecting to Android devices over MTP using Node.js, on Windows. While comp...</description>
      <content:encoded><![CDATA[<p>This is a follow-on to <a href="https://gerritniezen.com/attempting-to-get-libmtp-compiled-on-windows">Part 1</a> and <a href="https://gerritniezen.com/more-adventures-with-libmtp">Part 2</a> of my adventures in connecting to Android devices over MTP using Node.js, on Windows.</p>

<p>While compiling the Node.js native module, I got the following error:</p>

<pre><code>Macro definition of snprintf conflicts with Standard Library function declaration
</code></pre>

<p><a href="https://stackoverflow.com/questions/51897245/visual-studio-macro-definition-of-snprintf-conflict">Searching StackOverflow</a> led to this solution, which I added to the libmtp source code:</p>

<pre><code class="language-c">#if _MSC_VER &lt; 1900
#define snprintf _snprintf
#endif
</code></pre>

<p>I also kept on getting a “Module not found” error, until I re-read <a href="https://gerritniezen.com/using-libavutils-lzo-algorithm-in-node-js-part-5">my own post</a> and used Dependency Walker to figure out that for some reason my <code>.node</code> file is looking for <code>libmtp-9.dll.dll</code> instead of <code>libmtp-9.dll</code>. 🤷‍♂️️ I also had to copy <code>libusb-1.0.dll</code> into the same folder, as it was looking for that too.</p>

<p>Finally, like magic, I was able to connect to a device on Windows over MTP with my own Node.js library using libmtp, instead of the Windows MTP implementation that can only be accessed through Windows Explorer or the Windows APIs.</p>

<p>And I just submitted <a href="https://github.com/libmtp/libmtp/pull/41">a PR to get Windows builds fixed in the upstream libmtp library</a>.</p>

<p>Next step: Getting it compiled for 32-bit Windows using <code>i686-w64-mingw32</code> and/or <code>i686-mingw32</code></p>

<hr/>

<p>I’m publishing this as part of 100 Days To Offload. You can join in yourself by visiting <a href="https://100daystooffload.com">https://100daystooffload.com</a>.</p>

<p><a href="https://gerritniezen.com/tag:100DaysToOffload" class="hashtag"><span>#</span><span class="p-category">100DaysToOffload</span></a> <a href="https://gerritniezen.com/tag:day34" class="hashtag"><span>#</span><span class="p-category">day34</span></a> <a href="https://gerritniezen.com/tag:libmtp" class="hashtag"><span>#</span><span class="p-category">libmtp</span></a> <a href="https://gerritniezen.com/tag:Node" class="hashtag"><span>#</span><span class="p-category">Node</span></a>.js</p>

<p><i>Comment on this post</i>
<div id="cusdis_thread"></div></p>
]]></content:encoded>
      <guid>https://gerritniezen.com/getting-a-node-js-library-using-libmtp-working-on-windows</guid>
      <pubDate>Fri, 29 May 2020 15:17:11 +0000</pubDate>
    </item>
  </channel>
</rss>