For the love of .. please don't quote this entire post in any reply, or see your reply deleted - If you must quote, quote only relevant parts.
This is a lengthy and picture-heavy rundown of compiling cgminer on Windows by somebody who hasn't done so in over a year and ran into various problems doing so from scratch - procedure for 2015-07-06.
If you don't need any code changes, just use the regular
cgminer builds.
If you do need a custom Windows binary, consider
cross-compiling in a Linux environment.
If you enjoy mild frustration, continue reading
Although the result works (well, so far), there's always a chance that it doesn't perform the same as the official builds due to differences in library versions, kludgy code edits to get things to compile, and so on.
It's also entirely possible that things could be done more efficiently ( in terms of compiling - starting this thread out step-by-clicking-step on purpose ) - if so, leave your replies
"build cgminer for windows"So you want to build cgminer for Windows, and presumably
on Windows.
First thing you're likely to do is hit up google with exactly those search terms.
Lucky me, the very top result points to a document at the official github repository, while the third result in my case braces me for things to come. October 2012 is a bit too 3 years ago to dive into that thread, though, so carry on and follow the first result. "Native WIN32 setup and build instructions (on mingw32/Windows)". Sounds promising, though what's mingw32?
https://github.com/ckolivas/cgminer/blob/master/windows-build.txtCarry on reading and - aha - mingw32 is something I'll have to install. At this point, you may wish to do a quick read through the entire document and then come back here.
Download and install MinGWAnother site to go to, follow the link.
http://www.mingw.org/wiki/Getting_StartedNow the next instruction refers to a "
Download and run the latest mingw-get-inst version." link. That no longer exists.
Instead, scroll down the page to find "
Graphical User Interface Installer" and the
mingw-get-setup.exe link, and click that instead.
https://sourceforge.net/projects/mingw/files/latest/downloadYou'll end up at Sourceforge - probably will for the foreseeable time, despite sourceforge's recent snafus, as a lot of mingw depends on things hosted at sourceforge - with a countdown time before the download begins. Once the download has completed, launch the downloaded MinGW installer.
Click through the bunch of boring install screens - but keep an eye out in case it gets repackaged with 'value added' software. Note that in my case, I changed the drive from C: to E: because reasons. Yes, this installer downloads additional files. That'll be a running theme in this post.
Eventually you'll end up with a new screen labeled
MinGW Installation Manager. Here you can choose which components to include in your MinGW installation.
The instructions suggest to select basically everything - with poor Fortran singled out as not having been selected by the cgminer author. You'll want to select the following components:
- mingw-developer-toolkit
- mingw32-base
The first one will also automatically select the
msys-base component. To select the components for installation, click on the checkbox and choose
Mark for Installation Note: If you want to save a few steps later on, expand the tree on the left to
All Packages > MinGW > MinGW Libraries, and also select
mingw32-pthreads-32 of class
dev (doesn't hurt to select 'doc' and 'lic' as well).
Once the components have been marked for installation, go to the
Installation menu and choose
Apply Changes. You'll get a new dialog that shows what changes will be made (in this case, only new/upgraded packages) - in there, click
Apply. The
MinGW Installation Manager will now download (yep) and install those components - this takes a while. Once it is done, the components should be marked as installed in the manager, and you can choose
Installation and then
Quit to exit the manager.
Run the MSYS shell / create your user directoryThe next instruction suggests that MSYS shell should be run by going through the Start menu. Only one problem: it's not there. If you're on Windows 8, the 'metro' start menu will inform you that the only 'MinGW' it knows of is that manager.
Off to google I go, to find out why I
can't find MinGW shell, and luckily I'm not alone. The first result is a good hit, though the first answer goes off on uninstalling and reinstalling and another mentions setting up a shortcut (if you must, by all means) which can be entirely ignored,
msoliman has the tl;dr version, I have to launch a batch file. Success! That certainly does look like a command line interface of some sort.
Install libpdcursesThe next section in the instructions suggests to install libpdcurses by a couple of commands. Unfortunately, the very first command throws an error:
sh: mingw-get: command not found. Thankfully, the earlier page that explained how to launch the shell also had a hint in there that I happened to read: the installer might not actually perform all that needs doing, and a post-install batch file will have to be run and its instructions followed. Once done,
mingw-get can be found just fine and the libpdcurses libraries download (yep) and install without a problem.
mingw-get install mingw32-libpdcurses
mingw-get install mingw32-pdcurses
Copy CGMiner source to your MSYS working directory...is the title of the next section in the instructions, but how do I go about getting the cgminer source, exactly? Well, the github repository that holds the instructions document is also the source repository, simply click on through to
cgminer, and then click on the
Download ZIP button to download the entire source repository as a ZIP file. Open that ZIP file, and follow the instructions by copying the files - I recommend just copying the
cgminer-master folder - and pasting it into your MSYS user folder in
MinGW\msys\1.0\home\USERNAME\.
https://github.com/ckolivas/cgminer/blob/master/windows-build.txtGPU mining optionalGPU mining.. optional, you say? Good, let me skip this.
( If you want GPU mining - go ahead.. that's probably a whole 'nother can of worms, though. )
Install GTK-WINGood, more bits to download and install. Just click all the appropriate links and buttons, make sure there's no 'value added' bits and pieces, and continue following the instructions. Make sure you copy the files that the instructions say to copy! If you can't find the files to copy (e.g. you can't find
Program Files (x86) or
Program Files), make sure your Windows Explorer or other file manager is set to display hidden files and folders.
http://sourceforge.net/projects/gtk-win/Install pkg-configMore. Again, click the appropriate links and buttons, following the instructions, with the one caveat that it's
pkg-config you're looking for, and not
pkg-cfg. By now you should be used to opening downloaded files, and copying files from one location to another, so let me skip those screenshots.
http://www.gtk.org/download/win32.phpInstall libcurlOnce again, click the appropriate links and buttons, following the instructions, with the caveat here being that you shouldn't try copying all the files in the 3 folders mentioned individually - just copy the 3 folders, and paste them into the
MinGW installation folder. Note that you may get a complaint about
zlib1.dll already existing - skip that file (at this time the one that comes with MinGW is newer than the one that comes with libcurl).
http://curl.haxx.se/download.html#Win32The instructions also ask you to edit a file. Find the file, right-click it, and open it in your editor. If you don't have a good editor - well, I like notepad++ (
https://notepad-plus-plus.org/ ) as a lightweight one. Note that if you try opening files with regular
Windows Notepad, the file may not be interpreted correctly, with linebreaks missing. This is because Linux uses a different linebreak format from Windows and Windows Notepad basically screws up. Make sure you actually
save the file when done editing.
Build cgminer.exeHurrah! Let's, by all means, actually build cgminer.exe! Typing
cd cg is the way to go, gets you straight into the
cgminer-master directory.
The next two instructions you should skip. Not just because the first one is optional, but because the second one is obsolete, as per the cgminer developer's own statement on this forum. Instead, run
autogen.sh by simply typing that and hitting enter. This shell script will take a while to run.
autogen.sh
Next up is setting the compile flags. As I didn't include GPU mining support, those should be disabled with. As the point of compiling cgminer from scratch was to play with Icarus-comms type device, I enabled that option.
CFLAGS="-O2 -msse2" ./configure --disable-gpu --disable-adl --enable-icarus
Alas, an error occurs. If you took my advice a few steps back and enabled the
mingw32-pthreads-32 component, you should not be getting this error. If you didn't take that advice, here's how to resolve the error:
mingw-get install pthreads
The MinGW Installation Manager will also show the component as installed if you check now. ( Make sure to close it again before proceding further. )Once installed, re-run the compile flags command (press the
up arrow key to go back to previous commands you entered so save from typing them in manually again), and it should run through without any problems.
The next command is
make which actually starts the process of compiling the source into a binary. Run that command, and... more errors.
make
Googling the error yields some results - the first result is a bit of a red herring, but does helpfully point out that one should probably use MSYS2 as MSYS is outdated .. great, but ignore - the third result of which is most helpful, as it points out that this is an issue with MinGW itself introduced not all that long ago (and well after the cgminer build instructions). Following the links leads to a patch file which, when applied, effective disables some code.
Rather than applying it, opening the file shows exactly what needs to be done. The
#ifdef 0 ... #endif basically causes the code within to never be evaluated by the compiler. Find the file that needs to be edited at
MinGW\include\unistd.h, edit it, and make the appropriate changes. Don't forget to save the file.
At this point, run the compiler flags command and
make again, and... another error.
In this case the error is because the
sleep function got defined with different formats. The one from cgminer I'll probably want to keep, so instead I just commented out the ones from
MinGW\include\unistd.h.
Again, run the compiler flags command and
make again, and... success! cgminer source successfully compiled into
cgminer.exe The next step in the instructions suggests to strip it of debug bits, so why not.
strip cgminer.exe
Running cgminer.exeTo actually run
cgminer.exe, it has to be put together with some libraries it depends on into a folder. The instructions mention a bunch of libraries, find them as stated, copy, and paste them all together into a (new) folder, then launch
cgminer.exe to get the next error.
Update for 2015-07-10: You may find that you get more HW errors with this as built. Instead of using the file
pthreadGC2.dll as listed, download an older version from
http://ftp://sourceware.org/pub/pthreads-win32/prebuilt-dll-2-8-0-release/lib/pthreadGC2.dll and use that instead. For reference, see the
cross-compile build notes.
I'm missing a file, obviously. Thankfully, that file is available as
MinGW\bin\libgcc_s_dw2-1.dll, so copy it from there to the same folder as
cgminer.exe, then try again - oh boy, it runs!
ZadigAh crap. Zadig. If you get the error about needing to replace drivers, here's a very quick bonus section on running zadig so that the newer cgminer versions can find some miners. If you don't get this error, you should already be mining.
Zadig is a utility that can replace vendor-specific USB serial drivers, such as those from Silicon Labs, FTDI, etc. with a more universal USB serial driver. Google Zadig, make sure you get the official page, download the version for Vista or later unless you're on XP - the executable you get is the program, not an installer - launch, go to
Options and then
List All Devices to actually list the devices, pick the appropriate one from the list - which is easier if you don't have a bunch of serial devices plugged in - make sure the replacement driver is
WinUSB, click the
Replace Driver button, wait for Zadig to do its thing, then unplug and replug the device.
If all is well, re-run
cgminer.exe and off you go!
GekkoScience CompacIf you came here because you wanted to mess with higher frequencies on a
GekkoScience Compac, and just can't wait for official builds, here's the changes you'll have to make before building cgminer:
Edit the
cgminer.c file and adjust three sections, essentially changing '250' to '450'.
Edit the
driver-icarus.c file and adjust three sections, essentially changing '250' to '450' and adding the higher frequencies to the look-up table.
Frequencies and hex codes from BM1384 datasheet:
{ 275, 0x0a82 },
{ 300, 0x0b82 },
{ 325, 0x0c82 },
{ 350, 0x0d82 },
{ 375, 0x0e82 },
{ 400, 0x08f2 },
{ 425, 0x0801 },
{ 450, 0x0881 },