[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c

Hello world console program with lcc-win32

thomas.mertes

7/7/2011 12:49:00 PM

Hi, I have a problem with lcc-win32:
The generated executables are not useable.

I use XP Service Pack 3
Lcc has version 3.8 Compilation date: Jan 29 2011
Lcc is installend in C:\lcc with the official installer.
The path variable contains C:\lcc\bin
The environment variable LCCDIR is set to C:\lcc

I just tried to compile hello world with lcc-win32.
Lcc generates an executable with lcc hello.c -o hello.exe
When I start hello.exe it writes nothing and hangs.
I need to kill ntvdm.exe to stop the hang. In some tests a
a message box appeared that tells me that Ntvdm found an
illegal instruction. The hello world is as follows:

---------- begin file hello.c ----------
#include <stdio.h>

int main (int argc, char *argv[])
{
printf("Hello, world\n");
return 0;
}
---------- end file hello.c ----------

Can it be, that I need to use WinMain?
This would certainly be a problem, since the application
I try to compile insists on having a 'main'.
Other C compilers for Windows allow 'main' also, so
hopefully this is not a problem for lcc-win32.

Please help me.
Thanks in advance for the effort.


Greetings Thomas Mertes

--
Seed7 Homepage: http://seed7.sourc...
Seed7 - The extensible programming language: User defined statements
and operators, abstract data types, templates without special
syntax, OO with interfaces and multiple dispatch, statically typed,
interpreted or compiled, portable, runs under linux/unix/windows.
15 Answers

Bartc

7/7/2011 3:12:00 PM

0

"tm" <thomas.mertes@gmx.at> wrote in message
news:26973786-538f-4b42-8c2c-63c02cddf797@n28g2000vbs.googlegroups.com...

> I just tried to compile hello world with lcc-win32.
> Lcc generates an executable with lcc hello.c -o hello.exe
> When I start hello.exe it writes nothing and hangs.
> I need to kill ntvdm.exe to stop the hang. In some tests a
> a message box appeared that tells me that Ntvdm found an
> illegal instruction. The hello world is as follows:

I think that you are telling it to name the object file as hello.exe instead
of hello.obj. No wonder it causes a problem...

Don't know to to combine compile and link in lcc-win32. But the following
ought to work:

lcc hello.c
lcclnk hello.obj
hello

--
Bartc


jacob navia

7/7/2011 3:37:00 PM

0

Le 07/07/11 14:49, tm a écrit :
> Hi, I have a problem with lcc-win32:
> The generated executables are not useable.
>
just tried to compile hello world with lcc-win32.
> Lcc generates an executable with lcc hello.c -o hello.exe

You should do

lc hello.c

"lc" and NOT "lcc". lcc just translates that to object
code format and needs a link.

If you are unsure just use the IDE, it is much easier

Keith Thompson

7/7/2011 5:23:00 PM

0

tm <thomas.mertes@gmx.at> writes:
> Hi, I have a problem with lcc-win32:
> The generated executables are not useable.
[...]

For future reference, questions like yours are better posted to
comp.compilers.lcc, or submitted to the lcc-win32 support mechanism.
You're asking about the behavior of a particular implementation,
not about the C language.

(Please ignore the inevitable flurry of followups claiming that
I'm being rude by suggesting a better way to get help.)

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.ne...
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

thomas.mertes

7/7/2011 5:49:00 PM

0

On 7 Jul., 17:37, jacob navia <ja...@spamsink.net> wrote:
> Le 07/07/11 14:49, tm a écrit :> Hi, I have a problem with lcc-win32:
> > The generated executables are not useable.
>
> just tried to compile hello world with lcc-win32.
>
> > Lcc generates an executable with lcc hello.c -o hello.exe
>
> You should do
>
> lc hello.c
>
> "lc" and NOT "lcc". lcc just translates that to object
> code format and needs a link.

Thank you for the information, it allowed me to proceed.
Compiling and execute hello world with lcc succeds. :-)

Now a different problem surfaced. Both ways

lc setpaths.c -o setpaths.exe

and

lcc -c setpaths.c
lcclnk setpaths.obj -o setpaths.exe

give me the error:

setpaths.obj .text: undefined reference to '__wgetcwd'

Which library is necessary for _wgetcwd?
Which lcclnk command links this library?
Which lc command links this library?
Do I need to set up some library search path?

AFAICS (at MSDN) _wgetcwd seems to be part of the windows version of
the standard C library. Other Windows C compilers do not require
special libraries for _wgetcwd.

> If you are unsure just use the IDE, it is much easier

Of cause, an IDE is easier to use.
In my case I want to do two things where an IDE would not help.
1. I want to create a makefile that allows other users to compile
Seed7 with lcc.
2. The Seed7 compiler generates C and needs a C compiler and linker
as backend.


Greetings Thomas Mertes

--
Seed7 Homepage: http://seed7.sourc...
Seed7 - The extensible programming language: User defined statements
and operators, abstract data types, templates without special
syntax, OO with interfaces and multiple dispatch, statically typed,
interpreted or compiled, portable, runs under linux/unix/windows.

jacob navia

7/7/2011 5:59:00 PM

0

Le 07/07/11 19:48, tm a écrit :
> On 7 Jul., 17:37, jacob navia<ja...@spamsink.net> wrote:
>> Le 07/07/11 14:49, tm a écrit :> Hi, I have a problem with lcc-win32:
>>> The generated executables are not useable.
>>
>> just tried to compile hello world with lcc-win32.
>>
>>> Lcc generates an executable with lcc hello.c -o hello.exe
>>
>> You should do
>>
>> lc hello.c
>>
>> "lc" and NOT "lcc". lcc just translates that to object
>> code format and needs a link.
>
> Thank you for the information, it allowed me to proceed.
> Compiling and execute hello world with lcc succeds. :-)
>
> Now a different problem surfaced. Both ways
>
> lc setpaths.c -o setpaths.exe
>
> and
>
> lcc -c setpaths.c
> lcclnk setpaths.obj -o setpaths.exe
>
> give me the error:
>
> setpaths.obj .text: undefined reference to '__wgetcwd'
>
> Which library is necessary for _wgetcwd?
> Which lcclnk command links this library?
> Which lc command links this library?
> Do I need to set up some library search path?
>
> AFAICS (at MSDN) _wgetcwd seems to be part of the windows version of
> the standard C library. Other Windows C compilers do not require
> special libraries for _wgetcwd.
>

wgetcwd is not a standard ANSI C function. I haven't gotten around
to writing it.

You can synthetize it
by getting the path with getcwd, then using mbstowcs to transform
it into a wide character string.

You can also synthetize it with the windows API using unicode.

jacob navia

7/7/2011 6:09:00 PM

0

Le 07/07/11 19:59, jacob navia a écrit :
>
> You can also synthetize it with the windows API using unicode.
>

Use the windows API with

GetCurrentDirectoryW

that is in kernel32.dll

thomas.mertes

7/7/2011 6:28:00 PM

0

On 7 Jul., 19:59, jacob navia <ja...@spamsink.net> wrote:
> Le 07/07/11 19:48, tm a écrit :
>
>
>
> > On 7 Jul., 17:37, jacob navia<ja...@spamsink.net> wrote:
> >> Le 07/07/11 14:49, tm a écrit :> Hi, I have a problem with lcc-win32:
> >>> The generated executables are not useable.
>
> >> just tried to compile hello world with lcc-win32.
>
> >>> Lcc generates an executable with lcc hello.c -o hello.exe
>
> >> You should do
>
> >> lc hello.c
>
> >> "lc" and NOT "lcc". lcc just translates that to object
> >> code format and needs a link.
>
> > Thank you for the information, it allowed me to proceed.
> > Compiling and execute hello world with lcc succeds. :-)
>
> > Now a different problem surfaced. Both ways
>
> > lc setpaths.c -o setpaths.exe
>
> > and
>
> > lcc -c setpaths.c
> > lcclnk setpaths.obj -o setpaths.exe
>
> > give me the error:
>
> > setpaths.obj .text: undefined reference to '__wgetcwd'
>
> > Which library is necessary for _wgetcwd?
> > Which lcclnk command links this library?
> > Which lc command links this library?
> > Do I need to set up some library search path?
>
> > AFAICS (at MSDN) _wgetcwd seems to be part of the windows version of
> > the standard C library. Other Windows C compilers do not require
> > special libraries for _wgetcwd.
>
> wgetcwd is not a standard ANSI C function. I haven't gotten around
> to writing it.

OKAY.
What other wide functions are missing?

I use the wide functions for Unicode support under Windows.
The Windows port of Seed7 with MinGW (and other compilers) uses:
_wchdir, _wgetcwd, _wmkdir(path), _wrmdir, _wopendir, _wreaddir,
_wclosedir, _wstati64, _wchmod, _wutime, _wremove, _wrename,
_wsystem, _wpopen, _wfopen, _wgetenv and _wputenv.

MinGW, Cygwin, MSVC, Borland, TinyC and DJGPP support them
(sometimes with and sometimes without underline, but this can
be handled with preprocessor macros).

> You can synthetize it
> by getting the path with getcwd, then using mbstowcs to transform
> it into a wide character string.

IMHO windows functions like getcwd handle strings depending on the
current codepage. So the Unicode support seems limited (but I am
not an expert of Windows codepages and multibyte strings).

> You can also synthetize it with the windows API using unicode.

Yes, but I was hoping that this work was already done. :-)

BTW. Is there support for files with 64 bit offsets?

Thanks in advance, for your effort.


Greetings Thomas Mertes

--
Seed7 Homepage: http://seed7.sourc...
Seed7 - The extensible programming language: User defined statements
and operators, abstract data types, templates without special
syntax, OO with interfaces and multiple dispatch, statically typed,
interpreted or compiled, portable, runs under linux/unix/windows.

thomas.mertes

7/7/2011 6:48:00 PM

0

On 7 Jul., 20:09, jacob navia <ja...@spamsink.net> wrote:
> Le 07/07/11 19:59, jacob navia a écrit :
>
>
>
> > You can also synthetize it with the windows API using unicode.
>
> Use the windows API with
>
> GetCurrentDirectoryW
>
> that is in kernel32.dll

Thank you for this information.
As you can see in the other post, I need other wide character
functions also.


Greetings Thomas Mertes

--
Seed7 Homepage: http://seed7.sourc...
Seed7 - The extensible programming language: User defined statements
and operators, abstract data types, templates without special
syntax, OO with interfaces and multiple dispatch, statically typed,
interpreted or compiled, portable, runs under linux/unix/windows.

jacob navia

7/7/2011 6:51:00 PM

0

Le 07/07/11 20:28, tm a écrit :

> OKAY.
> What other wide functions are missing?
>
> I use the wide functions for Unicode support under Windows.
> The Windows port of Seed7 with MinGW (and other compilers) uses:
> _wchdir,

SetCurrentDirectoryW

_wgetcwd,

GetCurrentDirectoryW

_wmkdir(path),

CreateDirectory

_wrmdir,

RemoveDirectory

_wopendir,
_wreaddir,
_wclosedir,

I don't know what those should do.

_wstati64,

Can be done with the windows API

_wchmod, _wutime,

_wremove, _wrename,
> _wsystem, _wpopen, _wfopen, _wgetenv and _wputenv.
>

None of those...

> MinGW, Cygwin, MSVC, Borland, TinyC and DJGPP support them

No, they link with the run time library of MSVC. I don't link with that
since it is not C99.


You can do this easily with:

Handle h = LoadLibrary("msvcrt.dll");

Then fill all the function pointers to each of those functions in
a loop with:

GetProcAddress(h,"wstati64");

etc

jacob

Bartc

7/7/2011 7:46:00 PM

0

"jacob navia" <jacob@spamsink.net> wrote in message
news:iv4v7d$dio$1@speranza.aioe.org...
> Le 07/07/11 20:28, tm a écrit :

>> MinGW, Cygwin, MSVC, Borland, TinyC and DJGPP support them
>
> No, they link with the run time library of MSVC. I don't link with that
> since it is not C99.
>
>
> You can do this easily with:
>
> Handle h = LoadLibrary("msvcrt.dll");
>
> Then fill all the function pointers to each of those functions in
> a loop with:
>
> GetProcAddress(h,"wstati64");

Looks like a lot of work.

You have a file MSVCRT.LIB in your distribution, which appears to contain
the function wgetcwd(). What is the purpose of that, if not for statically
linking with?

(In fact, the following seems to work, when linked with msvcrt.lib; I had to
guess the signature of _wgetcwd():

#include <stdio.h>
#include <stdlib.h>
#include <wctype.h>

wchar_t* _wgetcwd(wchar_t *,int);

int main(void)
{
wchar_t a[500];
int i;

_wgetcwd(a,500);

printf("%S\n",a);

}

)


--
Bartc