views:

24

answers:

2

I'm attempting to compile a simple hello world program in c with lcc-win32/wedit, and i'm a little unfamiliar with windows c programming.

#include <stdio.h>

int main(void){
 printf("hellow\n");
 return 0;
}

When I compile the program the console output is:

Wedit output window build: Tue Jun 15 09:13:17 2010

c:\lcc\lib\lcccrt0.obj .text: undefined reference to '_RtlUnwind@16'
c:\lcc\lib\lcccrt0.obj .text: undefined reference to '_signal'
c:\lcc\lib\lcccrt0.obj .text: undefined reference to '_raise'
c:\lcc\lib\lcccrt0.obj .text: undefined reference to '_exit'
asctoq.obj .text: undefined reference to '_strnicmp'
defaulttrap.obj .text: undefined reference to '__imp___iob'
defaulttrap.obj .text: undefined reference to '_fwrite'
defaulttrap.obj .text: undefined reference to '_itoa'
defaulttrap.obj .text: undefined reference to '_strcat'
defaulttrap.obj .text: undefined reference to '_MessageBoxA@16'
defaulttrap.obj .text: undefined reference to '_abort'
powlasm.obj .text: undefined reference to '_pow'
qfloat.obj .text: undefined reference to '_memset'
qfloat.obj .text: undefined reference to '_strchr'
qfloat.obj .text: undefined reference to '_memmove'
strlcpy.obj .text: undefined reference to '_memcpy'
xprintf.obj .text: undefined reference to '_localeconv'
xprintf.obj .text: undefined reference to '_strtol'
xprintf.obj .text: undefined reference to '_wcslen'
xprintf.obj .text: undefined reference to '_wctomb'
xprintf.obj .text: undefined reference to '_fputc'
search
Compilation + link time:0.1 sec, Return code: 60

when I attempt to execute the program within wedit i get a dialog box that says "hello.exe is not up-to-date. Rebuild?"

If I click yes, nothing happens. If I click no, a dos window pops up saying
"C:\lcc\projects\lcc2\hello.exe"
Return code -1
Execution time 0.001 seconds
Press any key to continue...

This continues to happen no matter how many times i compile/rebuild.

Any ideas?

A: 

Add the following to the top of the page:

#include <stdio.h>
Geoffrey Van Wyk
No, these a linker errors, not compile errors.
Hans Passant
stdio.h is already included though?
Rowhawn
+1  A: 

You need to tell the linker to link the C runtime library as well as the Windows kernel32.lib and user32.lib import libraries. The latter two require the Windows SDK to be installed.

The compiler you are using is pretty obscure. You'll need to read the small print in its manuals to figure out how to configure it properly so that the linker links those libraries. If you cannot sort this out by yourself or find somebody familiar with this IDE, I'd recommend you download the free Microsoft Visual Studio Express C++ edition. It takes care of a lot of those gritty details with project templates that presets a lot of compiler and linker settings. You'd want the Win32 Console Application template.

Hans Passant
thanks, i guess i'll try that out
Rowhawn