Albert Albani wrote:
> I compile and link it like this:
> gcc -mwindows -lole32 main.c
> and get the following linker error:
> main.c: undefined reference to `CoInitialize@...'
The linker makes one pass through objects and libraries in
the order given. In each library it looks only for symbols
it hasn't yet resolved. Here
gcc -mwindows -lole32 ...
it looks in libole32.a for...nothing, because it hasn't yet
read main.o and doesn't know it'll need 'CoInitialize@...'.
By the time it reads main.o, it's too late--libole32.a was
Put the library after the module that requires it:
gcc -mwindows main.c -lole32
Now, when the linker gets to libole32.a, it knows to look