Linking programs with pdclib

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Stevo14
Member
Member
Posts: 179
Joined: Fri Mar 07, 2008 3:40 am
Location: Arad, Romania

Linking programs with pdclib

Post 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.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Linking programs with pdclib

Post 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').
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Stevo14
Member
Member
Posts: 179
Joined: Fri Mar 07, 2008 3:40 am
Location: Arad, Romania

Re: Linking programs with pdclib

Post 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.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Linking programs with pdclib

Post 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
User avatar
Stevo14
Member
Member
Posts: 179
Joined: Fri Mar 07, 2008 3:40 am
Location: Arad, Romania

Re: Linking programs with pdclib

Post 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.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Linking programs with pdclib

Post 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.
Every good solution is obvious once you've found it.
User avatar
Stevo14
Member
Member
Posts: 179
Joined: Fri Mar 07, 2008 3:40 am
Location: Arad, Romania

Re: Linking programs with pdclib

Post 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. :D
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Linking programs with pdclib

Post 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.
Every good solution is obvious once you've found it.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Linking programs with pdclib

Post 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 :wink:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Re: Linking programs with pdclib

Post 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.
Last edited by quok on Thu Sep 18, 2008 3:04 pm, edited 1 time in total.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: Linking programs with pdclib

Post 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
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Re: Linking programs with pdclib

Post 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. :)
Post Reply