如何更改为使用cygwin下的g ++ mingw工具链

时间:2022-06-10 01:51:40

It looks like g++/gcc-mingw is installed but I can't tell how to use it.

它看起来像是安装了g ++ / gcc-mingw,但我不知道如何使用它。

I am building a C source file with a windows main proc and I get this error:

我正在使用windows main proc构建一个C源文件,我收到此错误:

g++-3 -mwindows -L/usr/lib/gcc/i686-pc-mingw32 -lmingw32 winmain.c

g ++ - 3 -mwindows -L / usr / lib / gcc / i686-pc-mingw32 -lmingw32 winmain.c

/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lmingw32 collect2: ld returned 1 exit status

/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld:找不到-lmingw32 collect2:ld返回1退出状态

Or

$ g++-3 -mwindows -L/usr/lib/gcc/i686-pc-mingw32 winmain.c /tmp/ccyLGxkn.o:winmain.c:(.text+0x21): undefined reference to `MainWndProc(HWND__*, unsigned int, unsigned int, long)@16' collect2: ld returned 1 exit status

$ g ++ - 3 -mwindows -L / usr / lib / gcc / i686-pc-mingw32 winmain.c /tmp/ccyLGxkn.o:winmain.c:(.text+0x21):未定义引用`MainWndProc(HWND __ *, unsigned int,unsigned int,long)@ 16'colle2:ld返回1退出状态

If I do a list directory on the installed libraries I see this:

如果我在已安装的库上执行列表目录,我会看到:

$ ls /usr/lib/gcc/ i686-pc-cygwin/ i686-pc-mingw32/

$ ls / usr / lib / gcc / i686-pc-cygwin / i686-pc-mingw32 /

Note: 'i686-pc-mingw32' How do I compile using the mingw32 libraries?

注意:'i686-pc-mingw32'如何使用mingw32库进行编译?

Also, I installed the package: 'gcc-mingw-g++' through the cygwin setup.exe utility, I just don't know how to use it?

另外,我通过cygwin setup.exe实用程序安装了软件包:'gcc-mingw-g ++',我只是不知道如何使用它?

Note: I am mostly working with 'cygwin', I would prefer NOT to install the full ming install?

注意:我主要使用'cygwin',我宁愿不安装完整的ming安装?

1 个解决方案

#1


0  

There are actually two sets of projects, the libraries and the actually toolchain. I installed the libraries and not the toolchain.

实际上有两组项目,即库和实际的工具链。我安装了库而不是工具链。

The libraries are: gcc-mingw-g++

这些库是:gcc-mingw-g ++

mingw64-i686-gcc is the toolchain

mingw64-i686-gcc是工具链

I ran with this command and it worked correctly:

我运行这个命令,它运行正常:

i686-pc-mingw32-g++

i686-w64-mingw32-g++

Or:

i686-w64-mingw32-g++ -mwindows -static -I/opt/jdk/include -I/opt/jdk/include/win32 -Wl,--add-stdcall-alias -shared -o Hello.dll Hello.cpp

i686-w64-mingw32-g ++ -mwindows -static -I / opt / jdk / include -I / opt / jdk / include / win32 -Wl, - add-stdcall-alias -shared -o Hello.dll Hello.cpp

#1


0  

There are actually two sets of projects, the libraries and the actually toolchain. I installed the libraries and not the toolchain.

实际上有两组项目,即库和实际的工具链。我安装了库而不是工具链。

The libraries are: gcc-mingw-g++

这些库是:gcc-mingw-g ++

mingw64-i686-gcc is the toolchain

mingw64-i686-gcc是工具链

I ran with this command and it worked correctly:

我运行这个命令,它运行正常:

i686-pc-mingw32-g++

i686-w64-mingw32-g++

Or:

i686-w64-mingw32-g++ -mwindows -static -I/opt/jdk/include -I/opt/jdk/include/win32 -Wl,--add-stdcall-alias -shared -o Hello.dll Hello.cpp

i686-w64-mingw32-g ++ -mwindows -static -I / opt / jdk / include -I / opt / jdk / include / win32 -Wl, - add-stdcall-alias -shared -o Hello.dll Hello.cpp