Page 1 of 2

CLIB2 failures

Posted: Mon Sep 28, 2015 7:09 pm
by xenic
Although the Final Edition SDK announcement at the Hyperion web site claims that the SDK includes an "Updated clib2 alternative C standard library", it apparently wasn't updated to use renamed AmigaDOS functions. Here is an example of the link failures I'm getting:

/SDK/clib2/lib/libc.a(stdlib_program_name.o): In function `stdlib_program_name_init_ctor':
stdlib_program_name.c:(.text+0xe4): undefined reference to `GetProgramName'
make: *** [usbsnd] Error 1

GetProgramName() was renamed to GetCliProgramName() and including "dos/obsolete.h" in a program has no effect on a precompiled library like libc.a which contains obsolete function names. Unless someone has a fix for this problem, could we please get a new clib2 for the new SDK in AmiUpdate or uploaded to OS4Depot??

Re: CLIB2 failures

Posted: Mon Sep 28, 2015 7:59 pm
by chris
You are best off posting this bug to the clib2 project: http://sourceforge.net/p/clib2/bugs/
The SDK simply provides a pre-compiled version.

Re: CLIB2 failures

Posted: Mon Sep 28, 2015 10:39 pm
by xenic
chris wrote:You are best off posting this bug to the clib2 project: http://sourceforge.net/p/clib2/bugs/
The SDK simply provides a pre-compiled version.
I'm not sure if that is the right place to look anymore. Various people have moved the project to at least 3 different repositories at Github. After checking out all the clib2 repositories at Github, it looks like adtools/clib2 is the right one. Olaf Barthel made some changes there in July. Personally, I think that if clib2 is going to be included in the SDK then one of the OS4 devs should join the project, keep it up-to-date for OS4 and compile it for any SDK releases.

I guess I'll just look for a workaround.

Re: CLIB2 failures

Posted: Tue Sep 29, 2015 2:13 am
by tonyw
Perhaps create a small object file with a few stubs?

Re: CLIB2 failures

Posted: Tue Sep 29, 2015 11:12 am
by broadblues
@xenic

clib2 itself is easy to build, IIRC, perhaps you could fix it an provide a patch.

Re: CLIB2 failures

Posted: Tue Sep 29, 2015 7:03 pm
by xenic
@all
Actually, my workaround is to compile with the previous SDK. Whoever added clib2 to the previous SDK must have compiled it themselves (probably including <dos/obsolete.h>). The clib2 changes log indicates "tfrieden" made some of the original changes for OS4. I guess none of the other OS4 devs stepped in to keep it updated. I filed bug reports at the sf.net clib2 repository and the Github clib2 repository but that doesn't mean it will get fixed.

Re: CLIB2 failures

Posted: Tue Sep 29, 2015 10:39 pm
by ssolie
xenic wrote:GetProgramName() was renamed to GetCliProgramName() and including "dos/obsolete.h" in a program has no effect on a precompiled library like libc.a which contains obsolete function names. Unless someone has a fix for this problem, could we please get a new clib2 for the new SDK in AmiUpdate or uploaded to OS4Depot??
I don't understand why this is a problem because we don't link by name.

What is really going on here? Can you provide a full explanation with example?

Here is where clib2 lives now -> https://github.com/adtools/clib2

Can somebody tell us what is broken?

Re: CLIB2 failures

Posted: Wed Sep 30, 2015 1:37 am
by xenic
ssolie wrote: I don't understand why this is a problem because we don't link by name.
It's a problem because when I compile this:

Code: Select all

/* gcc -mcrt=clib2 test.c -o test */

#include <proto/exec.h>
#include <proto/dos.h>

int main(int argc, char **argv)
{

	IDOS->Printf("Hello World\n");

	return 0;
}
I get this link error:
  • /SDK/clib2/lib/libc.a(stdlib_program_name.o): In function `stdlib_program_name_init_ctor':
    stdlib_program_name.c:(.text+0xe4): undefined reference to `GetProgramName'
What is really going on here? Can you provide a full explanation with example?

Here is where clib2 lives now -> https://github.com/adtools/clib2

Can somebody tell us what is broken?
I don't know anything about how we link but when I examined the file "stdlib_program_name.c" in the clib2 sourcecode at https://github.com/adtools/clib2, it contains the a call to the function "GetProgramName()" which is no longer present in "SDK:Include/include_h/interfaces/dos.h". It was replaced with "GetCliProgramName()". I could be wrong but I suspect that clib2 needs to be compiled with the SDK:Include/include_h/dos/obsolete.h" header file included.

If I replace the new "libc.a" with libc.a from the previous SDK I don't get a link error with the above example source.

Re: CLIB2 failures

Posted: Wed Sep 30, 2015 3:43 am
by broadblues
@xenic
but if you look at the commit logs on the github site you'll see Olaf added that header.

Could be it doesn't get included inot that one particular file somehow.

Just grab the source and build yourself a new copy.

Re: CLIB2 failures

Posted: Wed Sep 30, 2015 11:00 am
by salass00
Compiling with -Werror as well as -Wall would have stopped this accident from happening.

With only -Wall gcc would have produced an "implicit declaration of function" warning but because it's not treated as an error it can be really easy to miss in a project with lots of files to compile such as clib2.