xmr-stak-cpu icon indicating copy to clipboard operation
xmr-stak-cpu copied to clipboard

How to build and run this on Mac OS X?

Open inder123 opened this issue 8 years ago • 31 comments

inder123 avatar May 26 '17 01:05 inder123

Here is what I did to compile successfully:

  1. install brew /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. install cmake brew install cmake
  3. cmake -DMICROHTTPD_REQUIRED=OFF -DOpenSSL_REQUIRED=OFF .
  4. Edit xmr-stak-cpu/minethd.cpp On line 51: change cpu_id with static_cast<integer_t>(cpu_id)
  5. make install

inder123 avatar May 26 '17 02:05 inder123

Hi, does skipping step 4 result in an error or a warning?

fireice-uk avatar May 26 '17 17:05 fireice-uk

Correct.. May be you can fix it in the code.

inder123 avatar May 26 '17 17:05 inder123

@fireice-uk Can you also explain the implication of -DMICROHTTPD_REQUIRED=OFF -DOpenSSL_REQUIRED=OFF

Does that result in an unsecure mining that someone can hack?

inder123 avatar May 26 '17 17:05 inder123

cmake -DMICROHTTPD_REQUIRED=OFF -DOpenSSL_REQUIRED=OFF .

You shouldn't need to disable OpenSSL - I was able to compile with homebrew OpenSSL on mac. I believe these were the steps, assuming you have the fix in #142 as well:

brew install cmake
brew install openssl
cmake -DMICROHTTPD_REQUIRED=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl .
make install

Note that I was not able to get large pages support working on mac. From searching around it looks like it can be tricky to get large pages working at all with mac memory management.

rsanheim avatar Jun 05 '17 06:06 rsanheim

@inder123 Nobody can "hack" mining, encryption enables you to hide the fact you are mining (at least at the general packet inspection level, for complete privacy you would need to TORify the traffic), and the amount that you mined from your ISP.

fireice-uk avatar Jun 05 '17 17:06 fireice-uk

I followed the steps described by @rsanheim and still got this two errors

/Users/sa/repos/xmr-stak-cpu/socket.cpp:196:8: error: no matching function for call to 'SSL_CTX_new'
        ctx = SSL_CTX_new(method);
              ^~~~~~~~~~~
/usr/include/openssl/ssl.h:1362:10: note: candidate function not viable: 1st argument ('const SSL_METHOD *' (aka 'const ssl_method_st *')) would lose const qualifier
SSL_CTX *SSL_CTX_new(SSL_METHOD *meth) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
         ^
/Users/sa/repos/xmr-stak-cpu/socket.cpp:202:82: error: use of undeclared identifier 'SSL_OP_NO_COMPRESSION'
                SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | SSL_OP_NO_COMPRESSION);
                                                                                               ^
/usr/include/openssl/ssl.h:582:39: note: expanded from macro 'SSL_CTX_set_options'
        SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL)

ismaproco avatar Jun 07 '17 21:06 ismaproco

@ismaproco You can always disable openssl via -DOpenSSL_REQUIRED=OFF

fireice-uk avatar Jun 10 '17 09:06 fireice-uk

@ismaproco What version of OSX are you using? Apple doesn't include openssl headers any more and I see it's looking at headers in /usr/include. I think they have other crypto libraries they want developers to use. I know on Sierra, openssl is still some version of 0.9.8. I'm pretty sure the headers are absent in El Capitan as well. It looks like it isn't using the headers from the version brew installed. I've only run this on El Capitan or Sierra myself and I usually compile with gcc.

ac0rnsoup avatar Jun 13 '17 02:06 ac0rnsoup

@rsanheim Granted, I have 16 gigs of memory, but I've never had issues getting large pages to work on my macs. If I get an error allocating the large pages, I have to restart. Have you tried a restart? Do you have a low amount of memory or automatically open a lot of apps on login?

Now, the aeon port is another story. I got large pages allocation errors on that across 4 different machines on a clean boot. But good old upstream xmr-stak-cpu started right up afterwards without issue.

ac0rnsoup avatar Jun 13 '17 02:06 ac0rnsoup

Granted, I have 16 gigs of memory, but I've never had issues getting large pages to work on my macs. If I get an error allocating the large pages,

@ac0rnsoup I'm not sure I follow you - are you saying large page support is working for you in xmr-stak-cpu, or in general with other programs?

On every mac I've tried xmr-stak-cpu, the large page support doesn't work, as you can see in the logs in startup:

[2017-06-13 16:09:00] : WARNING on MacOS thread affinity is only advisory.
[2017-06-13 16:09:00] : Starting single thread, affinity: 0.
[2017-06-13 16:09:01] : WARNING on MacOS thread affinity is only advisory.
[2017-06-13 16:09:01] : MEMORY ALLOC FAILED: mmap failed
[2017-06-13 16:09:01] : Starting single thread, affinity: 1.
[2017-06-13 16:09:01] : WARNING on MacOS thread affinity is only advisory.
[2017-06-13 16:09:01] : MEMORY ALLOC FAILED: mmap failed
[2017-06-13 16:09:01] : Starting single thread, affinity: 2.
[2017-06-13 16:09:01] : MEMORY ALLOC FAILED: mmap failed
[2017-06-13 16:09:01] : WARNING on MacOS thread affinity is only advisory.
[2017-06-13 16:09:01] : Starting single thread, affinity: 3.
[2017-06-13 16:09:02] : MEMORY ALLOC FAILED: mmap failed

This is across different mac models with different OS's, including Sierra and El Capitan. Granted, I'm definitely not a c / memory management expert 😄 - so my efforts to debug this have been minimal.

rsanheim avatar Jun 13 '17 21:06 rsanheim

Updating my mac build instructions here, which requires #154 until it gets merged. hwloc was merged in #108) which requires an additional dependency. This is on Mac OS Sierra 10.2.5, assumes you have homebrew installed. Using AppleClang 8.1.0.8020042 as the c compiler.

brew tap homebrew/science
brew install cmake
brew install openssl
brew install hwloc
cmake -DMICROHTTPD_ENABLE=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl .
make install

rsanheim avatar Jun 13 '17 21:06 rsanheim

@rsanheim tested using #154 and following the steps you suggested and it worked. Thanks!

ismaproco avatar Jun 14 '17 20:06 ismaproco

@rsanheim Sorry for the slow response. I wanted to test latest dev branch as I was using older code. I just compiled myself a new xmr-stak-cpu

Large pages are definitely still working for me on a macbook pro 2015 w dual core i7. It failed the first time with mmap errors like yours, and I got a hashrate of about 78h/s. I quit every application to make sure they didn't open on reboot, rebooted, the mmap memory went away and I get 120-126 h/s. FYI, this hardware gets the largest improvement I've seen. On the imacs I have, the improvement was less drastic but still very noticeable.

I do however get an error with the new hwloc stuff: hwloc: can't bind memory

I use gcc6 to compile. I have had large pages working on 8 macs, every one I tried, Sierra and El Capitan, although I only actively mine on 4 of them these days. I don't mine on the 2 macbook pros or 2 minis any more due to heat concerns, I don't care as much about the 4 imacs.

Maybe try gcc instead of clang? gcc just gives a warning, not failure, on the issue fixed with patch, so I don't patch it. I don't know what hwloc is, haven't looked into that.

ac0rnsoup avatar Jun 15 '17 01:06 ac0rnsoup

The first response of @inder123 worked straight forward on my Mac running Sierra

otmezger avatar Jun 15 '17 13:06 otmezger

Guys, can you please look here https://travis-ci.org/fireice-uk/xmr-stak-cpu/jobs/243759866 for the error?

Thank you...

ruzickap avatar Jun 16 '17 18:06 ruzickap

@ruzickap Yup, @fireice-uk needs to merge #154, which should fix that issue.

rsanheim avatar Jun 16 '17 18:06 rsanheim

I follow instructions and compile successfully on MAC . Could anybody tell me how to solve the problem(hwloc and mmap)?? thanks.

[2017-06-26 10:49:53] : WARNING on MacOS thread affinity is only advisory. [2017-06-26 10:49:53] : Starting single thread, affinity: 0. [2017-06-26 10:49:53] : WARNING on MacOS thread affinity is only advisory. [2017-06-26 10:49:53] : Starting single thread, affinity: 2. [2017-06-26 10:49:53] : WARNING on MacOS thread affinity is only advisory. [2017-06-26 10:49:53] : Starting single thread, affinity: 4. [2017-06-26 10:49:53] : Connecting to pool xmr.crypto-pool.fr:80 ... [2017-06-26 10:49:53] : hwloc: can't bind memory [2017-06-26 10:49:53] : hwloc: can't bind memory [2017-06-26 10:49:53] : hwloc: can't bind memory [2017-06-26 10:49:53] : MEMORY ALLOC FAILED: mmap failed [2017-06-26 10:49:53] : MEMORY ALLOC FAILED: mmap failed [2017-06-26 10:49:53] : MEMORY ALLOC FAILED: mmap failed

firawk avatar Jun 26 '17 03:06 firawk

@ac0rnsoup How can you tell if large pages are working? If I understand it right "MEMORY ALLOC FAILED: mmap failed" signal larges pages doesn't work, but hwloc binding is another memory mecanism? Mining works on my mac but can't see any differences between fireice-uk version and rsanheim (which I tried for the dev-mac branch, but I think I has been merged now). Sorry I'm quite new to xmr, still trying to squeeze any bit of perf.

EDIT: like others said before, after a reboot no nmap errors, but still no explaination for this odd behaviour

grashwandir avatar Aug 14 '17 18:08 grashwandir

@rsanheim

brew install cmake brew install openssl cmake -DMICROHTTPD_REQUIRED=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl .

here i get: CMake Error: The source directory "/Users/xxx" does not appear to contain CMakeLists.txt do I have to create this file? in /Users/xxx or do I have to change the directory in the terminal? (if so where?)

make install

BR

CybotDNA avatar Oct 05 '17 11:10 CybotDNA

@CybotDNA i just executed those successfully... the cmake command must be executed in the project folder / checkout. brew doesn't matter where. seems like u did it in another folder.

k3muri84 avatar Oct 30 '17 21:10 k3muri84

The commands above worked for me, but up until cmake.

brew tap homebrew/science
brew install cmake
brew install openssl
brew install hwloc
brew install libmicrohttpd
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl .
make install

make install fails with

xmrstak/backend/amd/amd_gpu/gpu.hpp:37:14: error: implicit instantiation of undefined template 'std::__1::basic_string<char,
      std::__1::char_traits<char>, std::__1::allocator<char> >'
        std::string name;
                    ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/iosfwd:193:32: note: template is declared here
    class _LIBCPP_TEMPLATE_VIS basic_string;
                               ^
1 error generated.
make[2]: *** [CMakeFiles/xmrstak_opencl_backend.dir/xmrstak/backend/amd/minethd.cpp.o] Error 1
make[1]: *** [CMakeFiles/xmrstak_opencl_backend.dir/all] Error 2
make: *** [all] Error 2

LucasArruda avatar Nov 21 '17 15:11 LucasArruda

@fabulouspanda binaries work for me, though http://macminer.fabulouspanda.com/commandline/xmrstakamd/

Maybe I need dev branch too.

LucasArruda avatar Nov 21 '17 15:11 LucasArruda

@LucasArruda have you tried https://github.com/fireice-uk/xmr-stak ? I haven't had time but I'll check it out when I do, that seems to be what's recommended now

fabulouspanda avatar Nov 21 '17 16:11 fabulouspanda

@fabulouspanda to tell you the truth I'm kinda new in this mining world. I checked that but found no binaries for Mac, just Linux and Windows. Though on the source apparently there are bin compatibles with a Mac. I'll try it.

LucasArruda avatar Nov 21 '17 22:11 LucasArruda

Adding the dev branch worked for me. brew tap homebrew/science brew install cmake brew install openssl brew install hwloc brew install libmicrohttpd cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl . git checkout dev make install

ghost avatar Nov 22 '17 22:11 ghost

I hit this issue as well and got them all compiled after hell and back :) if you want the final bins I posted them for safe keeping this time lol: https://github.com/killswitch-GUI/xmr-stak-osx

killswitch-GUI avatar Nov 30 '17 01:11 killswitch-GUI

Using the latest xmr-stak code (https://github.com/fireice-uk/xmr-stak) all I had to do was:

brew install cmake openssl hwloc libmicrohttpd
git clone https://github.com/fireice-uk/xmr-stak.git
cd xmr-stak
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DCUDA_ENABLE=OFF .
make install
./bin/xmr-stak 

johnathanmay avatar Dec 24 '17 16:12 johnathanmay

Can we please add this to the documentation? Finally found this!

evanjmg avatar Jan 21 '18 15:01 evanjmg

agreed, @evanjmg @fireice-uk ?

LucasArruda avatar Jan 22 '18 18:01 LucasArruda