S
S
SuperZombie2020-11-15 18:08:37
GCC
SuperZombie, 2020-11-15 18:08:37

How to compile .c to .exe using gcc?

The question is a continuation of this article , but is already addressed to those who sit on C. I have a .c file
I already converted it to a .o binary using gcc.
How can I further convert it to exe? It gives me an error:

undefined reference to `__imp_PyModuleDef_Init'
undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status

In the original code, I used tkinter and there the main function is called like this:
if __name__ == '__main__':
    # Мой код

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
NQUARE, 2020-11-15
@NQUARE

https://habr.com/en/post/478124/
If undefined reference to and collect2.exe: error: ld returned 1 exit status - then you need to link something:
-lsomething

T
Trimsky, 2020-11-16
@Trimsky

So wait, but .o is the binary...

C
CityCat4, 2020-11-16
@CityCat4

undefined reference means that the linker could not find a lib containing a call to this function. Look for libs that are missing and add them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question