Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to build and run this on Mac OS X? #124

Open
inder123 opened this issue May 26, 2017 · 31 comments
Open

How to build and run this on Mac OS X? #124

inder123 opened this issue May 26, 2017 · 31 comments

Comments

@inder123
Copy link

No description provided.

@inder123
Copy link
Author

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

@fireice-uk
Copy link
Owner

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

@inder123
Copy link
Author

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

@inder123
Copy link
Author

@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?

@rsanheim
Copy link
Contributor

rsanheim commented Jun 5, 2017

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.

@fireice-uk
Copy link
Owner

fireice-uk commented Jun 5, 2017

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

@ismaproco
Copy link

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)

@fireice-uk
Copy link
Owner

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

@ac0rnsoup
Copy link

@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
Copy link

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

@rsanheim
Copy link
Contributor

rsanheim commented Jun 13, 2017

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
Copy link
Contributor

rsanheim commented Jun 13, 2017

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

@ismaproco
Copy link

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

@ac0rnsoup
Copy link

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

@otmezger
Copy link

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

@ruzickap
Copy link
Contributor

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

Thank you...

@rsanheim
Copy link
Contributor

rsanheim commented Jun 16, 2017

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

@firawk
Copy link

firawk commented Jun 26, 2017

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

@grashwandir
Copy link

grashwandir commented Aug 14, 2017

@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

@CybotDNA
Copy link

CybotDNA commented Oct 5, 2017

@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

@k3muri84
Copy link

k3muri84 commented Oct 30, 2017

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

@LucasArruda
Copy link

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
Copy link

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

Maybe I need dev branch too.

@fabulouspanda
Copy link

@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

@LucasArruda
Copy link

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

@ghost
Copy link

ghost commented Nov 22, 2017

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

@killswitch-GUI
Copy link

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

@johnathanmay
Copy link

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 

@evanjmg
Copy link

evanjmg commented Jan 21, 2018

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

@LucasArruda
Copy link

agreed, @evanjmg
@fireice-uk ?

@evanjmg
Copy link

evanjmg commented Jan 22, 2018

Made a PR fireice-uk/xmr-stak#948

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests