Compiling C++ for Android: select command

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

CRoberson
Posts: 2056
Joined: Mon Mar 13, 2006 2:31 am
Location: North Carolina, USA

Compiling C++ for Android: select command

Post by CRoberson »

I've downloaded the CodeSourcery stuff (the free stuff if that makes a difference) and tried compiling Ares. There is only one compile error (now) and that is on the select command which works on my other Linux G++ compilers.

Here is the error:
compmov.cpp:170:63: error: 'select' was not declared in this scope.

At the top of compmov.cpp, I have these:
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>

#include <iostream>
#include <time.h>
#include "headers.h"

So, what is different about this compiler than G++ for Linux x86 64 bit that makes it not work?
User avatar
stegemma
Posts: 859
Joined: Mon Aug 10, 2009 10:05 pm
Location: Italy
Full name: Stefano Gemma

Re: Compiling C++ for Android: select command

Post by stegemma »

I suggest to find in witch of the headers is included "select" in G++ and then search for the correspondent one in android compiler.

Can you post the line of code where "select" is used?
CRoberson
Posts: 2056
Joined: Mon Mar 13, 2006 2:31 am
Location: North Carolina, USA

Re: Compiling C++ for Android: select command

Post by CRoberson »

stegemma wrote:I suggest to find in witch of the headers is included "select" in G++ and then search for the correspondent one in android compiler.

Can you post the line of code where "select" is used?
The online GNU manuals claim it is in <sys/types.h>. In their manual, they have a sample program. I cut/pasted it in a file and get the same error.

The example is on this page:

http://www.gnu.org/savannah-checkouts/g ... or-I_002fO

My code is:

select(32, &readfds, (fd_set *) 0,(fd_set *) 0, &timeout);
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Compiling C++ for Android: select command

Post by Sven »

Just a wild guess, try <sys/select.h> if that exists. Found here.

Sven
CRoberson
Posts: 2056
Joined: Mon Mar 13, 2006 2:31 am
Location: North Carolina, USA

Re: Compiling C++ for Android: select command

Post by CRoberson »

Sven Schüle wrote:Just a wild guess, try <sys/select.h> if that exists. Found here.

Sven
#include <sys/select.h>

The compiler says no such file or directory.
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Compiling C++ for Android: select command

Post by Sven »

CRoberson wrote:
Sven Schüle wrote:Just a wild guess, try <sys/select.h> if that exists. Found here.

Sven
#include <sys/select.h>

The compiler says no such file or directory.
Hmm. Maybe you try something like "man -M <directory of Sourcery G++ man pages> select"?

Or could there be some offending code included in your "headers.h" that confuses the compiler?

Sven
CRoberson
Posts: 2056
Joined: Mon Mar 13, 2006 2:31 am
Location: North Carolina, USA

Re: Compiling C++ for Android: select command

Post by CRoberson »

Sven Schüle wrote:
CRoberson wrote:
Sven Schüle wrote:Just a wild guess, try <sys/select.h> if that exists. Found here.

Sven
#include <sys/select.h>

The compiler says no such file or directory.
Hmm. Maybe you try something like "man -M <directory of Sourcery G++ man pages> select"?

Or could there be some offending code included in your "headers.h" that confuses the compiler?

Sven
I also tried the example on the page you referenced. It fails the same way.
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Compiling C++ for Android: select command

Post by Sven »

CRoberson wrote:
Sven Schüle wrote:
CRoberson wrote:
Sven Schüle wrote:Just a wild guess, try <sys/select.h> if that exists. Found here.

Sven
#include <sys/select.h>

The compiler says no such file or directory.
Hmm. Maybe you try something like "man -M <directory of Sourcery G++ man pages> select"?

Or could there be some offending code included in your "headers.h" that confuses the compiler?

Sven
I also tried the example on the page you referenced. It fails the same way.
I am not sure whether this thread covers a somewhat related topic. But at least it shows that there are some "standard" things not implemented in that toolchain.

Sven
wgarvin
Posts: 838
Joined: Thu Jul 05, 2007 5:03 pm
Location: British Columbia, Canada

Re: Compiling C++ for Android: select command

Post by wgarvin »

My guess is that "select" is a socket function, and I guess Ares is trying to use it to detect if there is input available to be read.

But the uCLinux platform that compiler is for has been stripped down, and perhaps it does not include that function.

[Edit: the things removed from uCLinux are mostly things that can't be implemented without an MMU. Such as fork(). Sockets could probably be supported, but I don't know if it does.]
CRoberson
Posts: 2056
Joined: Mon Mar 13, 2006 2:31 am
Location: North Carolina, USA

Re: Compiling C++ for Android: select command

Post by CRoberson »

wgarvin wrote:My guess is that "select" is a socket function, and I guess Ares is trying to use it to detect if there is input available to be read.

But the uCLinux platform that compiler is for has been stripped down, and perhaps it does not include that function.

[Edit: the things removed from uCLinux are mostly things that can't be implemented without an MMU. Such as fork(). Sockets could probably be supported, but I don't know if it does.]
It is testing for input on stdin.

If this can't be accomplished then that explains all the missing functionality in Android based Chess programs compared to the PC Chess programs.