Problem about Linux API

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem about Linux API

chao sun
I installed mingw on my Ubuntu 10.10.
Then i test with a short program that calls Linux API sleep().
When compile it with mingw in this way:

i586-mingw32msvc-gcc -o hello.exe hello.c

It reports an error:

/tmp/ccZ492RP.o:hello.c.text+0x35): undefined reference to `_sleep'
collect2: ld returned 1 exit status

But when compile it with Linux gcc, it works fine.
What's more, it works also with Cygwin.
I guess maybe the difference between the sleep functions on Windows
which is ::Sleep() and linux which is sleep().

Does that mean we cannot compile any program that calls Linux api with mingw ??

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Problem about Linux API

lrn-2
On 21.06.2011 13:14, chao sun wrote:

> I installed mingw on my Ubuntu 10.10.
> Then i test with a short program that calls Linux API sleep().
> When compile it with mingw in this way:
>
> i586-mingw32msvc-gcc -o hello.exe hello.c
>
> It reports an error:
>
> /tmp/ccZ492RP.o:hello.c.text+0x35): undefined reference to `_sleep'
> collect2: ld returned 1 exit status
>
> But when compile it with Linux gcc, it works fine.
> What's more, it works also with Cygwin.
> I guess maybe the difference between the sleep functions on Windows
> which is ::Sleep() and linux which is sleep().
>
> Does that mean we cannot compile any program that calls Linux api with mingw ??
>
Yes.
MinGW != Cygwin.
MinGW does not aim to provide POSIX compatibility. You have to port
software.

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Problem about Linux API

Roman Wieczorek
do not use windows ::Sleep() version, behaviour is different than linux sleep
boost::this_thread::sleep() - probably is best

2011/6/21 LRN <[hidden email]>:

> On 21.06.2011 13:14, chao sun wrote:
>> I installed mingw on my Ubuntu 10.10.
>> Then i test with a short program that calls Linux API sleep().
>> When compile it with mingw in this way:
>>
>> i586-mingw32msvc-gcc -o hello.exe hello.c
>>
>> It reports an error:
>>
>> /tmp/ccZ492RP.o:hello.c.text+0x35): undefined reference to `_sleep'
>> collect2: ld returned 1 exit status
>>
>> But when compile it with Linux gcc, it works fine.
>> What's more, it works also with Cygwin.
>> I guess maybe the difference between the sleep functions on Windows
>> which is ::Sleep() and linux which is sleep().
>>
>> Does that mean we cannot compile any program that calls Linux api with mingw ??
>>
> Yes.
> MinGW != Cygwin.
> MinGW does not aim to provide POSIX compatibility. You have to port
> software.
>
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
> _______________________________________________
> MinGW-users mailing list
> [hidden email]
>
> This list observes the Etiquette found at
> http://www.mingw.org/Mailing_Lists.
> We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.
>
> _______________________________________________
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users
> Also: mailto:[hidden email]?subject=unsubscribe
>

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Problem about Linux API

Tor Lillqvist
> boost::this_thread::sleep() - probably is best

>>> i586-mingw32msvc-gcc -o hello.exe hello.c

but if he is using C, not C++, suggesting boost is pointless. Anyway,
the Sleep() in Win32 works fine, you just have to know that the
parameter is milliseconds, not seconds. So using boost for this even
in C++ code would be slight overkill if you aren't otherwise using
boost.

--tml

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Problem about Linux API

lrn-2
On 21.06.2011 14:40, Tor Lillqvist wrote:
>> boost::this_thread::sleep() - probably is best
>>>> i586-mingw32msvc-gcc -o hello.exe hello.c
> but if he is using C, not C++, suggesting boost is pointless. Anyway,
> the Sleep() in Win32 works fine, you just have to know that the
> parameter is milliseconds, not seconds. So using boost for this even
> in C++ code would be slight overkill if you aren't otherwise using
> boost.
>
Actually, the "correct" way of sleeping is WaitForSingleObject (), as it
has some properties of sleep()/usleep() that Sleep() does not have, such
as interruption.

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Problem about Linux API

Earnie Boyd
In reply to this post by lrn-2
LRN wrote:
> On 21.06.2011 13:14, chao sun wrote:
>> Does that mean we cannot compile any program that calls Linux api with mingw ??
>>
> Yes.
> MinGW != Cygwin.
> MinGW does not aim to provide POSIX compatibility. You have to port
> software.

Or use Cygwin if you can live with the slower response in the program.
To port the software you can find help at msdn.microsoft.com.

--
Earnie
-- http://www.for-my-kids.com

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe