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

windows gcc 编译,MsvcLibX库无法编译 #71

Open
dianjixz opened this issue May 28, 2022 · 6 comments
Open

windows gcc 编译,MsvcLibX库无法编译 #71

dianjixz opened this issue May 28, 2022 · 6 comments

Comments

@dianjixz
Copy link
Contributor

我在 windows10 用 x86_64-w64-mingw32 编译这个库的时候,libposix 这个库一直没编译通过,主要是 libposix4win.h 这个头文件依赖 MsvcLibX 这个库的 msvclibx.h 这个头文件。但是这个库是是专为微软的 vc++ 使用的,这就造成了一个问题,我无法使用 windows下的x86_64-w64-mingw32-gcc 编译器编译通过。所以想求助一下,怎样让 x86_64-w64-mingw32-gcc 正常编译通过 libposix 库。

# gcc -v
Using built-in specs.
COLLECT_GCC=E:\aapstar\gcc\mingw32\bin\gcc.exe
COLLECT_LTO_WRAPPER=E:/aapstar/gcc/mingw32/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-8.1.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw810/x86_64-810-win32-sjlj-rt_v6-rev0/mingw64 --enable-shared --enable-static --enable-targets=all --enable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=win32 --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-sjlj-exceptions --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch-32=i686 --with-arch-64=nocona --with-tune-32=generic --with-tune-64=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-win32-sjlj-rev0, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-win32-sjlj-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-win32-sjlj-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw810/x86_64-810-win32-sjlj-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw810/x86_64-810-win32-sjlj-rt_v6-rev0/mingw64/opt/lib -L/c/mingw810/prerequisites/x86_64-zlib-static/lib -L/c/mingw810/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: win32
gcc version 8.1.0 (x86_64-win32-sjlj-rev0, Built by MinGW-W64 project) 
@gozfree
Copy link
Owner

gozfree commented May 31, 2022

很遗憾MsvcLibX 不支持mingw的gcc编译,只支持msvc的cl.exe。因此提供了两种方法:
一种是不包含MsvcLibX的编译,使用libposix4win里的大部分接口:
(只支持部分编译,patch https://gitee.com/gozfreee/gear-lib/commit/95fcd68d11092d02ff66b10dd76b6915c4afe724
···
$ mkdir build_msys2
$ cd build_msys2
$ cmake ../
···
另一种是需要安装MSVC+CMake,可以使用win32原生的api,按照如下命令编译:
···

mkdir build_msvc
cd build_msvc
'/c/Program Files/CMake/bin/cmake.exe' ../
'/c/Program Files/CMake/bin/cmake.exe' --build .
···

@dianjixz
Copy link
Contributor Author

dianjixz commented Jun 2, 2022

好的,谢谢了。我整理了一个 c/c++ 开发框架,希望作者看一下,给一点反馈。https://github.com/dianjixz/gear-lib/tree/my/build/c_cpp_project_framework 如果可以的话,希望能合到仓库里。

@gozfree
Copy link
Owner

gozfree commented Jun 4, 2022

非常感谢您的贡献,可以让gear-lib多了一种编译开发的选择,正在准备pull request 和review中

@gozfree
Copy link
Owner

gozfree commented Jun 4, 2022

已经将您的改动合入gear-lib了,由于pull request中的多次提交中有创建和删除的文件夹,为了避免中间无效的提交,我直接将最终的文件手动提交上去了,您可以再次同步下来使用
54b2729975686870d986e567e457612b1425bd72

@dianjixz
Copy link
Contributor Author

dianjixz commented Jun 6, 2022

我重新整理 c_cpp_project_framework 这个的提交,并删除了 libbase64,你用这个进行合并吧。之前那个合并看起来比较乱。

@dianjixz
Copy link
Contributor Author

dianjixz commented Jun 6, 2022

合并完后在 linux 环境下,进入 build/c_cpp_project_framework/examples/demo1/ 目录下,直接执行 make 命令就能进行编译。这个编译环境依赖 python3 和 kconfiglib ,执行 pip3 install kconfiglib 就能完成编译环境。windows 下也一样的操作,不过目前 windows 下 gcc 的 libposix 问题还没有很好的解决。

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

2 participants