problem compilation soft cgminer

Hi all,

I don't know if it's the good section to post so excuse me by advance if it isn't the right section.

I'm running FreeBSD 8.1-p8 and I want to compile the software cgminer (there isn't a port for this software). Source is available at this address: http://ck.kolivas.org/apps/cgminer/. When I run ./configure --with-system-libusb --enable-icarus, the output is ok:
Code:
------------------------------------------------------------------------
cgminer 3.8.4
------------------------------------------------------------------------


Configuration Options Summary:

  libcurl(GBT+getwork).: Enabled: -L/usr/local/lib -lcurl
  curses.TUI...........: FOUND: -lncurses

  Avalon.ASICs.........: Disabled
  BlackArrow.ASICs.....: Disabled
  BFL.ASICs............: Disabled
  BitForce.FPGAs.......: Disabled
  BitFury.ASICs........: Disabled
  Hashfast.ASICs.......: Disabled
  Icarus.ASICs/FPGAs...: Enabled
  Klondike.ASICs.......: Disabled
  KnC.ASICs............: Disabled
  ModMiner.FPGAs.......: Disabled

Compilation............: make (or gmake)
  CPPFLAGS.............:
  CFLAGS...............: -g -O2
  LDFLAGS..............:  -lpthread
  LDADD................: -ldl -L/usr/local/lib -lcurl  compat/jansson-2.5/src/.libs/libjansson.a -lpthread    -lm -lusb -lrt

Installation...........: make install (as root if needed, with 'su' or 'sudo')
  prefix...............: /usr/local

But when I run make I have this error:
Code:
make  all-recursive
Making all in lib
  GEN    arg-nonnull.h
  GEN    c++defs.h
  GEN    warn-on-use.h
  GEN    signal.h
  GEN    string.h
make  all-recursive
  CC     dummy.o
  CC     memmem.o
  AR     libgnu.a
Making all in compat
Making all in jansson-2.5
"Makefile", line 825: Need an operator
make: fatal errors encountered -- cannot continue
*** Error code 1
Stop in /tmp/cgminer-3.8.4/compat.
*** Error code 1
Stop in /tmp/cgminer-3.8.4.
*** Error code 1
Stop in /tmp/cgminer-3.8.4.

This error refers to this line I think:
Code:
line 825 of compat/jansson-2.5
# These flags are gcc specific
export AM_CFLAGS = -Wall -Wextra -Wdeclaration-after-statement

But if I use gmake this error disappears but I have the other :(
Code:
usbutils.c:3236: error: redefinition of 'union semun'
gmake[2]: *** [cgminer-usbutils.o] Error 1
gmake[2]: Leaving directory `/tmp/cgminer-3.8.4'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/tmp/cgminer-3.8.4'
gmake: *** [all] Error 2

The line 3236 in usbutils.c:3236 is this code:
Code:
#ifndef __APPLE__
union semun {
        int val;
        struct semid_ds *buf;
        unsigned short *array;
        struct seminfo *__buf;
};
#endif

if I comment the block I have finally this error:
Code:
  CCLD   cgminer
/usr/bin/ld: cannot find -ldl
gmake[2]: *** [cgminer] Error 1
gmake[2]: Leaving directory `/tmp/cgminer-3.8.4'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/tmp/cgminer-3.8.4'
gmake: *** [all] Error 2
And finally it seems cgminer wants to link against libdl, which does not exist on FreeBSD I think. So if I delete this switch, I have this error:
Code:
  CCLD   cgminer
cgminer-cgminer.o(.text+0x18b4): In function `libusb_poll_thread':
/tmp/cgminer-3.8.4/cgminer.c:7801: undefined reference to `libusb_handle_events_timeout_completed'
cgminer-cgminer.o(.text+0x18da):/tmp/cgminer-3.8.4/cgminer.c:7809: undefined reference to `libusb_handle_events_timeout_completed'
cgminer-util.o(.text+0x17bc): In function `nanosleep_abstime':
/tmp/cgminer-3.8.4/util.c:1001: undefined reference to `clock_nanosleep'
cgminer-usbutils.o(.text+0x1b37): In function `usb_all':
/tmp/cgminer-3.8.4/usbutils.c:999: undefined reference to `libusb_error_name'
cgminer-usbutils.o(.text+0x1cc4):/tmp/cgminer-3.8.4/usbutils.c:903: undefined reference to `libusb_error_name'
cgminer-usbutils.o(.text+0x1cf7):/tmp/cgminer-3.8.4/usbutils.c:899: undefined reference to `libusb_error_name'
cgminer-usbutils.o(.text+0x1d6e):/tmp/cgminer-3.8.4/usbutils.c:979: undefined reference to `libusb_error_name'
cgminer-usbutils.o(.text+0x6988): In function `resource_process':
/tmp/cgminer-3.8.4/usbutils.c:3546: undefined reference to `semtimedop'
cgminer-usbutils.o(.text+0x88f3): In function `_usb_transfer_read':
/tmp/cgminer-3.8.4/usbutils.c:2899: undefined reference to `libusb_error_name'
cgminer-usbutils.o(.text+0x8cec): In function `__usb_transfer':
/tmp/cgminer-3.8.4/usbutils.c:2830: undefined reference to `libusb_error_name'
cgminer-usbutils.o(.text+0x9b74): In function `_usb_write':
/tmp/cgminer-3.8.4/usbutils.c:2732: undefined reference to `libusb_error_name'
cgminer-usbutils.o(.text+0xa181): In function `_usb_read':
/tmp/cgminer-3.8.4/usbutils.c:2641: undefined reference to `libusb_error_name'
gmake[2]: *** [cgminer] Error 1
gmake[2]: Leaving directory `/tmp/cgminer-3.8.4'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/tmp/cgminer-3.8.4'
gmake: *** [all] Error 2
But know at this point I don't have any idea how to solve the error :(

I think the code is not ready for FreeBSD but could you help me to compile it?

Thank you very much.

PS: I wrote to the author but I didn't have any box with FreeBSD to debug the software.
 
I just tested it rapidly on a production server which is on FreeBSD 9.1 and I have exactly the same error. The exact same error appears on versions 8.1, 9.0 and 9.1. Two of them are EoL but 9.1 is still supported and the error is the same. I think problem is with the libusb libraries. cgminer was written for Linux and has a bug on FreeBSD with a libusb function call but I'm not good enough at C to debug it :(
 
Fair enough, I'll have a look at the source when/if I can find the time. What exactly does this cgminer thing do anyways?
 
Code:
bc@j182:~/src/cgminer % uname -a
FreeBSD j182.setjmp.lan 9.2-STABLE FreeBSD 9.2-STABLE #0 r260800: Fri Jan 17 02:22:08 EST 2014     root@gw.setjmp.lan:/usr/obj/usr/src/sys/SETJMP  amd64

And getting the same results. Most of the ports in that jail were current as of the src update which created it, and a few SVN updates in the ports tree since too.
 
I finally got success getting bfgminer compiling. :) It's working well as a CPU miner right now, though kind of sloppy and not a perfect port. I'm working on it and hope to be submitting within the week at least initial attempts with a semi solid build for what I needed for stratum mining. I had to port libblkmaker first, and that is pretty much done already :)
 
Back
Top