无Ubuntu环境,如何在Visual Studio 2015中执行MakeFiles?
Running NIST Post-Quantum Cryptography Round 1 Code in Visual Studio 2015 (No Ubuntu Environment)
Hey there! Let's break down how you can run those NIST post-quantum cryptography Round 1 submission codes in Visual Studio 2015 without an Ubuntu environment. Here are practical approaches to handle the Makefiles:
1. Use VS2015's Makefile Project Template
VS2015 has built-in support for Makefile projects—here's how to set it up:
- Open Visual Studio 2015, go to File > New > Project, then navigate to Visual C++ > General and select Makefile Project.
- Name your project and point it to the directory containing the submission's Makefile.
- Configure build commands: In the project properties (right-click project > Properties), under Configuration Properties > NMake:
- Set Build Command Line to something like
make -f "$(ProjectDir)Makefile"(you'll need a Windows-compatiblemaketool—install MinGW or Cygwin, then add itsbindirectory to your system PATH so VS can find it). - Adjust Clean Command Line to
make clean -f "$(ProjectDir)Makefile"if the Makefile supports it.
- Set Build Command Line to something like
- Important: Many Linux-targeted Makefiles use GCC-specific flags or Linux path conventions. You may need to tweak the Makefile: replace
gccwithcl.exe(VS's compiler), swap forward slashes (/) with backslashes (\) for paths, or adjust linker flags to match VS's syntax.
2. Leverage Windows Subsystem for Linux (WSL)
Even without a full Ubuntu install, WSL lets you run a Linux environment directly on Windows:
- Enable WSL in Windows Settings (search for "Turn Windows features on or off" and check "Windows Subsystem for Linux"), then install an Ubuntu distro from the Microsoft Store.
- Copy your NIST submission code into the WSL file system (you can access Windows files via
/mnt/c/in WSL). - Compile the code using
makeinside the Ubuntu WSL terminal. - If you want to debug from VS2015, set up remote debugging to connect to your WSL instance (note: VS2015's WSL support is limited compared to newer versions, but basic debugging should work with the right configuration).
3. Manually Convert the Makefile to a VS C++ Project
If the Makefile isn't overly complex, you can recreate the project structure in VS:
- Create a new Empty Project under Visual C++.
- Add all source files (
.c,.cpp) and header files (.h) from the submission to the project. - Replicate the Makefile's build settings in VS project properties:
- C/C++ > General: Add any include directories from the Makefile's
-Iflags to Additional Include Directories. - C/C++ > Preprocessor: Add macro definitions from
-Dflags to Preprocessor Definitions. - Linker > General: Add library directories from
-Lflags to Additional Library Directories. - Linker > Input: Add library dependencies from
-lflags to Additional Dependencies.
- C/C++ > General: Add any include directories from the Makefile's
- Watch out for Linux-specific code: Some submissions may use system calls or headers unique to Linux (like
unistd.h). You may need to modify these parts to work on Windows, or use compatibility libraries from MinGW.
Quick Tips
- If you hit compilation errors, first double-check that all paths are correctly set and that compiler flags are compatible with VS's
cl.exe. - Look for platform-specific conditionals in the code (e.g.,
#ifdef __linux__) and add#ifdef _WIN32blocks to handle Windows-specific logic where needed.
内容的提问来源于stack exchange,提问作者ChanBan
相关产品推荐
相关产品推荐

