Page 1 of 1
Linking programs with pdclib
Posted: Tue Sep 09, 2008 5:41 am
by Stevo14
Hi,
I've started moving my OS's shell out of the kernel and into it's own binary file. I chose pdclib (Public Domain C lib) as the standard C library for my OS, mainly because it is free from and POSIX requirements. Building it was super easy but when I tried linking with it I get this error:
Code: Select all
In file included from ../../pdclib/internals/_PDCLIB_int.h:23,
from ../../pdclib/includes/string.h:16,
from ./src/iobot.c:1:
../../pdclib/internals/_PDCLIB_aux.h:53:2: error: #error PDCLib might not be fully conforming to either C89 or C95 prior to v2.x.
The make file for this program (which is itself a custom I/O library for my OS (called "iobot")) is setup like this:
Code: Select all
COMPILE_PARAMS=-O -Wall -Wextra -Werror -nostdinc -nostartfiles -fno-builtin -ffreestanding -fno-stack-protector
INCLUDE_PATHS=-I./inc -I../../pdclib/includes -I../../pdclib/internals
OBJ_PATH=./bin
SRC_PATH=./src
all :
#
# iobot
@cp -u ../../kernel/inc/syscall.h ./inc
@gcc $(COMPILE_PARAMS) $(INCLUDE_PATHS) -c -o $(OBJ_PATH)/iobot.o $(SRC_PATH)/iobot.c
@ar rcs $(OBJ_PATH)/libiobot.a $(OBJ_PATH)/iobot.o
As you can see, there is not actually any linking going on here. I'm just including <string.h> in iobot.c.
Also, the pdclib site seems to be down so I can't go looking there for any documentation.
Re: Linking programs with pdclib
Posted: Tue Sep 09, 2008 7:38 am
by Combuster
It "requires" an ISO C99 compiler. Pass -std=c99 to gcc to fix it the correct way, or remove that error line if you can't be bothered with strict conformance.
P.S. Since the library was fairly incomplete when I started using it, and AFAIK it still is, I had to append several more functions for getting other things to compile in turn. If you find something missing, you can find some stuff in my OS' codebase. The libc bits should all be public domain, let me know if I forgot to put up a copyright tag somewhere (which technically means 'all rights reserved').
Re: Linking programs with pdclib
Posted: Tue Sep 09, 2008 8:20 am
by Stevo14
Thanks Combuster. I commented out the #error... line and it compiled/linked/ran without problems. The header very clearly says, "You should not have to edit anything in this file; if you DO have to, it would be considered a bug / missing feature: notify the author(s)." so I wanted some advice before editing.
btw, the libc directory in your source tree contains
a lot more code than what I have in my current pdclib tree. Am I using some ancient version of pdclib or have you added
that much code? (all of /math/, /ctype/, and /stdio/ are missing for me(!))
EDIT: The project's
home page gives me an internal server error, so I can't access the svn repository to get the absolute latest version.
Re: Linking programs with pdclib
Posted: Tue Sep 09, 2008 8:25 am
by AJ
Hi,
PDCLib is incomplete (it's on version 0.4.1, IIRC). If you need full libc functionality now, try Newlib (sorry, Solar!) or add in your own stubs where needed.
Cheers,
Adam
Re: Linking programs with pdclib
Posted: Tue Sep 09, 2008 8:58 am
by Stevo14
AJ wrote:If you need full libc functionality now, try Newlib (sorry, Solar!)
Well, I don't need full libc functionality right now. I basically need string.h, stdio.h, and stdlib.h just to get my shell going.
Re: Linking programs with pdclib
Posted: Mon Sep 15, 2008 8:52 am
by Solar
Sorry, haven't checked the forum during my vacation.
Thanks for pointing out the Internal Server error; will try to fix that tonight. (What's wrong now, damnit...)
The warning is, as Combuster correctly pointed out, because I assume a C99 compiler setting. (I only have the C99 standard document at hand currently.) Post-1.0 versions of PDCLib might support older compiler settings. I don't see why you should run your compiler in legacy setting, though.
Yes, PDCLib is very much incomplete currently, and thinking about how long I have been promising to get stdio.h done makes me angry with myself. I can't really help it at the moment, though, as rennovating our new home and getting to grips with a company gone insane ranks higher on my priority list and the cosy train trips to and from work have been replaced with a 10-minute car drive - my PDCLib time is reduced to zero for the time being.
Re: Linking programs with pdclib
Posted: Mon Sep 15, 2008 11:04 am
by Stevo14
Solar wrote:
The warning is, as Combuster correctly pointed out, because I assume a C99 compiler setting. (I only have the C99 standard document at hand currently.) Post-1.0 versions of PDCLib might support older compiler settings. I don't see why you should run your compiler in legacy setting, though.
ATM I'm not passing any --std="foo" options to gcc (yes, I know, "me |= bad | lazy"). So gcc must default to legacy standards (or no standards)?
Solar wrote:
Yes, PDCLib is very much incomplete currently, and thinking about how long I have been promising to get stdio.h done makes me angry with myself. I can't really help it at the moment, though, as rennovating our new home and getting to grips with a company gone insane ranks higher on my priority list and the cosy train trips to and from work have been replaced with a 10-minute car drive - my PDCLib time is reduced to zero for the time being.
Well, there's no rush from me. I grabbed the relevant public-domain stdio parts from the link that Combuster provided, integrated them into my local PDClib sources, and am now writing the glue code. At this point the library suits my needs. Thanks for all your hard work Solar.
Re: Linking programs with pdclib
Posted: Mon Sep 15, 2008 12:13 pm
by Solar
Stevo14 wrote:So gcc must default to legacy standards (or no standards)?
Indeed GCC defaults to "gnu89", i.e. C89 (or rather, C90) with GNU-specific extensions. C99 support in GCC is still not complete...
Edit: Website is back up. Thanks for pointing it out.
Re: Linking programs with pdclib
Posted: Tue Sep 16, 2008 4:08 am
by Combuster
Solar wrote:Yes, PDCLib is very much incomplete currently, and thinking about how long I have been promising to get stdio.h done makes me angry with myself. I can't really help it at the moment, though, as rennovating our new home and getting to grips with a company gone insane ranks higher on my priority list and the cosy train trips to and from work have been replaced with a 10-minute car drive - my PDCLib time is reduced to zero for the time being.
My age-old offer to steal missing parts of pdclib back still stands
Re: Linking programs with pdclib
Posted: Tue Sep 16, 2008 10:39 am
by quok
Solar wrote:Stevo14 wrote:So gcc must default to legacy standards (or no standards)?
Indeed GCC defaults to "gnu89", i.e. C89 (or rather, C90) with GNU-specific extensions. C99 support in GCC is still not complete...
You can get the status of C99 support in GCC from
this link for the latest CVS code (currently 4.4). It has links to similar pages for past releases as well. That page and the page for GCC 4.3 seem to be the same after giving a quick once-over, so here's the list of things missing:
[*]wide character library support in <wchar.h> and <wctype.h> (library issue, missing support)
[*]complex (and imaginary) support in <complex.h> (broken)
[*]extended identifiers (missing)
[*]extended integer types in <stdint.h> (missing)
[*]treatment of error conditions by math library functions (math_errhandling) (library issue, missing)
[*]IEC 60559 (also known as IEC 559 or IEEE arithmetic) support (broken)
[*]additional predefined macro names (missing)
[*]standard pragmas (missing)
Although standard pragmas are missing, support for the _Pragma preprocessor directive is complete.
The 4.3 series finally has support for C99's inline. No more passing -fgnu-inline to gcc with -std=c99 or -std=gnu99, heh.
Re: Linking programs with pdclib
Posted: Thu Sep 18, 2008 2:23 am
by jal
quok wrote:You can get the status of C99 support in GCC from
this link
Not quite, but
this link should work.
JAL
Re: Linking programs with pdclib
Posted: Thu Sep 18, 2008 3:05 pm
by quok
jal wrote:quok wrote:You can get the status of C99 support in GCC from
this link
Not quite, but
this link should work.
JAL
Gah, that's what I get for not checking the link during preview... thanks for the correction. I updated my above post as well.