Author

Topic: Compiling with Visual Studio (Read 5558 times)

rlh
hero member
Activity: 804
Merit: 1004
December 13, 2013, 10:58:44 AM
#9
A lot has changed since 2011.  Has anyone updated this instruction set for the more recent version of Bitcoin?
https://bitcoinqtmsvc2012.codeplex.com/
Thank you!
legendary
Activity: 2058
Merit: 1452
December 13, 2013, 10:52:59 AM
#8
A lot has changed since 2011.  Has anyone updated this instruction set for the more recent version of Bitcoin?
https://bitcoinqtmsvc2012.codeplex.com/
rlh
hero member
Activity: 804
Merit: 1004
December 13, 2013, 10:51:16 AM
#7
A lot has changed since 2011.  Has anyone updated this instruction set for the more recent version of Bitcoin?
newbie
Activity: 13
Merit: 0
July 01, 2011, 05:35:46 AM
#6
Thank you, EricJ2190.

I tried to build with your makefile and achieved success.
full member
Activity: 134
Merit: 102
June 30, 2011, 10:09:39 PM
#5
I got it to build and run using the following modified version of makefile.vc:
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"C:\bitcoin-build\boost_1_46_1" \
  /I"C:\bitcoin-build\db-4.7.25\build_windows" \
  /I"C:\bitcoin-build\openssl-1.0.0d\include" \
  /I"C:\bitcoin-build\wxWidgets-2.9.1\lib\vc_lib\mswu" \
  /I"C:\bitcoin-build\wxWidgets-2.9.1\include" \
  /I"C:\bitcoin-build\miniupnpc-1.5.20110215"

LIBPATHS= \
  /LIBPATH:"C:\bitcoin-build\boost_1_46_1\stage\lib" \
  /LIBPATH:"C:\bitcoin-build\db-4.7.25\build_windows\Release" \
  /LIBPATH:"C:\bitcoin-build\openssl-1.0.0d\out32dll" \
  /LIBPATH:"C:\bitcoin-build\wxWidgets-2.9.1\lib\vc_lib" \
  /LIBPATH:"C:\bitcoin-build\upnpc-exe-win32-20110215" \
  /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib \
  /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib \
  /NODEFAULTLIB:msvcrtd.lib

WXLIBS=wxmsw29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib

LIBS= \
  libboost_system-vc100-mt.lib \
  libboost_filesystem-vc100-mt.lib \
  libboost_program_options-vc100-mt.lib \
  libboost_thread-vc100-mt.lib \
  libdb47s.lib \
  libeay32.lib \
  miniupnpc.lib \
  kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib ws2_32.lib shlwapi.lib

DEFS=/DWIN32 /D__WXMSW__ /D_WINDOWS /DNOPCH /DNOMINMAX /DUSE_UPNP
DEBUGFLAGS=/Os
CFLAGS=/MD /c /nologo /EHsc /GR /Zm300 $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
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.obj \
    obj\script.obj \
    obj\db.obj \
    obj\net.obj \
    obj\irc.obj \
    obj\main.obj \
    obj\rpc.obj \
    obj\init.obj

CRYPTOPP_OBJS= \
    cryptopp\obj\sha.obj \
    cryptopp\obj\cpu.obj


all: bitcoin.exe


.cpp{obj}.obj:
    cl $(CFLAGS) /DGUI /Fo$@ %s

obj\util.obj: $(HEADERS)

obj\script.obj: $(HEADERS)

obj\db.obj: $(HEADERS)

obj\net.obj: $(HEADERS)

obj\irc.obj: $(HEADERS)

obj\main.obj: $(HEADERS)

obj\rpc.obj: $(HEADERS)

obj\init.obj: $(HEADERS)

obj\ui.obj: $(HEADERS)

obj\uibase.obj: $(HEADERS)

cryptopp\obj\sha.obj: cryptopp\sha.cpp
    cl $(CFLAGS) /O2 /DCRYPTOPP_DISABLE_ASM /Fo$@ %s

cryptopp\obj\cpu.obj: cryptopp\cpu.cpp
    cl $(CFLAGS) /O2 /DCRYPTOPP_DISABLE_ASM /Fo$@ %s

obj\ui.res: ../share/ui.rc ../share/pixmaps/bitcoin.ico ../share/pixmaps/check.ico ../share/pixmaps/send16.bmp ../share/pixmaps/send16mask.bmp ../share/pixmaps/send16masknoshadow.bmp ../share/pixmaps/send20.bmp ../share/pixmaps/send20mask.bmp ../share/pixmaps/addressbook16.bmp ../share/pixmaps/addressbook16mask.bmp ../share/pixmaps/addressbook20.bmp ../share/pixmaps/addressbook20mask.bmp
    rc $(INCLUDEPATHS) $(DEFS) /Fo$@ %s

bitcoin.exe: $(OBJS) $(CRYPTOPP_OBJS) obj\ui.obj obj\uibase.obj obj\ui.res
    link /nologo /SUBSYSTEM:WINDOWS /OUT:$@ $(LIBPATHS) $** $(WXLIBS) $(LIBS)


.cpp{obj\nogui}.obj:
    cl $(CFLAGS) /Fo$@ %s

obj\nogui\util.obj: $(HEADERS)

obj\nogui\script.obj: $(HEADERS)

obj\nogui\db.obj: $(HEADERS)

obj\nogui\net.obj: $(HEADERS)

obj\nogui\irc.obj: $(HEADERS)

obj\nogui\main.obj: $(HEADERS)

obj\nogui\rpc.obj: $(HEADERS)

obj\nogui\init.obj: $(HEADERS)

bitcoind.exe: $(OBJS:obj\=obj\nogui\) $(CRYPTOPP_OBJS) obj\ui.res
    link /nologo /OUT:$@ $(LIBPATHS) $** $(LIBS)


clean:
    -del /Q obj\*
    -del /Q obj\nogui\*
    -del /Q cryptopp\obj\*
    -del /Q *.ilk
    -del /Q *.pdb

If you use this, you'll want to set INCLUDEPATHS and LIBPATHS to your own library locations.

The changes I made are:
  • Updated location of resources used to build ui.res.
  • Moved list of CryptoPP objects from OBJ to its own CRYPTOPP_OBJ since they don't have seperate nogui versions.
  • Added MiniUPnP library and USE_UPNP define.
  • Added NOMAXMIN define to remove certain incompatible macros.

Also, for wxWidgets, make sure you either edit config.vc to make a release build before building, or modify this makefile to use the default debug build.

Edit: Spoke too soon. After running for a few seconds, my Bitcoin build is being terminated by DEP. This applies to both bitcoin.exe and bitcoind.exe. I'll look into this more later.

It appears the issue was with MiniUPnP. I have been completely unsuccessful of making my own build of miniupnpc.lib using VC, so I built it without UPnP entirely. In order to build Bitcoin without USE_UPNP defined, I had to make a small modification to net.cpp by added the following lines after the MapPort function:
Code:
#else
void MapPort(bool fMapPort) {}
This gives a us MapPort function to use when USE_UPNP is not defined.

More Edit: D'oh! I forgot to copy the MiniUPnP DLL to the same directory as bitcoin.exe when using the prebuilt MiniUPnP. That solves the DEP issue.
full member
Activity: 134
Merit: 102
June 30, 2011, 07:51:45 PM
#4
It has been a while since I last built Bitcoin on MSVC. I tried to do it today so I could explain how I did it, and it seems the VC makefile is broken. I am going work on trying to fix it up, and I'll let you know when I get it to compile.
newbie
Activity: 13
Merit: 0
June 30, 2011, 04:04:59 PM
#3
If you haven't done so, you need to edit your makefile to make sure it's INCLUDEPATHS and LIBPATHS point to the proper directory of your libraries.

If that isn't it, can you post the error?

After launch Bitcoin.exe throws an Access violation exception in function _initterm_e. It even not enters in WinMain function.
Also Dependency Walker sais "Error processing the module's imports table".

This is my parameters of compilation:
cl /MDd /c /nologo /EHsc /GR /Zm300 /Zi /Os /D_DEBUG /DWIN32 /D__WXMSW__ /D_WINDOWS /DNOPCH /DUSE_UPNP /I"../../boost_1_43_0"  /I"../../db-4.7.25.NC/build_windows"  /I"../../openssl-1.0.0d/include"  /I"../../wxwidgets-2.9.1/lib/vc_lib/mswud"  /I"../../wxwidgets-2.9.1/include"  /I"../../upnpc-exe-win32-20110215" /DGUI /Foobj\util.obj util.cpp util.cpp

This is my parameters of linking:
link /nologo /SUBSYSTEM:WINDOWS /DEBUG /OUT:bitcoin.exe /LIBPATH:"../../boost_1_43_0/stage/lib"  /LIBPATH:"../../db-4.7.25.NC/build_windows/Debug"  /LIBPATH:"../../openssl-1.0.0d/out32dll"  /LIBPATH:"../../wxwidgets-2.9.1/lib/vc_lib" obj\util.obj obj\script.obj obj\db.obj obj\net.obj obj\irc.obj obj\main.obj obj\rpc.obj obj\init.obj cryptopp\obj\sha.obj cryptopp\obj\cpu.obj obj\ui.obj obj\uibase.obj obj\ui.res wxmsw29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib libboost_system-vc100-mt-gd.lib  libboost_filesystem-vc100-mt-gd.lib  libboost_program_options-vc100-mt-gd.lib  libboost_thread-vc100-mt-gd.lib  libdb47d.lib  libeay32.lib  "../../upnpc-exe-win32-20110215/miniupnpc.lib"  kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib ws2_32.lib shlwapi.lib
 
Could you show your parameters of compilation\linking?
full member
Activity: 134
Merit: 102
June 30, 2011, 02:24:06 PM
#2
If you haven't done so, you need to edit your makefile to make sure it's INCLUDEPATHS and LIBPATHS point to the proper directory of your libraries.

If that isn't it, can you post the error?
newbie
Activity: 13
Merit: 0
June 30, 2011, 07:02:17 AM
#1
Hi all!

I am trying to build bitcoin with VC2010 Express. It compiles but doesn't work.
I think the problem is in inconsistency between compilation/linking keys of libraries and bitcoin.

As far as I understand, there are many guys here who builds bitcoin with some version
of Visual Studio. Could you help me, please? I want to build buitcoin with any Visual Studio version.
Could you share your project file and tell how you build libraries?
Or maybe there is a ready link for this?

I build libraries in this way:

cd wxWidgets-2.9.1\build\msw
nmake -f makefile.vc

cd openssl-1.0.0d
perl Configure VC-WIN32 no-asm
ms\do_ms
nmake -f ms\ntdll.mak

db-4.7.25.NC\build_windows\Berkeley_DB.dsw

cd boost-1.43.0
bootstrap (makes bjam)
bjam toolset=msvc-10.0 threading=multi --build-type=complete stage

Get upnpc-exe-win32-20110215.zip and unzip it to \upnpc-exe-win32-20110215
Get miniupnpc-1.5.20110215.tar.gz and copy *.h to \upnpc-exe-win32-20110215\miniupnpc

Thanks!
Jump to: