c-是否有一种编译windows GUI的方法,即在tcc中没有控制台exe



我知道gcc中的开关,但TTC中没有这样的选项。我读到了一些关于_wagent或什么swich的东西,但我不知道该把它放在哪里。

好吧,似乎可以在tcc中制作非控制台应用程序。我还没有弄清楚这里需要哪些关键元素。但是在tcc包中有一个hello_win.c的例子。

tcc-Wall-Wl,-subsystem=windows example.c-luser32

不会弹出控制台窗口。参见tcc-hh

示例.c:

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
// need -luser32 at end of tcc cmd line. user presses OK returns 1.
int main(int argc, char *argv[]) {
    char *banner = malloc(100);
    sprintf(banner, "tcc is great, %d cmd line or DRAGGED args", argc - 1);
    while (argc-- > 0) MessageBox(NULL, argv[argc], banner, 1 + 256);
    return(0);
}

要将example.ico文件中的图标(例如由irfanview生成)添加到可执行文件中,请使用cygwin-util-windres,创建一个example.rc:文件

this ICON example.ico

然后

windres example.rc -O coff -o example.res

并使用

tcc -Wall -Wl,-subsystem=windows example.c -luser32 example.res

顺便说一下,我正在使用来自http://repo.or.cz/tinycc.git,并在cygwin:下编译此版本的tcc

./configure --tccdir=/usr/tcc --bindir=/usr/bin
make
make install

BTW2:有人知道如何在windows下向这些c程序传递更多的args吗?有一些窗口限制。拖动1000个参数后,得到"文件名或扩展名太长"。限制在窗户一侧。Windows和商业程序没有此限制。

John Refling

相关内容

最新更新