Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » allegro interface

Credits go to Elias, Evert, Peter Wang, and Thomas Fjellstrom for helping out!
This thread is locked; no one can reply to it. rss feed Print
 1   2   3 
allegro interface
Matěj Týč
Member #9,863
June 2008
avatar

Hello again,
I have discovered quite disturbing things, when I have played with Allegro build setup.
1. The distributed include files somehow contain platform-dependent stuff. I have read somwhere that the library interface should be platform independent and it sounds as a very smart thing...
2. The allegro library has different names across platforms (for instance alleg42 on w32 and (lib)alleg on Linux). What about making it the same? Symlinks on Linux may ensure the backward compatibility
3. I really suggest renaming ASM files with CPP code from foo.s to foo.S or something like that (gcc needs this to autodetect the right file type)
4. Allegro 4.2 C and ASM versions are not compatible at that moment, what about fixing it?

I can do the work, I would just like to know whether it is OK for you or not...

I would also like an advice from those who understand X11: The autotools-compiled allegro library works, but the resolution of the fullscreen mode is always set to the desktop resolution and although the screen bitmap has the right size, it is not stretched to the physical screen.
What can be the cause of that?

Cheers, Matej

---------------------------------------------------
Mind is like space, it is open, clear and unlimited. -- Ole Nydahl

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

3. I really suggest renaming ASM files with CPP code from foo.s to foo.S or something like that (gcc needs this to autodetect the right file type)
4. Allegro 4.2 C and ASM versions are not compatible at that moment, what about fixing it?

The ASM code has been dropped. 4.2 is a dead end. 4.3 is WIP for 4.4 (4.4 will essentially be an updated 4.2), so please work on that and tells us how things go.

Quote:

1. The distributed include files somehow contain platform-dependent stuff. I have read somwhere that the library interface should be platform independent and it sounds as a very smart thing...

Allegro has to use platform specific code in order to work on the different platforms. In some cases you can also include special headers to gain access to platform specific allegro functions which make it easier to get at platform stuff like win32 window handles and such. The main allegro API is platform independent, if you only use Allegro and language functions (and other platform independent libs).

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Quote:

1. The distributed include files somehow contain platform-dependent stuff. I have read somwhere that the library interface should be platform independent and it sounds as a very smart thing...

Not quite sure what you mean here. Could you be more specific and provide an example? The library interface is platform independent, and that ability comes from platform dependent headers that get included during the build process. At least that's how I see it.

Quote:

3. I really suggest renaming ASM files with CPP code from foo.s to foo.S or something like that (gcc needs this to autodetect the right file type)

I didn't know there was any C++ code in Allegro. Which files have it?

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

I didn't know there was any C++ code in Allegro. Which files have it?

He probably means C PreProcessor. but you can call gcc with asm files and use -x assembler-with-cpp IIRC. Which allegro probably does...

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Peter Wang
Member #23
April 2000

Quote:

1. The distributed include files somehow contain platform-dependent stuff. I have read somwhere that the library interface should be platform independent and it sounds as a very smart thing...

Not sure what you mean. Can you explain?

Quote:

2. The allegro library has different names across platforms (for instance alleg42 on w32 and (lib)alleg on Linux). What about making it the same? Symlinks on Linux may ensure the backward compatibility

I don't see what advantage there would be to making the Unix library names conform to DOS 8.3 limitations.

Quote:

3. I really suggest renaming ASM files with CPP code from foo.s to foo.S or something like that (gcc needs this to autodetect the right file type)

AFAIK, .S is for assembly files, so that wouldn't help at all.

Quote:

4. Allegro 4.2 C and ASM versions are not compatible at that moment, what about fixing it?

No. It would probably mean breaking ABI compatibility with existing 4.2.x versions, which is not allowed. Besides, as we keep saying, asm is dropped from 4.3 onwards.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Elias
Member #358
May 2000

Quote:

Hello again,
I have discovered quite disturbing things, when I have played with Allegro build setup.
1. The distributed include files somehow contain platform-dependent stuff. I have read somwhere that the library interface should be platform independent and it sounds as a very smart thing...

I assume you mean that bug that some of the config results leak into allegro.h? I thought that was fixed some time ago, but maybe it wasn't.

Quote:

2. The allegro library has different names across platforms (for instance alleg42 on w32 and (lib)alleg on Linux). What about making it the same? Symlinks on Linux may ensure the backward compatibility

For A5, the static library names are now like:

liballegro-static-4.9.6.a

Quote:

3. I really suggest renaming ASM files with CPP code from foo.s to foo.S or something like that (gcc needs this to autodetect the right file type)

Makes sense according to man gcc - however, are any such files still used in 4.3.10? If not, we might as well remove them instead of rename.

Quote:

4. Allegro 4.2 C and ASM versions are not compatible at that moment, what about fixing it?

I can do the work, I would just like to know whether it is OK for you or not...

Hard to fix, as I believe some parts of the code (I think "bank switchers", whatever that is) are only written in C or ASM or something like that. And again, we mostly dropped asm support as far as I understand.

Quote:

I would also like an advice from those who understand X11: The autotools-compiled allegro library works, but the resolution of the fullscreen mode is always set to the desktop resolution and although the screen bitmap has the right size, it is not stretched to the physical screen.
What can be the cause of that?

We use the (by now half deprecated - so you may have to install it first on your system) XVidMode extension to set fullscreen modes. If you compile Allegro without that extension, you cannot get fullscreen modes (instead the window is centered and the rest of the desktop is blacked out).

--
"Either help out or stop whining" - Evert

Evert
Member #794
November 2000
avatar

As keeps being said, stop worrying about 4.2. It's not going to go anywhere at this point. It's done and finished, future development is elsewhere.

Quote:

2. The allegro library has different names across platforms (for instance alleg42 on w32 and (lib)alleg on Linux). What about making it the same?

What on Earth for? Seriously, why?

Quote:

4. Allegro 4.2 C and ASM versions are not compatible at that moment, what about fixing it?

Great idea, now why did we never think of that? ::)
Read Peter's post for the answer. With hindsight, we should have dropped it in the 4.1 WIP series before 4.2 was out, but sadly that thought didn't hit until a few weeks after 4.2 was released, when it was too late for ABI reasons.

Matěj Týč
Member #9,863
June 2008
avatar

Thank you all for your replies,

Thomas Fjellstrom said:

In some cases you can also include special headers to gain access to platform specific allegro functions which make it easier...

OK, that sounds reasonable. Both Unix and Windows packages distribute all headers though, so I will investigate which ones are disposable.

Peter Wang said:

I don't see what advantage there would be to making the Unix library names conform to DOS 8.3 limitations.

I don't know what are those DOS limitations, but the reasons for that are following ones:
1. Why not? The 4.2.x library can be named alleg42 on Windows and liballeg42.so.something on unix. Every time you would pass -lalleg42 to link with it...
2. It makes it easy for people to check for it and to cross compile, especially when they use autotools :-)

One question I forgot to ask: Linux version produces also some alleg_unsharable library, what's that?

Elias said:

For A5, the static library names are now like: liballegro-static-4.9.6.a

And why to give different names to static and shared libraries? Why not just liballegro49.a?
Have you took a look on how libtool does this thing? I think it is quite smart..

Peter Wang said:

AFAIK, .S is for assembly files, so that wouldn't help at all.

It really works. However, are you really so sure that there won't be any further 4.2 release? With some bugs fixed and proper autotools support:D?
Anyway, I suggest deleting ASM files from other branches since they are just making things look more complicated...

Elias said:

Hard to fix, as I believe some parts of the code (I think "bank switchers", whatever that is) are only written in C or ASM or something like that

I am surprised that the fact that functions are implemented in a different way implies that the libraries are not compatible. Interesting, but I don't doubt that.

Elias said:

We use the ... XVidMode extension ...

Thanks, it helped me to correct a bug in the build setup and now it seems to work;), thank you.

---------------------------------------------------
Mind is like space, it is open, clear and unlimited. -- Ole Nydahl

Evert
Member #794
November 2000
avatar

Quote:

1. Why not? The 4.2.x library can be named alleg42 on Windows and liballeg42.so.something on unix. Every time you would pass -lalleg42 to link with it...

Except that you should not be linking with -lalleg on UNIX systems to begin with. Also, it's supposed to be liballeg.a on both platforms (alleg.lib for MSVC), just the DLL is called alleg42.dll on Windows.

Quote:

And why to give different names to static and shared libraries?

Because you may want to have both installed.

Quote:

Linux version produces also some alleg_unsharable library, what's that?

Code that should not go into the shared object for one reason or another, I forgot the details. I think the magic main goes in there if you use/need one, for instance.

Quote:

I am surprised that the fact that functions are implemented in a different way implies that the libraries are not compatible.

Something to do with the calling conventions being different between the two. This is a remnant from long ago.

Quote:

However, are you really so sure that there won't be any further 4.2 release? With some bugs fixed and proper autotools support:D?

Bug fixes at most, but not more. Shouldn't anyway.

Matěj Týč
Member #9,863
June 2008
avatar

Thank you for your replies,

Quote:

Except that you should not be linking with -lalleg on UNIX systems to begin with

Do you mean that I should use allegro-config and AM_PATH_ALLEGRO? I really don't like those tools and I think that thanks to the fact that Allegro is monolithic library, those tools are an overkill. I wanted to add pkg-config support, but that tool does not support cross compilation out of the box right now and also doesn't integrate well with autotools and it is not going to change in the near future :(

Quote:

And why to give different names to static and shared libraries?
...
Because you may want to have both installed.

This should be OK since they have different suffixes. Let the compiler choose(you can pass the -static flag)... Is something wrong with that?

Quote:

Linux version produces also some alleg_unsharable library, what's that?
...
Code that should not go into the shared object for one reason or another

I am really surprised about that, I have never heard of such thing :o. Is it still neccessarry? I have built the library into just one file and it seems to work fine...

---------------------------------------------------
Mind is like space, it is open, clear and unlimited. -- Ole Nydahl

Martin Kalbfuß
Member #9,131
October 2007
avatar

The simplest way, would be a multi-platform allegro-config. (pkg-config). Than the lib names aren't longer of interrest for the end user.

allegro-config --static

-L/usr/local/lib -Wl,--export-dynamic -lalleg -lm -lXxf86vm -lXcursor -lXpm -lXext -lX11 -lpthread -ldl

Simple passing -lalleg isn't enough.
It isn't overkill. It's overkill to do this stuff yourself.

There is a m4 package for allegro. You don't need the allegro-config tool when using autotools.

http://remote-lisp.spdns.de -- my server side lisp interpreter
http://www.nongnu.org/gm2/ -- Modula-2 alias Pascal++

Evert
Member #794
November 2000
avatar

Quote:

Do you mean that I should use allegro-config and AM_PATH_ALLEGRO?

Yes.

Quote:

I really don't like those tools and I think that thanks to the fact that Allegro is monolithic library, those tools are an overkill.

As pointed out, no, they're not. Do you prefer to enter the output of allegro-config --libs manually? Also, you may not like allegro-config for some reason, but lots of other people do.
Personally, I hate the fact that there's no equivalent for it on Windows.

Quote:

This should be OK since they have different suffixes.

Hmm... yes, you're right, they do. Maybe it is indeed overkill.

Quote:

I am really surprised about that, I have never heard of such thing :o. Is it still neccessarry?

Usually not I think, but I really haven't looked at this recently. Most libraries you're likely to use probably do not try to hijack your main() function either. ;)
I think there was some other code that had to go in there, but I don't remember the details.

Martin Kalbfuß
Member #9,131
October 2007
avatar

The difference between the names of the static and dynamic library is the version number. This is necessary for having different versions of allegro installed. But there should be a link called liballeg.so To ease the building process.

http://remote-lisp.spdns.de -- my server side lisp interpreter
http://www.nongnu.org/gm2/ -- Modula-2 alias Pascal++

Peter Wang
Member #23
April 2000

Quote:

Let the compiler choose(you can pass the -static flag)... Is something wrong with that?

Yes. That makes your binary completely statically linked, instead of just Allegro.

Quote:

I think there was some other code that had to go in there, but I don't remember the details.

Pretty sure it was because some (all?) hand written asm functions were not relocatable. This wouldn't be a problem in 4.3+.

Martin Kalbfuß
Member #9,131
October 2007
avatar

You can use -Wl,-static option to link only allegro as a static lib.

http://remote-lisp.spdns.de -- my server side lisp interpreter
http://www.nongnu.org/gm2/ -- Modula-2 alias Pascal++

Matěj Týč
Member #9,863
June 2008
avatar

Quote:

Do you mean that I should use allegro-config and AM_PATH_ALLEGRO?
...
Yes
...
Do you prefer to enter the output of allegro-config --libs manually?

The AM_PATH_ALLEGRO macro is not trivial as well as the allegro-config script and they are probably a pain to maintain.
I have found out that if you use autotools, you can just add alleg to your LIBS (inside the configure script) and if a libtool Allegro library is installed, it is going to be OK (AM_PATH_ALLEGRO macro is not needed then)
And for people who use IDEs or who don't like libtool, I will provide pkg-config support. (pkg-config allegro --libs instead of allegro-config --libs)
Now I think that this is really smary and it even complies to standards 8-)

Quote:

Pretty sure it was because some (all?) hand written asm functions were not relocatable. This wouldn't be a problem in 4.3+.

What is the consequence of this? I have compiled Allegro 4.2 with ASM to one shared library and stuff seem to work fine. Are there any risks assotiated?

---------------------------------------------------
Mind is like space, it is open, clear and unlimited. -- Ole Nydahl

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

What is the consequence of this? I have compiled Allegro 4.2 with ASM to one shared library and stuff seem to work fine. Are there any risks assotiated?

The code wont link or run properly on all platforms. dynamic linking usually ends up relocating the code. Non relocatable code uses absolute jump points and such. Some linkers can manage to work with it, but many can't.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Matt Smith
Member #783
November 2000

It was the calling conventions (as pointed out, in the bank switching funcs) in the asm that were different from the C version. The asm version was in the official 4.2 ABI, so if you made a C only version it made an incompatible DLL.

In 4.3, the ABI uses the C calling convention. The asm has been stripped out for simplicity, but if it goes back in it will have to be wrapped in cdecl stack parameter passing. There is not currently any appetite for this, as the asm would only compile where gcc is available (not from within a VC project. All our attempts to invoke gas as an external tool failed with every version of VC) and would need to be maintained.

I do somewhat regret losing all the asm code. compilers are getting better but it's a fact that many people find the asm faster, especially on older machines where it matters most. I do agree however, with stripping it all out first, as all the build tools treat x86 as the default choice, due to Allegro's DOS only origins. When/if asm is grafted back in, it should be triggered by non-default macros. I'm talking specifically about replacing ALLEGRO_USE_C and ALLEGRO_NO_ASM with an ALLEGRO_USE_686_ASM etc. when required.

Matěj Týč
Member #9,863
June 2008
avatar

Quote:

I do somewhat regret losing all the asm code.

Something can probably go back, but it should be more robust, standards-complying etc. I think that some external tool like this would be ideal for that.

---------------------------------------------------
Mind is like space, it is open, clear and unlimited. -- Ole Nydahl

SiegeLord
Member #7,827
October 2006
avatar

Quote:

Something can probably go back, but it should be more robust, standards-complying etc. I think that some external tool like this would be ideal for that.

Too bad it's license is incompatible with that of allegro :P

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Matěj Týč
Member #9,863
June 2008
avatar

Quote:

Too bad it's license is incompatible with that of allegro

It's two clause BSD license (http://l4ka.org/bsdlicense.php). How come that Allegro is not compatible with it? Do we have a different disclamer or what?

---------------------------------------------------
Mind is like space, it is open, clear and unlimited. -- Ole Nydahl

Peter Wang
Member #23
April 2000

Traditionally we only accepted code which could be licensed under 'giftware' in Allegro, although we have relaxed that for the addons in 4.3.

Evert
Member #794
November 2000
avatar

Quote:

How come that Allegro is not compatible with it?

The other way around. ;) Allegro has a less (!) restrictive license. Have you never looked at Allegro's license?

Anyway, as Peter said, what goes for Allegro does not necessarily go for (bundled) addons.

Matěj Týč
Member #9,863
June 2008
avatar

So I see that the disclamer is +- the same :)
I consider that BSD license as some protection of the user than some sort of a restriction, maybe it wouldn't be bad to include the rest into the giftware license as well.
However, distributing it as an addon should be OK. Some --with-liboil configure switch combined with some notification should do it. I think that ricers can start their work!

---------------------------------------------------
Mind is like space, it is open, clear and unlimited. -- Ole Nydahl

 1   2   3 


Go to: