Allegro.cc - Online Community

Allegro.cc Forums » The Depot » AMGC2 Loader

This thread is locked; no one can reply to it. rss feed Print
 1   2 
AMGC2 Loader
miran
Member #2,407
June 2002

Still the same. If you print out the value dlerror() returns like Thomas said, it can help a bit. I added that in my copy and here's what it reports after failing to load the .so:

./amgc2load: undefined symbol: GetPlugin

Which is weird. But it gets even more weird if I compile your program manually with g++ -o amgc2load main.cpp -I../src/ -ldl `allegro-config --libs`:

�@: cannot open shared object file: No such file or directory

Only if I compile with -O2, I get the first error. So maybe it's something about the way it's compiled. Maybe something doesn't get linked in properly?

--
sig used to be here

juvinious
Member #5,145
October 2004
avatar

Hmm maybe it's a name conflict. I didn't realize that the export "C" is GetPlugin for the loader and I'm using that as well.
I just changed it to loadPlugin throughout hopefully that's the problem.
I uploaded it with the changes to the first post.

__________________________________________
Paintown

miran
Member #2,407
June 2002

Makes no difference.

--
sig used to be here

juvinious
Member #5,145
October 2004
avatar

:'(
There is no hope.
Missing libraries?
What distro?

__________________________________________
Paintown

miran
Member #2,407
June 2002

Quote:

There is no hope.

:'(

Quote:

Missing libraries?

What could be missing?

Quote:

What distro?

FC5_x64, but what could that have to do with anything? My code works when I use it, but not when you use it... :(

EDIT: I made a little test program which works like your loader. It includes IGame.h and plugin.h from the AMGC2 source dir and uses them to load a plugin specified with the command line and prints out plugin info i n an Allegro window. Analyze it and see what you're doing differently, because this program works just fine for me.

1#include <plugin.h>
2#include <IGame.h>
3 
4int main(int argc, char **argv) {
5 if (argc >= 2) {
6 IGame *game = *(new Plugin<IGame>(argv[1]));
7 if (game) {
8 allegro_init();
9 set_color_depth(32);
10 set_gfx_mode(GFX_AUTODETECT_WINDOWED, 400, 32, 0, 0);
11 install_keyboard();
12 textprintf_ex(screen, font, 0, 0, -1, -1, "name: %s", game->GetName());
13 textprintf_ex(screen, font, 0, 8, -1, -1, "author: %s", game->GetAuthor());
14 textprintf_ex(screen, font, 0, 16, -1, -1, "description: %s", game->GetDescription());
15 textprintf_ex(screen, font, 0, 24, -1, -1, "version: %s", game->GetVersion());
16 delete game;
17 readkey();
18 }
19 }
20
21 return 0;
22}
23END_OF_MAIN();

And here's the makefile too. I use the same makefile to compile your loader as well. (note: I keep the source code in a directory under the AMGC2 dir)

CFLAGS = -s -O2 -W -Wall -I../src/

LIBS = \
  -ldl\
   `allegro-config --libs`

all: main.cpp
  g++ -o ../testload main.cpp $(CFLAGS) $(LIBS)

--
sig used to be here

juvinious
Member #5,145
October 2004
avatar

I do exactly the same thing except for two things:
I install the keyboard before set_color_depth(32) and I don't use -ldl in my build flags.
Did you try getting info for a plugin through the command line?
./amgc2load plugin.so -i
It prints the same information to the console.

__________________________________________
Paintown

Thomas Fjellstrom
Member #476
June 2000
avatar

I downloaded the loader thing yesterday sometime, and it works fine here.

I repeat, IT WORKS HERE. These are the steps I followed:
1. downloaded amgc2load
2. ran the amgc2 compile script
3. CDed into the res/amgc2/games/tetris folder
4. typed "make"
5. CDed back to the base amgc2load folder
6. ran: ./amgc2load res/amgc2/games/testris/tetris.so
7. PROFIT!

--
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

miran
Member #2,407
June 2002

Quote:

I install the keyboard before set_color_depth(32) and I don't use -ldl in my build flags.

It doesn't matter, the same happens if I build with your cbuild script or my makefile.

Quote:

Did you try getting info for a plugin through the command line?
./amgc2load plugin.so -i
It prints the same information to the console.

No difference. The error occurs when loading the .so.

Thomas: Yes, that's how it's supposed to be. But for some reason this doesn't work for me in Linux (it works in Windows though)...

--
sig used to be here

Audric
Member #907
January 2001

Time to check the linker version ?
For mingw I have:
$ ld -v
GNU ld version 2.15.91 20040904

$ gcc -v
Reading specs from C:/MSYS/mingw/bin/../lib/gcc/mingw32/3.4.5/specs
Configured with: ../gcc-3.4.5/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shared --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchronization --enable-libstdcxx-debug
Thread model: win32
gcc version 3.4.5 (mingw special)

amgc2 loader is useful, by the way, since amgc2 spends a noticeable time scanning the directories for all games (listing them in text mode, white text on black background, was a bit too much, I think) So the loader is valuable for quicker testing during development. Can even run it from the makefile :)

miran
Member #2,407
June 2002

Quote:

amgc2 loader is useful, by the way, since amgc2 spends a noticeable time scanning the directories for all games (listing them in text mode, white text on black background, was a bit too much, I think)

That's only really applicable in Windows. In Linux all the plugins are scanned so quickly you never even see that printout ;)

--
sig used to be here

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

Thomas: Yes, that's how it's supposed to be. But for some reason this doesn't work for me in Linux (it works in Windows though)...

Then maybe theres something wrong with YOUR system? Seems to work for several other people.

--
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

miran
Member #2,407
June 2002

Well, yeah, it looks like it...

--
sig used to be here

juvinious
Member #5,145
October 2004
avatar

That's the pita of binary based distros.
You wouldn't have that problem if you were using a real distro. *cough *cough gentoo. ;)

Anyhow, I've updated my missle defend clone to use game_path so that it can be loaded in any directory. It's attached, if not you can grab it from its page.

Now if we can get the other plugin developers to update their plugins to use the game_path, my loader will be easier to use. :)

__________________________________________
Paintown

miran
Member #2,407
June 2002

Did you by mistake put the wrong source in the tar.gz you attached to your last post? Because your code crashes. Guess what is wrong. Here's a small hint:

1//...snip...
2class MissleDefend : public IGame
3{
4 public:
5 
6 Manager *gameManager;
7 
8 MissleDefend() : IGame()
9 {
10 //Nothing
11 }
12 
13 ~MissleDefend()
14 {
15 delete gameManager;
16 }
17//...snip...

;)

Here's another hint for you:

1// this is how it should look like:
2class MissleDefend : public IGame
3{
4 public:
5 
6 Manager *gameManager;
7 
8 MissleDefend() : IGame(), gameManager(0)
9 {
10 //Nothing
11 }
12 
13 ~MissleDefend()
14 {
15 if (gameManager) {
16 delete gameManager;
17 gameManager = 0;
18 }
19 }

Another minor suggestion: Rename the README file to readme.txt, startup my GUI host program and be amazed. :)

And finally a request from the general public: Could anyone running Windows that also happens to have Allegro 4.2.0, AMGC2 and preferably the MinGW compiler please try to compile a Windows DLL of the game? Here are the instructions:

1. Unpack the game to amgc2/games.
2. Edit the makefile so that line 4 looks like this: SRCDIR=../..
3. Edit mdefend.cpp so that the code starting at line 2271 looks like the second snippet in this post.
4. Run "make win" and ignore all the warnings.
5. Run amgc2.exe to verify that mdefend.dll works.
6. Attach mdefend.dll here or send to my email (in amgc2's readme.txt).
7. Go play a couple of rounds of Missile Defend! It's good! :)

--
sig used to be here

juvinious
Member #5,145
October 2004
avatar

Quote:

Because your code crashes.

Heh, I'm not suprised considering the amgc2loader isn't working for you. ;P
But yeah you are right I should be initializing it to 0 and having the check before deleting. I changed it to look like that and renamed readme.txt to comform to amgc2. ::)

On a side note my loader seems to be a tad bit slower than yours, but not incredibly slower, I assume the timing is a bit off in my loader. I just ran it and it worked fine in amgc2 and in the loader.

Source attached. (deleted from previous post)

__________________________________________
Paintown

GullRaDriel
Member #3,861
September 2003
avatar

I was trying to compile it and put it here, but I got errors:

1C:\Download\amgc2\amgc2\src>make
2g++ -O2 -fomit-frame-pointer -ffast-math -funroll-loops -s -W -Wall -mwindows -D
3__GTHREAD_HIDE_WIN32API -o obj/mingw/MainMenu.o -c MainMenu.cpp
4MainMenu.cpp: In member function `virtual void IconItem::DrawItem(MAS::Bitmap&,
5int, int, const MAS::Rect&)':
6MainMenu.cpp:14: error: 'class MAS::ListBoxEx' has no member named 'AreGridLines
7Enabled'
8MainMenu.cpp:15: error: `DrawGrid' undeclared (first use this function)
9MainMenu.cpp:15: error: (Each undeclared identifier is reported only once for ea
10ch function it appears in.)
11c:/Codeblocks/bin/../lib/gcc/mingw32/3.4.4/../../../../include/MASkinG/compound.
12h: At global scope:
13c:/Codeblocks/bin/../lib/gcc/mingw32/3.4.4/../../../../include/MASkinG/compound.
14h:37: warning: unused parameter 'objList'
15c:/Codeblocks/bin/../lib/gcc/mingw32/3.4.4/../../../../include/MASkinG/compound.
16h:37: warning: unused parameter 'cmp'
17c:/Codeblocks/bin/../lib/gcc/mingw32/3.4.4/../../../../include/MASkinG/compound.
18h:37: warning: unused parameter 'focusObject'
19c:/Codeblocks/bin/../lib/gcc/mingw32/3.4.4/../../../../include/MASkinG/compound.
20h:37: warning: unused parameter 'c'
21make: [obj/mingw/MainMenu.o] Error 1 (ignored)
22g++ -o ../amgc2.exe -O2 -fomit-frame-pointer -ffast-math -funroll-loops -s -W -W
23all -mwindows -D__GTHREAD_HIDE_WIN32API obj/mingw/main.o obj/mingw/MainMenu.o ob
24j/mingw/GameDriver.o obj/mingw/PluginManager.o obj/mingw/hsc.o obj/mingw/HscDial
25og.o obj/mingw/fps.o obj/mingw/screenshot.o obj/mingw/OptionsDlg.o obj/mingw/Key
26Settings.o obj/mingw/KeyDialog.o obj/mingw/SettingsDialog.o obj/mingw/global.o o
27bj/mingw/OnlineDlg.o -lmasking -lalfont -lalleg obj/mingw/icon.res
28g++: obj/mingw/MainMenu.o: No such file or directory
29make: *** [main] Error 1

Lots of warnings before, and I was forced to change OBJDIR to obj/mingw32 instead of obj\mingw32

We will see later ;-)

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

miran
Member #2,407
June 2002

You need MASkinG from CVS. But why do you want to compile AMGC2.exe? Does the precompiled version not work for you? If you just want to compile the game dll, you don't need to compile amgc2 itself, you just need to have its source code.

--
sig used to be here

GullRaDriel
Member #3,861
September 2003
avatar

I don't have CVS allowed trough our fucking proxy.

I got some work to finish, and I will try to give you this dll after.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

miran
Member #2,407
June 2002

Quote:

I don't have CVS allowed trough our fucking proxy.

As I said, you do NOT need MASkinG at all! To compile game dlls you just need a couple of files from the AMGC2 code and plain Allegro.

--
sig used to be here

GullRaDriel
Member #3,861
September 2003
avatar

Attached is the dll.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

miran
Member #2,407
June 2002

Thanks. :D

Hehe, I was able to compile it myself actually as I'm at work right now where I use a Windows machine and had 15 minutes of time :)

Juvinious: AMGC2 page has been updated and now lists Missile Defend v1.9 :)

--
sig used to be here

Neil Walker
Member #210
April 2000
avatar

Hello,
I have nothing to add to this thread, other than to say I think your newly designed website is most excellent and a great design. Well done that man.

(the only thing that would be nice would be an inclusion of online manual for your libraries, e.g. masking)

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

miran
Member #2,407
June 2002

Quote:

Hello,
I have nothing to add to this thread, other than to say I think your newly designed website is most excellent and a great design. Well done that man.

(the only thing that would be nice would be an inclusion of online manual for your libraries, e.g. masking)

Thanks, that's a good idea. I might even write some tutorials some time... :D

--
sig used to be here

 1   2 


Go to: