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

error when compiling oqs-provider in windows Using msys2 and mingw32 #105

Closed
k-Artin opened this issue Jan 28, 2023 · 12 comments
Closed

error when compiling oqs-provider in windows Using msys2 and mingw32 #105

k-Artin opened this issue Jan 28, 2023 · 12 comments

Comments

@k-Artin
Copy link

k-Artin commented Jan 28, 2023

hello
I am getting the following errors when I install oqs-provider on windows with mingw32.

$ ninja -j 4
[11/28] Building C object test/CMakeFiles/oqs_test_signatures.dir/test_common.c.obj
C:/msys64/home/oqs-provider/oqs-provider-main/test/test_common.c: In function 'alg_is_enabled':
C:/msys64/home/oqs-provider/oqs-provider-main/test/test_common.c:27:20: warning: implicit declaration of function 'index' [-Wimplicit-function-declarat
ion]
27 | while((comma = index(alglist, ','))) {
| ^~~~~
C:/msys64/home/oqs-provider/oqs-provider-main/test/test_common.c:27:20: warning: incompatible implicit declaration of built-in function 'index' [-Wbuil
tin-declaration-mismatch]
[13/28] Building C object test/CMakeFiles/oqs_test_kems.dir/test_common.c.obj
C:/msys64/home/oqs-provider/oqs-provider-main/test/test_common.c: In function 'alg_is_enabled':
C:/msys64/home/oqs-provider/oqs-provider-main/test/test_common.c:27:20: warning: implicit declaration of function 'index' [-Wimplicit-function-declarat
ion]
27 | while((comma = index(alglist, ','))) {
| ^~~~~
C:/msys64/home/oqs-provider/oqs-provider-main/test/test_common.c:27:20: warning: incompatible implicit declaration of built-in function 'index' [-Wbuil
tin-declaration-mismatch]
[14/28] Linking C executable test\oqs_test_signatures.exe
FAILED: test/oqs_test_signatures.exe
cmd.exe /C "cd . && C:\msys64\mingw32\bin\gcc.exe test/CMakeFiles/oqs_test_signatures.dir/oqs_test_signatures.c.obj test/CMakeFiles/oqs_test_sig
natures.dir/test_common.c.obj -o test\oqs_test_signatures.exe -Wl,--out-implib,test\liboqs_test_signatures.dll.a -Wl,--major-image-version,0,--min
or-image-version,0 C:/openvpn3/lib/libcrypto.dll.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvap
i32 && cd ."
C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/12.2.0/../../../../i686-w64-mingw32/bin/ld.exe: test/CMakeFiles/oqs_test_signatures.dir/test_com
mon.c.obj:test_common.c:(.text+0x165): undefined reference to **index'** collect2.exe: error: ld returned 1 exit status [15/28] Linking C executable test\oqs_test_kems.exe FAILED: test/oqs_test_kems.exe cmd.exe /C "cd . && C:\msys64\mingw32\bin\gcc.exe test/CMakeFiles/oqs_test_kems.dir/oqs_test_kems.c.obj test/CMakeFiles/oqs_test_kems.dir/test_c ommon.c.obj -o test\oqs_test_kems.exe -Wl,--out-implib,test\liboqs_test_kems.dll.a -Wl,--major-image-version,0,--minor-image-version,0 C:/openvpn 3/lib/libcrypto.dll.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ." C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/12.2.0/../../../../i686-w64-mingw32/bin/ld.exe: test/CMakeFiles/oqs_test_kems.dir/test_common.c. obj:test_common.c:(.text+0x165): undefined reference to index'
collect2.exe: error: ld returned 1 exit status
[17/28] Building C object oqsprov/CMakeFiles/oqsprovider.dir/oqs_encode_key2any.c.obj
ninja: build stopped: subcommand failed.

this error is in the mingw32.
This error is due to the index() function. Is it possible to use strchr instead of this function?

when using visual studio this error does not exist and the following error occurs:
fatal error: 'stdatomic.h' file not found.

i think something wrong.
Thank you in advance!

@baentsch
Copy link
Member

That is not entirely unexpected as Windows is not yet supported (see #47). If you see a need for support of that platform, please let us know. Any contribution by you will be welcome.

@baentsch
Copy link
Member

See open-quantum-safe/liboqs#1371 (comment). Same here. #47 will first be resolved with cygwin support.

@k-Artin
Copy link
Author

k-Artin commented Jan 29, 2023

my gcc version is :
gcc.exe (Rev6, Built by MSYS2 project) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

@k-Artin k-Artin changed the title error when compiling oqs-provider in windows with mingw32 error when compiling oqs-provider in windows Using msys2 and mingw32 Jan 29, 2023
@k-Artin
Copy link
Author

k-Artin commented Jan 29, 2023

when using visual studio this error does not exist and the following error occurs:

my apology about that. There is an error about the index() function in visual studio too.

the index function is in the strings.h in GNU c library in ubuntu but in the mingw32 strings.h does not have this function.

@mingw-io
Copy link

Last year I was under the impression that this project had/has never been tested (properly or at all) on Mac & Windows.
The more platforms we support, the better for this project.
We should never release something with compilation errors!

On another note, we should not confuse environments (e.g. cygwin, MSYS, etc).

Based on the issue reported here, I suspect a broken environment and/or lack of experience (e.g. fresher?).

We built this project last year from source. We could try again now.

@baentsch
Copy link
Member

Fully agreed with all your statements, @mingw-io , Thanks -- also for detailing Windows-specific build issues. When looking into #47 again I again already stumbled building "plain" openssl in a cygwin environment (compile errors of an apparent Microsoft crypto include file), so hints very welcome how to correctly build. My ultimate goal would be an AppVeyor script to test all components using MSVC, cygwin, msys2/mingw.

@VeronikaNguyen
Copy link
Contributor

VeronikaNguyen commented Feb 2, 2023

I could build this project on windows with mingw64. However, the tests were skipped in the building process but creating PQC certificates and running a test client and server still works for me.

For the step "Building the provider", likewise as @k-Artin mentioned, I used while((comma = strchr(alglist, ','))) instead of while((comma = index(alglist, ','))) in test_common.c. Moreover, I created a oqsprov.def file in the oqsprov folder with the following contents:

EXPORTS
  OSSL_provider_init

Lastly, I added the file oqsprov.def to the following section in CMakeLists.txt of the oqsprov folder.

set(PROVIDER_SOURCE_FILES
  oqsprov.c oqsprov_capabilities.c oqsprov_keys.c
  oqs_kmgmt.c oqs_sig.c oqs_kem.c
  oqs_encode_key2any.c oqs_endecoder_common.c oqs_decode_der2key.c oqsprov_bio.c
  oqsprov.def
)

Hopefully, cmake will build after the adjustments. It took me a long time to figure out how to build this and I received help from others. Hope this works for @k-Artin as well.

@baentsch
Copy link
Member

baentsch commented Feb 2, 2023

@VeronikaNguyen Thanks very much for sharing all this! Would you consider contributing this to the project via PR (such as to ease the life of others)? Otherwise, I guess it'd be OK for you if I'd add things as per the above?
Finally, did you also build openssl3 or did you already have a built binary of that? Sorry for the possibly silly question if mingw64 already comes with openssl3 (?).

@VeronikaNguyen
Copy link
Contributor

@baentsch No problem, I am glad this project exists. Sure, I will create a PR for this.

This is not a silly question. I am not sure if mingw64 comes with openssl but since I wanted to use TLS with PQC signatures, I build openssl3 from https://github.com/baentsch/openssl/tree/sigload in mingw64 as well.

@mingw-io mingw-io mentioned this issue Feb 8, 2023
@baentsch
Copy link
Member

FWIW, I now checked that building & testing oqsprovider on current main branch on cygwin works fine (and I'll add CI as part of #47). Could someone more versed in these "windows shims" tell me whether this alleviates/resolves this issue, too? No disregard to mingw, msys2 or cygwin, I just don't know how they relate (and what a successful build on cygwin means).

@baentsch
Copy link
Member

As #192 landed, we now have CI building and testing oqsprovider on Windows (cygwin and MSVC). If there are (still) specific problems with msys2, please provide problems/information referring to the current code base below (at least a reproducible error report or even better, a PR adding msys2 to CI). We'll close this issue without further input in a week's time.

@baentsch
Copy link
Member

Closing due to inactivityt. Build on cygwin and msvc works without problems. Please feel free to re-open with reproducer script if still an issue.

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

4 participants