skeeto / w64devkit

Portable C and C++ Development Kit for x64 (and x86) Windows
The Unlicense
2.68k stars 185 forks source link

possible gcc problem with w64devkit-1.19.0 and win_flex #65

Open jpetrescu opened 1 year ago

jpetrescu commented 1 year ago

Most likely a user error, but I've spent a couple of hours trying to find a solution. I am on Windows 11 in a command window. I have run win_flex on a simple flex input file: %{

include "token.h"

%} DIGIT [0-9] LETTER [a-zA-Z] %% (" "|\t|\n) / skip whitespace / + { return TOKEN_ADD; } while { return TOKEN_WHILE; } {LETTER}+ { return TOKEN_IDENT; } {DIGIT}+ { return TOKEN_NUMBER; } . { return TOKEN_ERROR; } %% int yywrap() { return 1; }

Using w64devkit-1.19.0 I run: gcc lex.yy.c I get the following error: D:\JonProjects\w64devkit-1.19.0\w64devkit\bin/ld.exe: D:/JonProjects/w64devkit-1.19.0/w64devkit/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crtexewin.o):crtexewin.c:(.text.startup+0xb1): undefined reference to `WinMain' collect2.exe: error: ld returned 1 exit status

I suspect an option must be turned off or on or need to add a library, but am unable to determine the solution.

skeeto commented 1 year ago

That message about WinMain is just Mingw-w64's way of saying the linker cannot find an entry point. That is, you don't have a "main" function in your source file. Perhaps you mean to compile with "gcc -c" to create an object file and not run the linker?

jpetrescu commented 1 year ago

Thank you. That's the clue I needed.

On Sat, May 13, 2023 at 2:47 PM Christopher Wellons < @.***> wrote:

That message about WinMain is just Mingw-w64's way of saying the linker cannot find an entry point. That is, you don't have a "main" function in your source file. Perhaps you mean to compile with "gcc -c" to create an object file and not run the linker?

— Reply to this email directly, view it on GitHub https://github.com/skeeto/w64devkit/issues/65#issuecomment-1546756170, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABX6AGFDKUIGVUWISHADKWLXF76ONANCNFSM6AAAAAAYAVL6CE . You are receiving this because you authored the thread.Message ID: @.***>