Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Windows compiling error with mvsc #131

Open
1 task done
Hirobreak opened this issue Sep 19, 2019 · 2 comments
Open
1 task done

Windows compiling error with mvsc #131

Hirobreak opened this issue Sep 19, 2019 · 2 comments

Comments

@Hirobreak
Copy link

I have:

  • searched open and closed issues for duplicates

Bug description

I was unable to compile libsignal-protocol-c using Visual Studio, either with the IDE or the default console compiler msvc.

Steps to reproduce

  • Open PowerShell or Developer Command Prompt for VS 2019
  • Go to the repo's folder, create a folder for the build and open it
  • run cmake ..
  • run cmake --build .

Actual result:
I get the following errors:

C:\Users\Unable to decrypt\Documents\Git\libsignal-protocol-c\src\curve25519\ed25519\tests\internal_fast_tests.c(300,28): erro
r C2057:  expected constant expression [C:\Users\Unable to decrypt\Documents\Git\libsignal-protocol-c\myOwnBuild\src\curve2551
9\curve25519.vcxproj]
C:\Users\Unable to decrypt\Documents\Git\libsignal-protocol-c\src\curve25519\ed25519\tests\internal_fast_tests.c(300,28): erro r C2466:  cannot allocate an array of constant size 0 [C:\Users\Unable to decrypt\Documents\Git\libsignal-protocol-c\myOwnBuil d\src\curve25519\curve25519.vcxproj]
C:\Users\Unable to decrypt\Documents\Git\libsignal-protocol-c\src\curve25519\ed25519\tests\internal_fast_tests.c(300,29): erro r C2133:  'msg': unknown size [C:\Users\Unable to decrypt\Documents\Git\libsignal-protocol-c\myOwnBuild\src\curve25519\curve25 519.vcxproj]
C:\Users\Unable to decrypt\Documents\Git\libsignal-protocol-c\src\curve25519\ed25519\tests\internal_fast_tests.c(340,28): erro r C2057:  expected constant expression [C:\Users\Unable to decrypt\Documents\Git\libsignal-protocol-c\myOwnBuild\src\curve2551 9\curve25519.vcxproj]
C:\Users\Unable to decrypt\Documents\Git\libsignal-protocol-c\src\curve25519\ed25519\tests\internal_fast_tests.c(340,28): erro r C2466:  cannot allocate an array of constant size 0 [C:\Users\Unable to decrypt\Documents\Git\libsignal-protocol-c\myOwnBuil d\src\curve25519\curve25519.vcxproj]
C:\Users\Unable to decrypt\Documents\Git\libsignal-protocol-c\src\curve25519\ed25519\tests\internal_fast_tests.c(340,29): erro
r C2133:  'msg': unknown size [C:\Users\Unable to decrypt\Documents\Git\libsignal-protocol-c\myOwnBuild\src\curve25519\curve25
519.vcxproj]

Expected result:
I expect to generate signal-protocol-c.lib

Device info

Device: Toshiba (DESKTOP-PKJM3FE) Windows 10 Home 64 bits
Signal version: 2.3.2

Link to logs

It seems like msvc doesn't fully support standard c99 which leads to errors in the following code:

const int MSG_LEN = 200;
unsigned char msg[MSG_LEN];

It also doesn't identify #ifndef _WINDOWS so it always ends up trying to include unistd.h.

I have a workaround, changes can be seen here Hirobreak@2721ea8.

Which works for me as of now. I did a little research to make my workaround a solution but I've found none yet

@agauvin-cipherloc
Copy link

Note MSVC appears to only support this syntax when compiling a C++ application. I have tried targeting C11 standard with compiler flags using CMake and it still fails. I have not determined the root cause of the parsing/compilation bug using VS2019 either but have a similar work around stashed for when I need to build on Windows.

@thradams
Copy link

The workaround is:

#define MSG_LEN 200
unsigned char msg[MSG_LEN];

and you can add the macro _WINDOWS in your settings.

Windows also gave an an error with unsigned and strdup.
I disabled then using the additional command line on VC++: /wd4996 /wd4146

(
I managed to compile but I didn't find any complete client sample.
I want to send a message this should be very simple.
)

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

No branches or pull requests

3 participants