Windows原生编译openssl 脚本
:: must be executed at the same directory as root of this project
:: need to install StrawBerry Perl and NASM, then fill in those two environment variables.
set StrawBerry=D:\Strawberry
set NASM_dir=D:\NASM
set JOM_dir=D:\Qt\jom
:: below no need to read
set StrawBerry_dir=%StrawBerry%\c\bin;%StrawBerry%\perl\bin;%StrawBerry%\perl\site\bin
set PATH=%NASM_dir%;%StrawBerry_dir%;%JOM_dir%;%PATH%
:: Refer to https://stackoverflow.com/questions/75869012/unable-to-build-my-c-project-with-jom-qmake-problem
:: Compiler said "If several cl.exe write in the same file .PDB, use /FS"
set CFLAGS=/FS
set CXXFLAGS=/FS
:: use call otherwise the below commands will not be executed
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 10.0.18362.0 -vcvars_ver=14.0
perl Configure --prefix=%cd%\openssl_build_output
jom -j32
jom test -j32
:: I don't know why but jom can't read the prefix
nmake install -j32
Reference
How to Build OpenSSL, zlib, and cURL libraries on Windows
Notes for Windows platforms - openssl
Windows下编译ffmpeg(Msvc+msys2)
时效性声明
本文使用的版本为ffmpeg n6.1.1, vcvarsall.bat 来源于Visual Studio2022,
编译器为msvc v140
具体步骤
先随便打开一个cmd
-vcvars_ver=14.0
是为了用msvc v140(VS2015)编译
-use-full-path
是为了继承cmd里的环境变量到msys2 console里
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=14.0
D:\msys64\msys2_shell.cmd -use-full-path
到了msys2后安装git
cmp
make
nasm
pacman -S git diffutils make nasm pkg-config
因为msys2自带的link
和msvc里的link
会冲突,所以修改原来的link名称
mv /usr/bin/link /usr/bin/lin
反正这个link基本用不到(msys2环境是隔离的,生成的库不能直接被msvc链接,还不如mingw64环境,那个至少还能生成可被msvc链接的东西)
然后克隆和配置,默认安装到/usr/local/ffmpeg-v6.1.1
git clone https://github.com/FFmpeg/FFmpeg.git --depth 1 -b n6.1.1 ffmpeg-v6.1.1
cd ffmpeg-v6.1.1
./configure --toolchain=msvc --prefix=/usr/local/ffmpeg-v6.1.1
warning C4828: 文件包含在偏移 0x1d9 处开始的字符,该字 符在当前源字符集中无效(代码页 65001)。make: *** Deleting file 'libavcodec/msvideo1enc.o'
可能会遇到编译器信息导致的编码错误(有些人cmd打开默认code page是936)
直接随便改一下或者根据cl.exe给出的,编辑config.h
#define CC_IDENT "用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.00.24247.2 版"
最后
make -j32
make install
Reference
Windows + MSVC环境编译ffmpeg - 罗均 - 知乎
FFmpeg wiki:CompilationGuide/MSVC
关于一直说的MSVC CRT是个什么东西
https://learn.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=msvc-170
Orcad Capture CIS
Mingw-w64下链接动态库的细节
比如我想链接一个库-lA,在windows下有import library和static libraray之分,其中import library在mingw下通常以dll.a结尾,而statlic library则直接以.a结尾
打个比方usb-1.0
,
libusb-1.0.a libusb-1.0.dll.a
那么如果-L库路径包含了两个相同的会如何呢
请阅读binutils关于Win32的官方文档
这里面说了
For instance, when ld is called with the argument ‘-lxxx’ it will attempt to find, in the first directory of its search path,
libxxx.dll.a
xxx.dll.a
libxxx.a
xxx.lib
libxxx.lib
cygxxx.dll (*)
libxxx.dll
xxx.dll
所以是默认先找动态库的导入库进行链接的
其中还有有趣的 direct linking to a dll, 这是说不需要导入库,ld直接连接到一个dll上
如何让CMake找到QT
source
For find_package to be successful, CMake must find the Qt installation in one of the following ways:
- Set your
CMAKE_PREFIX_PATH
environment variable to the Qt 5 installation prefix. This is the recommended way. - Set the
Qt5_DIR
in the CMake cache to the location of the Qt5Config.cmake file.
但是下面那种办法只能找到qt core
还需要设置一堆比如
所以说, recommended approach is to set the CMake cache variableCMAKE_PREFIX_PATH
to include the Qt 6 installation prefix
cmake -GNinja -B build -DCMAKE_PREFIX_PATH= /Users/tz61/Qt/6.5.3/macos
更快地编译QT6
QT在6以后可以用cmake编译源码了,source
Windows下CMake可以默认从C:/Qt下找到Qt各个版本
在linux交叉编译openocd参考
MSVC BuildTools 老版本下载
更新:MSVC老编译器可以从VS2022里面下载,没必要单独再搞个BuildTools
2017: https://aka.ms/vs/15/release/vs_buildtools.exe
2019: https://aka.ms/vs/16/release/vs_buildtools.exe
2022: https://aka.ms/vs/17/release/vs_buildtools.exe
source
MSVC 14.16 是runtime 版本,10.0.17763.0是Windows SDK版本,19.16.27051是Compiler版本