This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: undefined reference to `__errno_location(void)'


On Wed, 04 Sep 2002 09:27:52 +0200
bjorn rohde jensen <bjensen@fastmail.fm> wrote:

> Hi Gordon,
> 
>   Could you post some (small) code demonstrating the problem?
> I think, you might be confusing ld's in its handling of weak/strong
> symbols during linking. It would be nice with some code to experiment
> with:)
> 
> Yours sincerely,
> 
> Bjorn
> 
> 

Sure enough! Here's the smallest code that I've written that has this problem.

===

#include <cstdio>
#include <cerrno>
#include <cstring>

int main(int argc, char **argv)
{
        extern int errno;
        FILE *fp;

        errno = 0;

        if(!(fp=fopen("Somestupidfile.txt","r"))) {
                printf("File error: %s\n",strerror(errno));
        }
        else {
                fclose(fp);
        }

        return 0;
}

===

This is just a stupid little code, but it demonstrates the problem.
If I try to compile it with g++ I get the following errors:

[root@vaghn (~/prog)] 10:42:17 $ g++ -Wall test.c -o test
/tmp/ccka9V3Q.o: In function `main':
/tmp/ccka9V3Q.o(.text+0x8): undefined reference to `__errno_location(void)'
/tmp/ccka9V3Q.o(.text+0x3d): undefined reference to `__errno_location(void)'
collect2: ld returned 1 exit status

Thank you for all your help.

Sincerely,

Gordon R. Ellsworth, Jr.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]