Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: The Madhatter on July 15, 2010, 03:32:04 PM



Title: HOWTO: Compiling Bitcoin v0.3 on FreeBSD (7.2,7.3,8.0)
Post by: The Madhatter on July 15, 2010, 03:32:04 PM
Step 1:

Install the following from the ports tree:

x11-toolkits/gtk20
devel/boost-all
devel/gmake
databases/db48

Step 2:

Install wxWidgets 2.9 from source. The ports version won't work.

You can get 2.9 here: http://prdownloads.sourceforge.net/wxwindows/wxWidgets-2.9.0.tar.bz2

Step 3:

Apply the attached patch to the "makefile.unix" file.

cd ~/bitcoin-0.3/src/
patch < makefile.unix.patch.txt

Step 4:

Tweak any compiler options in makefile.unix. (See the CFLAGS line). The default options are the options I use on my machines. They are: "-O3 -march=nocona -fstack-protector". Be sure to set your 'march' at the very least.

Step 5:

Build with:

gmake -f makefile.unix bitcoind

And enjoy! :)

$ cat ~/.bitcoin/debug.log |grep "Bitcoin version"
Bitcoin version 0.3.0 beta, OS version FreeBSD 8.0-RELEASE-p3 amd64
$


And what about performance? It's insanely great on FreeBSD. Especially with the ULE scheduler.

CPU: Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz (2666.38-MHz K8-class CPU)
hashmeter   4 CPUs   2585 khash/s


:D


Title: Re: HOWTO: Compiling Bitcoin v0.3 on FreeBSD (7.2,7.3,8.0)
Post by: Dereckson on September 20, 2010, 09:17:23 PM
Good evening,

Thank you for your howto, it allows me to prepare a FreeBSD port for Bitcoin.

Could you attach makefile.unix.patch.txt your patch? It seems you forgot it.


Title: Re: HOWTO: Compiling Bitcoin v0.3 on FreeBSD (7.2,7.3,8.0)
Post by: The Madhatter on September 20, 2010, 11:44:13 PM
I didn't forget to attach it. Look again.


Title: Re: HOWTO: Compiling Bitcoin v0.3 on FreeBSD (7.2,7.3,8.0)
Post by: Hiro Protagonist on October 15, 2010, 04:42:16 AM
Good evening,

Thank you for your howto, it allows me to prepare a FreeBSD port for Bitcoin.

Any status on the FreeBSD port?

Thanks for this HOWTO. Any ideas on the best way to run bitcoind as a daemon on the system?


Title: Re: HOWTO: Compiling Bitcoin v0.3 on FreeBSD (7.2,7.3,8.0)
Post by: The Madhatter on October 15, 2010, 04:57:00 AM
Each time I am close to submitting a port, the codebase/makefiles change. I'm waiting until the development of Bitcoin dies down a tad before I work on the port again.

Compiling it on FreeBSD is easier now. You just have to enable a define, adjust some library/include paths, and it compiles and runs great. :)


Title: Re: HOWTO: Compiling Bitcoin v0.3 on FreeBSD (7.2,7.3,8.0)
Post by: lucky on January 03, 2011, 01:37:42 AM
Compiling it on FreeBSD is easier now. You just have to enable a define, adjust some library/include paths, and it compiles and runs great. :)


Could you (or someone else) explain that a bit further?  I've been trying to get 0.3.19 it to compile on FBSD for about half an hour now with no success.


Title: Re: HOWTO: Compiling Bitcoin v0.3 on FreeBSD (7.2,7.3,8.0)
Post by: Metal on January 07, 2011, 04:04:39 AM
It seems that the original makefile.unix won't work as-is for most folks.

In my case, I had to use the output of `wx-config --cflags` and `wx-config --libs` to make the build work on a ubuntu hardy box (thanks to Diablo-3D for pointing me in the right direction.)

Are we okay with having a few build recipes hanging around old forum posts, or should there be an attempt at foolproofing the build process a bit?

Maybe some light autoconf/automake use would help here.



Title: Re: HOWTO: Compiling Bitcoin v0.3 on FreeBSD (7.2,7.3,8.0)
Post by: The Madhatter on January 07, 2011, 04:12:45 AM
Here is the complete makefile.unix that I used to build Bitcoin 0.3.19 on FreeBSD-8.1-RELEASE/amd64:

You'll need to install the following from ports:

gmake
boost-all
db47 (you can use db48, but you'll have to change the makefile a bit)
openssl (from ports works best)

After you drop in this makefile.unix file, just run "gmake -f makefile.unix bitcoind" and you'll have a "bitcoind" binary. :)

Code:
# Copyright (c) 2009-2010 Satoshi Nakamoto
# Distributed under the MIT/X11 software license, see the accompanying
# file license.txt or http://www.opensource.org/licenses/mit-license.php.

INCLUDEPATHS= \
 -I"/usr/local/include/wx-2.9" \
 -I"/usr/local/lib/wx/include/gtk2-unicode-release-2.9" \
 -I"/usr/local/include/db47" \
 -I"/usr/local/include"

LIBPATHS= \
 -L"/usr/local/lib/db47" \
 -L"/usr/local/lib" \
 -L"/usr/lib"

# for wxWidgets 2.9.1, add -l Xxf86vm
WXLIBS= \
 -Wl,-Bstatic \
   -l wx_gtk2ud-2.9 \
 -Wl,-Bdynamic \
   -l gtk-x11-2.0 \
   -l SM


# for boost 1.37, add -mt to the boost libraries
#LIBS= \
# -Wl,-Bstatic \
#   -l boost_system \
#   -l boost_filesystem \
#   -l boost_program_options \
#   -l boost_thread \
#   -l db_cxx \
#   -l crypto \
# -Wl,-Bdynamic

# for boost 1.37, add -mt to the boost libraries
LIBS= \
 -Wl,-Bstatic \
   -l boost_system \
   -l boost_filesystem \
   -l boost_program_options \
   -l boost_thread \
   -l db_cxx \
   -l ssl \
   -l crypto \
 -Wl,-Bdynamic \
   -l z \
   -l pthread

DEFS=-D__WXGTK__ -DNOPCH -DFOURWAYSSE2 -DUSE_SSL -D__BSD__
DEBUGFLAGS=-g -D__WXDEBUG__
CFLAGS=-O2 -march=nocona -fstack-protector -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) $(LIBPATHS)
HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \
    script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h noui.h init.h

OBJS= \
    obj/util.o \
    obj/script.o \
    obj/db.o \
    obj/net.o \
    obj/irc.o \
    obj/main.o \
    obj/rpc.o \
    obj/init.o \
    cryptopp/obj/sha.o \
    cryptopp/obj/cpu.o


all: bitcoin


obj/%.o: %.cpp $(HEADERS)
        g++ -c $(CFLAGS) -DGUI -o $@ $<

cryptopp/obj/%.o: cryptopp/%.cpp
        g++ -c $(CFLAGS) -O3 -o $@ $<

obj/sha256.o: sha256.cpp
        g++ -c $(CFLAGS) -msse2 -O3 -march=nocona -o $@ $<

bitcoin: $(OBJS) obj/ui.o obj/uibase.o obj/sha256.o
        g++ $(CFLAGS) -o $@ $^ $(WXLIBS) $(LIBS)


obj/nogui/%.o: %.cpp $(HEADERS)
        g++ -c $(CFLAGS) -o $@ $<

bitcoind: $(OBJS:obj/%=obj/nogui/%) obj/sha256.o
        g++ $(CFLAGS) -o $@ $^ $(LIBS)


clean:
        -rm -f obj/*.o
        -rm -f obj/nogui/*.o
        -rm -f cryptopp/obj/*.o
        -rm -f headers.h.gch

Edit: If you want the GUI you'll need to install "x11-toolkits/gtk20" from ports, and install wxwidgets 2.9 from source (it's not in the ports tree). Use the makefile above and run "gmake -f makefile.unix bitcoin".


Title: Re: HOWTO: Compiling Bitcoin v0.3 on FreeBSD (7.2,7.3,8.0)
Post by: Gavin Andresen on January 07, 2011, 05:23:32 PM
Great!  I'd like to see this good work make it back into mainline bitcoin; please talk with the other improve-the-build-process efforts and submit some patches.


Title: Re: HOWTO: Compiling Bitcoin v0.3 on FreeBSD (7.2,7.3,8.0)
Post by: gelraen on May 20, 2011, 12:10:27 PM
Now bitcoin from git repo works fine with databases/db46 and x11-toolkits/wxgtk29

Code:
Bitcoin version 0.3.22-beta
OS version FreeBSD 8.2-STABLE i386


Code:
diff --git a/src/makefile.unix b/src/makefile.unix
index 4f2da37..23bf964 100644
--- a/src/makefile.unix
+++ b/src/makefile.unix
@@ -4,9 +4,9 @@
 
 CXX=g++
 
-WXINCLUDEPATHS=$(shell wx-config --cxxflags)
+WXINCLUDEPATHS=$(shell wxgtk2u-2.9-config --cxxflags)
 
-WXLIBS=$(shell wx-config --libs)
+WXLIBS=$(shell wxgtk2u-2.9-config --libs)
 
 USE_UPNP:=0
 
@@ -32,12 +32,11 @@ LIBS+= \
  -Wl,-Bdynamic \
    -l gthread-2.0 \
    -l z \
-   -l dl \
    -l pthread
 
 
 DEBUGFLAGS=-g -D__WXDEBUG__
-CXXFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS)
+CXXFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) -I/usr/local/include -I/usr/local/include/db46 -L/usr/local/lib -L/usr/local/lib/db46
 HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \
     script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h noui.h init.h


Title: Re: HOWTO: Compiling Bitcoin v0.3 on FreeBSD (7.2,7.3,8.0)
Post by: Vladimir on May 22, 2011, 10:13:01 AM
This is of course based on published above excellent guide. Thanks to The Madhatter.

However, instead of all that, now one can simply do this:

cd /usr/ports/net-p2p/bitcoin; make install clean; rehash

you will even have a chance to select/deselect GUI and upnp stuff.