# problem compilation soft cgminer



## evolvia (Dec 6, 2013)

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:

```
------------------------------------------------------------------------
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:

```
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:

```
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 

```
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:

```
#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:

```
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:

```
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.


----------



## SirDice (Dec 6, 2013)

Keep in mind that FreeBSD 8.1 is not supported anymore, it's been end-of-life since July 2012.

http://www.freebsd.org/security/unsupported.html


----------



## evolvia (Dec 6, 2013)

*I* know but *I* have the same problem with a fresh install of 9.0*.*


----------



## fonz (Dec 6, 2013)

Please see the link @SirDice posted. FreeBSD 9.0 has been EoL for almost a year as well now.


----------



## evolvia (Dec 6, 2013)

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


----------



## fonz (Dec 6, 2013)

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?


----------



## evolvia (Dec 6, 2013)

cgminer is Bitcoin mining software. it detects USB devices and pools work to the USB device. The USB devices are cryptographic devices.

Links to explain more:
https://en.bitcoin.it/wiki/Mining
https://en.bitcoin.it/wiki/Mining_Hardware_Comparison

cgmineris designed by me with specific ASIC, FPGA and GPU hardware.


----------



## setjmp (Jan 29, 2014)

```
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.


----------



## setjmp (Jan 30, 2014)

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


----------



## evolvia (Jan 30, 2014)

Hi,

I have already compiled bfgminer, but *I* have a problem with it too, bfgmliner didn't detect my USB device 

I have posted  my probleme here, but *I* didn't get any answer 

https://bitcointalk.org/index.php?topic=357139.0


----------



## Peter2121 (Feb 10, 2014)

As for CPU mining - _pooler cpuminer_ works fine OOB (just clone the Git repository and compile)*.*
https://github.com/pooler/cpuminer


----------

