Skip to content

Commit a73e1fa

Browse files
committed
add back the windows installation guide
Signed-off-by: Adije Shen <[email protected]>
1 parent f24f634 commit a73e1fa

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
@@ -125,6 +125,64 @@ To build `liboqs-java` first download or clone this java wrapper into a `liboqs-
125125
git clone -b master https://github.com/open-quantum-safe/liboqs-java.git
126126
```
127127

128+
### Windows Build
129+
130+
#### Prerequisites
131+
132+
- MinGW-w64 GCC (version 11.5.0 or later)
133+
- CMake
134+
- JDK 1.8
135+
- Maven 3.8.8
136+
- Git
137+
138+
#### Installation Steps
139+
140+
1. Install MinGW-w64 GCC:
141+
- Download from [WinLibs](https://winlibs.com/#download-release)
142+
- Extract the ZIP file to a directory without spaces
143+
- Add the bin directory to PATH environment variable (e.g., `E:\develop\mingw64\bin`)
144+
- Via Control Panel → System → System Info → Advanced System Settings → Advanced → Environment Variables → PATH
145+
- Or via command line: `setx PATH "E:\develop\mingw64\bin;%PATH%"` (not recommended)
146+
147+
2. Install CMake:
148+
- Either via winget: `winget install cmake`
149+
- Or download from [cmake.org](https://cmake.org/download/)
150+
- Ensure CMake is added to PATH
151+
152+
3. Verify installations (by open cmd and type):
153+
```bash
154+
gcc --version
155+
cmake --version
156+
```
157+
158+
4. Build liboqs:
159+
```bash
160+
git clone https://github.com/open-quantum-safe/liboqs/
161+
cmake -G "MinGW Makefiles" -DCMAKE_C_COMPILER=gcc -DBUILD_SHARED_LIBS=OFF -S . -B build
162+
cmake --build build -j4
163+
cd ..
164+
```
165+
166+
5. Install Java dependencies:
167+
- Install JDK 1.8 from [OpenLogic](https://www.openlogic.com/openjdk-downloads)
168+
- Install Maven 3.8.8 from [Maven](https://maven.apache.org/)
169+
- Add both to PATH environment variables
170+
- Verify Java installations:
171+
```bash
172+
java -version
173+
mvn -version
174+
```
175+
176+
If you clone the liboqs under `liboqs-java` directory, then you can run the following command to build the package:
177+
```bash
178+
mvn package -P windows
179+
```
180+
181+
Or else, you should run
182+
```bash
183+
mvn package -P windows -Dliboqs.include.dir="<path-to-save-liboqs>\liboqs\build\include" -Dliboqs.lib.dir="<path-to-save-liboqs>\liboqs\build\lib"
184+
```
185+
128186
### Linux/MacOS
129187

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

138196
#### Build Instructions
139197

140-
1. Clone the repository with submodules
141-
```bash
142-
git clone --recursive https://github.com/open-quantum-safe/liboqs-java
143-
```
198+
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).
144199

145-
2. Build the liboqs C library to generate liboqs.a
200+
1. Build the liboqs C library to generate liboqs.a
146201
```bash
147-
cd liboqs
202+
cd <path-to-save-liboqs>
203+
git clone https://github.com/open-quantum-safe/liboqs/
148204
cmake -S . -B build
149205
cmake --build build -j4
206+
#optional
207+
sudo cmake --install build
150208
cd ..
151209
```
152-
This step will generate the `liboqs/build/liboqs.a` file.
153-
154-
3. Build liboqs-java
155-
```bash
156-
mvn package -P <OS>
157-
```
158-
This step will generate `target/liboqs-java.jar` and `target/classes/liboqs-jni.so`.
159210

211+
This step will generate the `liboqs/build/liboqs.a` file.
160212

161213
### Building the Java OQS wrapper
162214

@@ -168,18 +220,22 @@ mvn package -P macosx -Dliboqs.include.dir="/usr/local/include" -Dliboqs.lib.dir
168220
```
169221
The above command will compile the C and Java files and also run the unit tests.
170222

223+
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`
224+
```
225+
mvn package -P macosx -Dliboqs.include.dir="<path-to-save-liboqs>/liboqs/build/include" -Dliboqs.lib.dir="<path-to-save-liboqs>/liboqs/build/lib"
226+
```
227+
171228
To build without running the default unit tests you can use the `-Dmaven.test.skip=true` command line option as follows:
172229
```
173230
mvn package -P macosx -Dliboqs.include.dir="/usr/local/include" -Dliboqs.lib.dir="/usr/local/lib" -Dmaven.test.skip=true
174231
```
175232

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

178-
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).
235+
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).
179236

180237
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.
181238

182-
183239
### Building and running the examples
184240

185241
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)