Project

General

Profile

Actions

Bug #205

closed

Undefined reference to 'select()'

Added by wa1ter almost 18 years ago. Updated over 17 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Something recently broke several ports with this same link error:

foo.o(.text+0x965): In function `foo::select()':
: undefined reference to `select(int, fd_set*, fd_set*, fd_set*, timeval*)'

Firefox, fam, and musicbrainz are three examples and I thinks there are
others as well.

select() is defined in libc, and I can see with ktrace that the linker
finds libc okay -- but it can't find 'select'.

Anyone else seeing this?

Actions #1

Updated by erik-wikstrom almost 18 years ago

On 2006-06-16 10:04, walt wrote:

Something recently broke several ports with this same link error:

foo.o(.text+0x965): In function `foo::select()':
: undefined reference to `select(int, fd_set*, fd_set*, fd_set*, timeval*)'

Firefox, fam, and musicbrainz are three examples and I thinks there are
others as well.

select() is defined in libc, and I can see with ktrace that the linker
finds libc okay -- but it can't find 'select'.

Anyone else seeing this?

There was some changes to select recently but I can't find the commit-
message, however I've found Alexey Slynko's mail to submit which you can
read here:
http://leaf.dragonflybsd.org/mailarchive/submit/2006-06/msg00003.html

Make sure you have the latest version of the sources and try again, you
might have updated at a bad moment.

Actions #2

Updated by dillon almost 18 years ago

:...
:>
:> Firefox, fam, and musicbrainz are three examples and I thinks there are
:> others as well.
:>
:> select() is defined in libc, and I can see with ktrace that the linker
:> finds libc okay -- but it can't find 'select'.
:>
:> Anyone else seeing this?
:
:There was some changes to select recently but I can't find the commit-
:message, however I've found Alexey Slynko's mail to submit which you can
:read here:
:http://leaf.dragonflybsd.org/mailarchive/submit/2006-06/msg00003.html
:
:Make sure you have the latest version of the sources and try again, you
:might have updated at a bad moment.
:
:--
:Erik Wikström

This happened to me too a few days ago.  I think it was due to the
sys/selinfo.h / unistd.h changes. I did a followup commit a couple of
days ago to try to fix it by changing the way prototypes were
conditionalized.
-Matt
Matthew Dillon
<>
Actions #3

Updated by dacut almost 18 years ago

walt wrote:

Something recently broke several ports with this same link error:

foo.o(.text+0x965): In function `foo::select()':
: undefined reference to `select(int, fd_set*, fd_set*, fd_set*, timeval*)'

Note that it's giving you the types of parameters -- this is a C++
feature (typesafe linkage), but select() is a C function.

A header has probably lost it's extern "C" { } guard.

Actions #4

Updated by wa1ter almost 18 years ago

On Fri, 16 Jun 2006, David Cuthbert wrote:

walt wrote:

Something recently broke several ports with this same link error:

foo.o(.text+0x965): In function `foo::select()':
: undefined reference to `select(int, fd_set*, fd_set*, fd_set*, timeval*)'

Note that it's giving you the types of parameters -- this is a C++ feature
(typesafe linkage), but select() is a C function.

A header has probably lost it's extern "C" { } guard.

Here is the actual code from fam, and there is no extern "C"
appearing anywhere in the file:

int status = ::select(nfds, &readfds, &writefds, 0, timeout);

Could you explain briefly the meaning of the :: for me? I've been
reading a c++ tutorial but I haven't come to that lesson yet :o)

Thanks!

Actions #5

Updated by corecode almost 18 years ago

On 17.06.2006, at 09:25, walt wrote:

Here is the actual code from fam, and there is no extern "C"
appearing anywhere in the file:

yes, it should be around the declaration

int status = ::select(nfds, &readfds, &writefds, 0, timeout);

Could you explain briefly the meaning of the :: for me? I've been
reading a c++ tutorial but I haven't come to that lesson yet :o)

:: accesses the top level, in comparison to the class function.

cheers
simon

Actions #6

Updated by wa1ter almost 18 years ago

Simon 'corecode' Schubert wrote:

On 17.06.2006, at 09:25, walt wrote:

Here is the actual code from fam, and there is no extern "C"
appearing anywhere in the file:

yes, it should be around the declaration

int status = ::select(nfds, &readfds, &writefds, 0, timeout);

Fam has one other example of the use of extern "C", but it
encloses the declaration (or is it definition?) of a prototype.
In the example above there is no prototype for 'select', so I'm
not sure where the 'extern' should go.

Just for fun I added this prototype to the code:
extern "C" int select(int, fd_set*, fd_set*, fd_set*, struct timeval*);
Now I get complaints from <sys/select.h> about duplicate definitions
of select() :o(

I've tried surrounding my new prototype with various #ifndefs, but
no joy so far.

I'm wondering if the recent changes to select.h have resulted in
a circular dependency somewhere. Dunno.

Actions #7

Updated by dacut almost 18 years ago

walt wrote:

Just for fun I added this prototype to the code:
extern "C" int select(int, fd_set*, fd_set*, fd_set*, struct timeval*);
Now I get complaints from <sys/select.h> about duplicate definitions
of select() :o(

This indicates that sys/select.h should be wrapped in the extern "C".
Sounds like this got removed from a recent commit.

In general, all headers for C functions should look like:

#ifndef MY_HEADER
#define MY_HEADER
#include <blah.h>
#include ...

#ifdef __cplusplus
extern "C" {
#endif

void my_function();

#ifdef __cplusplus
}
#endif

#endif /* MY_HEADER */

Actions #8

Updated by wa1ter almost 18 years ago

On Sun, 18 Jun 2006, David Cuthbert wrote:

walt wrote:

Just for fun I added this prototype to the code:
extern "C" int select(int, fd_set*, fd_set*, fd_set*, struct timeval*);
Now I get complaints from <sys/select.h> about duplicate definitions
of select() :o(

This indicates that sys/select.h should be wrapped in the extern "C". Sounds
like this got removed from a recent commit...

Simon just committed your suggestion -- problem solved!

Thanks to you both for your help.

Actions #9

Updated by steve almost 18 years ago

On Sun, 18 Jun 2006 00:28:36 -0700
walt <> wrote:

On Sun, 18 Jun 2006, David Cuthbert wrote:

walt wrote:

Just for fun I added this prototype to the code:
extern "C" int select(int, fd_set*, fd_set*, fd_set*, struct timeval*);
Now I get complaints from <sys/select.h> about duplicate definitions
of select() :o(

This indicates that sys/select.h should be wrapped in the extern "C". Sounds
like this got removed from a recent commit...

Simon just committed your suggestion -- problem solved!

Any chance of slipping the Preview tag on this ?

Actions #10

Updated by corecode almost 18 years ago

Steve O'Hara-Smith wrote:

Any chance of slipping the Preview tag on this ?

yep, done.

Actions #11

Updated by steve almost 18 years ago

On Sun, 02 Jul 2006 00:47:02 +0200
Simon 'corecode' Schubert <> wrote:

Steve O'Hara-Smith wrote:

Any chance of slipping the Preview tag on this ?

yep, done.

Thanks.

Actions

Also available in: Atom PDF