Skip to content

Commit 430ae87

Browse files
committed
add back the windows installation guide
1 parent 4525c7e commit 430ae87

File tree

2 files changed

+76
-20
lines changed

2 files changed

+76
-20
lines changed

README.md

Lines changed: 71 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,64 @@ To build `liboqs-java` first download or clone this java wrapper into a `liboqs-
6767
git clone -b master https://github.com/open-quantum-safe/liboqs-java.git
6868
```
6969

70+
### Windows Build
71+
72+
#### Prerequisites
73+
74+
- MinGW-w64 GCC (version 11.5.0 or later)
75+
- CMake
76+
- JDK 1.8
77+
- Maven 3.8.8
78+
- Git
79+
80+
#### Installation Steps
81+
82+
1. Install MinGW-w64 GCC:
83+
- Download from [WinLibs](https://winlibs.com/#download-release)
84+
- Extract the ZIP file to a directory without spaces
85+
- Add the bin directory to PATH environment variable (e.g., `E:\develop\mingw64\bin`)
86+
- Via Control Panel → System → System Info → Advanced System Settings → Advanced → Environment Variables → PATH
87+
- Or via command line: `setx PATH "E:\develop\mingw64\bin;%PATH%"` (not recommended)
88+
89+
2. Install CMake:
90+
- Either via winget: `winget install cmake`
91+
- Or download from [cmake.org](https://cmake.org/download/)
92+
- Ensure CMake is added to PATH
93+
94+
3. Verify installations (by open cmd and type):
95+
```bash
96+
gcc --version
97+
cmake --version
98+
```
99+
100+
4. Build liboqs:
101+
```bash
102+
git clone https://github.com/open-quantum-safe/liboqs/
103+
cmake -G "MinGW Makefiles" -DCMAKE_C_COMPILER=gcc -DBUILD_SHARED_LIBS=OFF -S . -B build
104+
cmake --build build -j4
105+
cd ..
106+
```
107+
108+
5. Install Java dependencies:
109+
- Install JDK 1.8 from [OpenLogic](https://www.openlogic.com/openjdk-downloads)
110+
- Install Maven 3.8.8 from [Maven](https://maven.apache.org/)
111+
- Add both to PATH environment variables
112+
- Verify Java installations:
113+
```bash
114+
java -version
115+
mvn -version
116+
```
117+
118+
If you clone the liboqs under `liboqs-java` directory, then you can run the following command to build the package:
119+
```bash
120+
mvn package -P windows
121+
```
122+
123+
Or else, you should run
124+
```bash
125+
mvn package -P windows -Dliboqs.include.dir="<path-to-save-liboqs>\liboqs\build\include" -Dliboqs.lib.dir="<path-to-save-liboqs>\liboqs\build\lib"
126+
```
127+
70128
### Linux/MacOS
71129

72130
#### Prerequisites
@@ -79,26 +137,20 @@ git clone -b master https://github.com/open-quantum-safe/liboqs-java.git
79137

80138
#### Build Instructions
81139

82-
1. Clone the repository with submodules
83-
```bash
84-
git clone --recursive https://github.com/open-quantum-safe/liboqs-java
85-
```
140+
First, you must build the `main` branch of [liboqs](https://github.com/open-quantum-safe/liboqs/) according to the liboqs building instructions with static library, followed (optionally) by a `sudo cmake --install build` to ensure that the compiled library is visible system-wide (by default it installs under `/usr/local/include` and `/usr/local/lib` on Linux/macOS).
86141

87-
2. Build the liboqs C library to generate liboqs.a
142+
1. Build the liboqs C library to generate liboqs.a
88143
```bash
89-
cd liboqs
144+
cd <path-to-save-liboqs>
145+
git clone https://github.com/open-quantum-safe/liboqs/
90146
cmake -S . -B build
91147
cmake --build build -j4
148+
#optional
149+
sudo cmake --install build
92150
cd ..
93151
```
94-
This step will generate the `liboqs/build/liboqs.a` file.
95-
96-
3. Build liboqs-java
97-
```bash
98-
mvn package -P <OS>
99-
```
100-
This step will generate `target/liboqs-java.jar` and `target/classes/liboqs-jni.so`.
101152

153+
This step will generate the `liboqs/build/liboqs.a` file.
102154

103155
### Building the Java OQS wrapper
104156

@@ -110,18 +162,22 @@ mvn package -P macosx -Dliboqs.include.dir="/usr/local/include" -Dliboqs.lib.dir
110162
```
111163
The above command will compile the C and Java files and also run the unit tests.
112164

165+
For those who doen't want the `liboqs` library to install system wide. You **have to** change `<liboqs.include.dir>` to `<path-to-save-liboqs>/liboqs/build/include` to and `<liboqs.lib.dir>` to `<path-to-save-liboqs>/liboqs/build/lib`
166+
```
167+
mvn package -P macosx -Dliboqs.include.dir="<path-to-save-liboqs>/liboqs/build/include" -Dliboqs.lib.dir="<path-to-save-liboqs>/liboqs/build/lib"
168+
```
169+
113170
To build without running the default unit tests you can use the `-Dmaven.test.skip=true` command line option as follows:
114171
```
115172
mvn package -P macosx -Dliboqs.include.dir="/usr/local/include" -Dliboqs.lib.dir="/usr/local/lib" -Dmaven.test.skip=true
116173
```
117174

118175
The default profile for building is `linux`, so when building on Linux the `-P <OS>` command line option may be omitted.
119176

120-
You may also omit the `-Dliboqs.include.dir` and `-Dliboqs.lib.dir` options in case you installed liboqs in `/usr/local` (true if you ran `sudo --install build` after building liboqs).
177+
You may also omit the `-Dliboqs.include.dir` and `-Dliboqs.lib.dir` options in case you installed liboqs in `/usr/local` (true if you ran `sudo cmake --install build` after building liboqs).
121178

122179
Both the above commands will create a `target` directory with the build files, as well as a `src/main/resources` directory that will contain the `liboqs-jni.so` native library. Finally, a `liboqs-java.jar` will be created inside the `target` directory that will contain all the class files as well as the `liboqs-jni.so` native library.
123180

124-
125181
### Building and running the examples
126182

127183
The examples include:

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<java.os.include>-I${JAVA_HOME}/include -I${JAVA_HOME}/include/darwin</java.os.include>
6262
<compiler.provider>generic-classic</compiler.provider>
6363
<linker.executable>gcc</linker.executable>
64-
<!-- 修改为使用静态库 liboqs.a -->
64+
<!-- use the static lib liboqs.a -->
6565
<linker.start.option>-shared -L${liboqs.lib.dir}</linker.start.option>
6666
<linker.end.option>${liboqs.lib.dir}/liboqs.a -lcrypto</linker.end.option>
6767
</properties>
@@ -78,12 +78,12 @@
7878
<properties>
7979
<lib_name>liboqs-jni</lib_name>
8080
<lib_name_ext>so</lib_name_ext>
81-
<liboqs.include.dir>${project.basedir}/liboqs/build/include</liboqs.include.dir>
82-
<liboqs.lib.dir>${project.basedir}/liboqs/build/lib</liboqs.lib.dir>
81+
<liboqs.include.dir>/usr/local/include</liboqs.include.dir>
82+
<liboqs.lib.dir>/usr/local/lib</liboqs.lib.dir>
8383
<java.os.include>-I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux</java.os.include>
8484
<compiler.provider>generic-classic</compiler.provider>
8585
<linker.executable>gcc</linker.executable>
86-
<!-- 修改为使用静态库 liboqs.a -->
86+
<!-- use the static lib liboqs.a -->
8787
<linker.start.option>-shared -L${liboqs.lib.dir}</linker.start.option>
8888
<linker.end.option>${liboqs.lib.dir}/liboqs.a -lcrypto</linker.end.option>
8989
</properties>
@@ -106,7 +106,7 @@
106106
<java.os.include>-I"${JAVA_HOME}\include" -I"${JAVA_HOME}\include\win32" </java.os.include>
107107
<compiler.provider>mingw</compiler.provider>
108108
<linker.executable>g++</linker.executable>
109-
<!-- 修改为使用静态库 liboqs.a -->
109+
<!-- use the statia lib liboqs.a -->
110110
<linker.start.option>-shared -L${liboqs.lib.dir} -ladvapi32</linker.start.option>
111111
<linker.end.option>${liboqs.lib.dir}\liboqs.a</linker.end.option>
112112
</properties>

0 commit comments

Comments
 (0)