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

Create native support for MSVC #17

Closed
ben-crowhurst opened this issue Jul 10, 2015 · 11 comments
Closed

Create native support for MSVC #17

ben-crowhurst opened this issue Jul 10, 2015 · 11 comments
Assignees
Labels
Milestone

Comments

@ben-crowhurst
Copy link
Member

We've had a fair amount of success with Visual Studio 2015.

@nViso
Copy link

nViso commented Aug 30, 2015

Hi,

We'd like to try the project on VS2015, is it possible to add support for this compiler?

Thanks,
Tim

@ben-crowhurst
Copy link
Member Author

This functionality has been in beta for sometime and should be available in the next week or two. Currently we're addressing the OpenSSL situation to help ease VS2015 integration.

@ben-crowhurst ben-crowhurst added this to the 3.5 milestone Aug 31, 2015
@naedanger
Copy link
Contributor

Its now possible to build restbed in windows.

The build has been tested with Visual Studio 2015 Community Edition (compiler version 19.00.23026). You can use cmake to generate a VS project file or NMake files using the instructions below.

Examples that dont require OpenSSL, Syslog or PAM all build. The tests have not yet been ported. SSL support is not yet operational but this is just a matter of modifying cmake files to find the binaries on windows.

To create a Visual Studio project file, type the following at a command prompt or directly in GIT Bash (assuming cmake is in your path):

mkdir build && cd build
cmake -DBUILD_SSL=OFF -DBUILD_EXAMPLES=ON -G "Visual Studio 14 2015" ..

To use NMake, open a Visual Studio Command Prompt and navigate to restbed directory:

mkdir build && cd build
cmake -DBUILD_SSL=OFF -DBUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Release -G "NMake Makefiles" ..
nmake

@ben-crowhurst
Copy link
Member Author

The following helps to avoid the pain of opening the resource hog that is Visual Studio.

cmake -G "Visual Studio 14 2015" -DBUILD_SSL=NO -DBUILD_EXAMPLES=YES -DBUILD_TESTS=YES ..
cmake --build . --target ALL_BUILD --config Release
ctest

@ben-crowhurst
Copy link
Member Author

ben-crowhurst commented Sep 6, 2015

I can confirm that Restbed now builds natively on Windows with Visual Studio 2015. What follows is a set of instructions and any errors we have encountered along the way. I'm not going to close this ticket as several build warnings (unreachable code) still remain around test cases. These issues appear to be caused by our choice of framework.

Environment

  • Windows 8.1 x64
  • Visual Studio (CE) 14 2015

Setup
To address the resource problem and excessive file indexing caused by Visual Studio. We have opted to build the project using the Visual Studio 2015 x64 Native Tools Command Prompt. If your environment differs x86/ARM, please ensure you open the correct prompt. You MUST build Restbed and any dependencies (OpenSSL) via the same prompt to ensure x64 compatibility.

Once you've built the project and it's dependencies you can confirm you have the right build by checking each library as follows; they should produce matching output 8664 machine (x64) in our case.

dumpbin libeay32.dll /headers | findstr machine
dumpbin ssleay32.dll /headers | findstr machine
dumpbin restbed.lib /headers | findstr machine

Build OpenSSL
These instructions differ on x86/ARM platforms, please see dependency\openssl\INSTALL.* for details.

cd restbed\dependency\openssl
perl Configure VC-WIN64A
ms\do_win64a
nmake -f ms\ntdll.mak
nmake -f ms\ntdll.mak test
set PATH=restbed\dependency\openssl\out32dll;%PATH%

If you need to generate an SSL certificate you will additionally have to install OpenSSL.

nmake -f ms\ntdll.mak install
set PATH=%PATH%;c:\usr\local\ssl\bin

We will move to C:\tmp so the new certificate will work with the HTTPS example. The following must be performed in "Run As Administrator" mode to work, otherwise unable to write 'random state' errors will occur.

mkdir \tmp
cd \tmp
openssl genrsa -out server.key 1024
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
openssl dhparam -out dh768.pem 768

Build Restbed

cd restbed
mkdir build
cd build
cmake -G "Visual Studio 14 2015 Win64" -DBUILD_EXAMPLES=YES -DBUILD_TESTS=YES ..
cmake --build . --target ALL_BUILD --config Release
ctest

@nViso
Copy link

nViso commented Sep 14, 2015

While building OpenSSL with Visual Studio 2015 on Windows 10 we are getting this error. What was your build environment for compiling OpenSSL?

C:\workspace\scratch\restbed-master\dependency\openssl>nmake -f ms\ntdll.mak

Microsoft (R) Program Maintenance Utility Version 14.00.23026.0
Copyright (C) Microsoft Corporation.  All rights reserved.

Building OpenSSL

perl .\util\copy-if-different.pl ".\crypto\buildinf.h" "tmp32dll\buildin
f.h"

Copying: ./crypto/buildinf.h to tmp32dll/buildinf.h

perl .\util\copy-if-different.pl ".\crypto\opensslconf.h" "inc32\openssl
\opensslconf.h"

NOT copying: ./crypto/opensslconf.h to inc32/openssl/opensslconf.h
ml64 /c /Cp /Cx /Zi /Fotmp32dll\x86_64cpuid.obj tmp32dll\x86_64cpuid.asm

Microsoft (R) Macro Assembler (x64) Version 14.00.23026.0
Copyright (C) Microsoft Corporation.  All rights reserved.

Assembling: tmp32dll\x86_64cpuid.asm
tmp32dll\x86_64cpuid.asm(1) : error A2088:END directive required at end of file
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0
\VC\BIN\amd64\ml64.EXE"' : return code '0x1'
Stop.

@nViso
Copy link

nViso commented Sep 14, 2015

The static library is building fine : nmake -f ms\nt.mak

@ben-crowhurst
Copy link
Member Author

@nViso If I recall correctly, this error was due to an OpenSSL build issue/bug. Please reset the OpenSSL folder to its original state.

Reset

cd restbed
git deinit -f dependency/openssl
git submodule update --init dependency/openssl

Confirm everything has reverted to its original state.

cd dependency/openssl
git status
HEAD detacted at 2df619b
nothing to commit, working directory clean

Configure Stage 1

perl Configure VC-WIN64A

Output

Configuring for VC-WIN64A
    no-ec_nistp_64_gcc_128 [default]  OPENSSL_NO_EC
    no-gmp          [default]  OPENSSL_NO_GMP (skip
    no-jpake        [experimental] OPENSSL_NO_JPAKE
    no-krb5         [krb5-flavor not specified] OPE
    no-libunbound   [experimental] OPENSSL_NO_LIBUN
    no-md2          [default]  OPENSSL_NO_MD2 (skip
    no-rc5          [default]  OPENSSL_NO_RC5 (skip
    no-rfc3779      [default]  OPENSSL_NO_RFC3779 (
    no-sctp         [default]  OPENSSL_NO_SCTP (ski
    no-shared       [default]
    no-ssl-trace    [default]  OPENSSL_NO_SSL_TRACE
    no-store        [experimental] OPENSSL_NO_STORE
    no-unit-test    [default]  OPENSSL_NO_UNIT_TEST
    no-zlib         [default]
    no-zlib-dynamic [default]
IsMK1MF=1
CC            =cl
CFLAG         =-DOPENSSL_THREADS  -DDSO_WIN32 -W3 -
O_DEPRECATE -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MO
AES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DE
EX_LIBS       =
CPUID_OBJ     =x86_64cpuid.o
BN_ASM        =bn_asm.o x86_64-mont.o x86_64-mont5.
EC_ASM        =ecp_nistz256.o ecp_nistz256-x86_64.o
DES_ENC       =des_enc.o fcrypt_b.o
AES_ENC       =aes-x86_64.o vpaes-x86_64.o bsaes-x8
BF_ENC        =bf_enc.o
CAST_ENC      =c_enc.o
RC4_ENC       =rc4-x86_64.o rc4-md5-x86_64.o
RC5_ENC       =rc5_enc.o
MD5_OBJ_ASM   =md5-x86_64.o
SHA1_OBJ_ASM  =sha1-x86_64.o sha256-x86_64.o sha512
RMD160_OBJ_ASM=
CMLL_ENC      =cmll-x86_64.o cmll_misc.o
MODES_OBJ     =ghash-x86_64.o aesni-gcm-x86_64.o
ENGINES_OBJ   =
PROCESSOR     =
RANLIB        =true
ARFLAGS       =
PERL          =perl
SIXTY_FOUR_BIT mode
DES_INT used
RC4_CHUNK is unsigned long long

Configured for VC-WIN64A.

Configure Stage 2

ms\do_win64a

Output

perl util\mkfiles.pl  1>MINFO
cmd /c "nasm -f win64 -v"  1>NUL 2>&1
if 0 NEQ 0 goto ml64
perl ms\uplink-x86_64.pl nasm  1>ms\uptable.asm
nasm -f win64 -o ms\uptable.obj ms\uptable.asm
goto proceed
perl util\mk1mf.pl VC-WIN64A  1>ms\nt.mak
perl util\mk1mf.pl dll VC-WIN64A  1>ms\ntdll.mak
perl util\mkdef.pl 32 libeay  1>ms\libeay32.def
perl util\mkdef.pl 32 ssleay  1>ms\ssleay32.def

Build

nmake -f ms\ntdll.mak
nmake -f ms\ntdll.mak test

Environment

Asset Version
Operating System Microsoft Windows 8.1, 64-bit OS, x64-based processor
Processor Intel Core i3-2365M CPU @ 1.40GHz
RAM 4.00 GB (2.89 GB usable)
Command Prompt VS2015 x64 Native Tools
Visual Studio Community 2015 Version 14.0.23107.10
Visual Studio 2015 SDK - ENU Version 14.0.23107.10
Microsoft Visual C++ 2015 Redistributable (x64) 14.0.23026.0
Perl Active Perl 5, Version 20, SubVersion 2 (v5.20.2) build for MSWin32-x64 multi-thread
nasm Version 2.11.08 Complied on Feb 21 2015
nmake Microsoft Program Maintenance Utility Version 14.00.23026.0

@ben-crowhurst
Copy link
Member Author

@nViso Alternatively I can make the shared library available to you via download?

@Puneetsharma030
Copy link

Puneetsharma030 commented May 18, 2016

HI,

I tried to build with openssl support and was able to generate visual studio project files with cmake. But when I try to compile the project, it throws many errors from "asio/ssl/" dependency. I would really appreciate if I could get any lead.
Thanks

@ben-crowhurst
Copy link
Member Author

@Puneetsharma030 Please open a new ticket including as much detail as you can.

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

No branches or pull requests

4 participants