BugHunterUK
BugHunterUK

Reputation: 8968

How to compile C without a main function using CL?

I'm trying to create a PE binary (or lib) using CL so I can explore the produced assembly language? The code I have is simple:

test.c

void f() { return; };

And that's it. I compile like so:

cl /Od test.c

And I get the error LINK : fatal error LNK1561: entry point must be defined. I kinda knew this would happen because I know the compiler expects an entry point.

But how can I compile the code without any entry points to inspect the assembly?

Upvotes: 0

Views: 142

Answers (1)

BugHunterUK
BugHunterUK

Reputation: 8968

The solution is to assemble the code only and to not invoke the linker as per the MS Docs:

cl /Od /c test.c

Upvotes: 2

Related Questions