Closed walkero-gr closed 2 years ago
The cause is presumably the way how the mui headers are used. This leads to a MUI_NewObject
in each object file. If you do this correctly, the linker should complain about missing MUI_NewObject
which is then resolved by adding -lmui
.
If you can share the source - public or per private email - I might be able to point you in the right direction.
@bebbo I really appreciate your help. The project is open source and you can find it at https://github.com/walkero-gr/iGame/tree/sqlite . I use the Makefile to compile it, where you can see the compiler and linker flags.
What I do not understand, and that is the reason I opened this issue, is why this linker issue appears only with this gcc 6 cross-compiling setup and I do not have it with GCC 8 cross compiler, or even with vbcc in cross compiler, GCC 6 and 11 PPC native (on my OS4 system), where I am able to compile the same code.
Thank you again for your help and time spent on this.
I pushed a change to the mui.sdk to patch proto/muimaster.h
.
Now you only have to add -lmui
to the linker options.
And I strongly recommend to add -noixemul
to the CFLAGS. Also pass the CFLAGS to the linker!
@bebbo
Unfortunately, nothing of the above worked. Could it be a problem that I compile the gcc with make min
?
I was looking at the makefile and I wanted to ask you where exactly do you patch the gcc to work well with Amiga systems. In AmigaOS 4 compatible adtools there is a list of patches done before the build, which can be seen at https://github.com/sba1/adtools/tree/master/gcc/6/patches Your setup does not need something like that?
I also tried to compile your gcc 6 with make all
but as soon as I tried to compile the application I got the following error:
In file included from src/funcs.c:54:0:
/opt/amiga/m68k-amigaos/sys-include/stdio.h:29:19: fatal error: _ansi.h: No such file or directory
#include "_ansi.h"
^
compilation terminated.
Which is weird, because I can't find that _ansi.h file anywhere.
these are changes I needed:
git diff
diff --git a/Makefile b/Makefile
index 02295ef..aed8962 100644
--- a/Makefile
+++ b/Makefile
@@ -40,7 +40,7 @@ CFLAGS_OS4 = -c -Os -fomit-frame-pointer -std=c99 -D__USE_INLINE__ -DCPU_VERS=Am
# Builder settings
##########################################################################
#MKLIB = join
-LIBFLAGS = -v -lamiga -lstubs -o
+LIBFLAGS = -v -lamiga -lstubs -lmui -o
LIBFLAGS_MOS = -v -lamiga -lstubs -o
LIBFLAGS_OS4 = -v -lamiga -lstubs -o
diff --git a/src/fsfuncs.c b/src/fsfuncs.c
index 5519ceb..474aa76 100644
--- a/src/fsfuncs.c
+++ b/src/fsfuncs.c
@@ -562,7 +562,7 @@ void open_current_dir(void)
}
//Open path directory
- OpenWorkbenchObject((char *)path_only);
+ OpenWorkbenchObject((char *)path_only, TAG_DONE);
free(path_only); // get_directory_path uses malloc()
}
diff --git a/src/funcs.c b/src/funcs.c
index ae27637..1b24b63 100644
--- a/src/funcs.c
+++ b/src/funcs.c
@@ -68,7 +68,7 @@
extern struct ObjApp* app;
extern struct Library *GfxBase;
extern struct Library *IconBase;
-extern struct Library *IntuitionBase;
+extern struct IntuitionBase *IntuitionBase;
extern char* executable_name;
/* global variables */
@bebbo I think you tested the default branch and not the one I gave you above. But if this compiled fine for you, then there is a possibility that my setup is wrong.
If I create a docker image with your Dockerfile at https://github.com/bebbo/amiga-gcc/blob/master/Dockerfile would that be able to work fine and compile the same code as you did, or this is not up to date?
docker should work - I don't use that.,,
the sqlite branch fails for me because of
src/sqldb.h:5:21: fatal error: sqlite3.h: No such file or directory
#include <sqlite3.h>
ok, got that from aminet:
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: src/iGameMain.o: in function `main':
src/iGameMain.o:(.text+0x7ec): undefined reference to `createDB'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: src/fsfuncs.o: in function `load_games_db_list':
src/fsfuncs.o:(.text+0x548): undefined reference to `sqlGetItems'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: src/fsfuncs.o: in function `save_to_db':
src/fsfuncs.o:(.text+0x752): undefined reference to `sqlAddItem'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: src/fsfuncs.o:(.text+0x706): undefined reference to `sqlDBOpen'
collect2: error: ld returned 1 exit status
my changes in the Makefile:
diff --git a/Makefile b/Makefile
index 321fe89..4fa40c3 100644
--- a/Makefile
+++ b/Makefile
@@ -33,7 +33,7 @@ INCLUDES = -I$(NDK_INC) -I$(MUI50_INC) -I/opt/sdk/sqlite/include
INCLUDES_OS4= -ISDK:MUI/C/include -I$(MUI50_INC)
INCLUDES_MOS= -I$(NDK_INC) -I$(MUI50_INC)
-CFLAGS = -c -O2 -fomit-frame-pointer -std=c99 -DCPU_VERS=68000 -DRELEASE_DATE=$(DATE)
+CFLAGS = -c -noixemul -O2 -fomit-frame-pointer -std=c99 -DCPU_VERS=68000 -DRELEASE_DATE=$(DATE)
CFLAGS_030 = -c -mcpu=68030 -Os -fomit-frame-pointer -std=c99 -DCPU_VERS=68030 -DRELEASE_DATE=$(DATE)
CFLAGS_040 = -c -mcpu=68040 -Os -fomit-frame-pointer -std=c99 -DCPU_VERS=68040 -DRELEASE_DATE=$(DATE)
CFLAGS_060 = -c -mcpu=68060 -Os -fomit-frame-pointer -std=c99 -DCPU_VERS=68060 -DRELEASE_DATE=$(DATE)
@@ -44,7 +44,7 @@ CFLAGS_OS4 = -c -O3 -D__USE_INLINE__ -DCPU_VERS=AmigaOS4 -DRELEASE_DATE=$(DATE)
# Builder settings
##########################################################################
#MKLIB = join
-LIBFLAGS = -v -L/opt/sdk/sqlite/lib -lamiga -lstubs -lsqlite3 -noixemul -o
+LIBFLAGS = -v -noixemul -L/opt/sdk/sqlite/lib -lamiga -lstubs -lsqlite3 -lmui -o
LIBFLAGS_MOS = -v -lamiga -lstubs -o
LIBFLAGS_OS4 = -v -lsqlite3 -o
-noixemul
in CFLAGS and LDFLAGS !-lmui
rest is up to you
adding the additional src file results in a linked program:
diff --git a/make_includes/obj_000.inc b/make_includes/obj_000.inc
index 94776dd..3fc0277 100644
--- a/make_includes/obj_000.inc
+++ b/make_includes/obj_000.inc
@@ -16,3 +16,7 @@ src/strfuncs.o: src/strfuncs.c src/strfuncs.h
src/fsfuncs.o: src/fsfuncs.c src/fsfuncs.h
$(CC) $(CFLAGS) $(INCLUDES) -o $@ src/fsfuncs.c
+
+src/sqldb.o: src/sqldb.c src/sqldb.h
+ $(CC) $(CFLAGS) $(INCLUDES) -o $@ src/sqldb.c
+
diff --git a/make_includes/obj_files.inc b/make_includes/obj_files.inc
index 0980ef8..7c58ddf 100644
--- a/make_includes/obj_files.inc
+++ b/make_includes/obj_files.inc
@@ -2,7 +2,7 @@
# Object files which are part of iGame
##########################################################################
-OBJS = src/funcs.o src/iGameGUI.o src/iGameMain.o src/strfuncs.o src/fsfuncs.o
+OBJS = src/funcs.o src/iGameGUI.o src/iGameMain.o src/strfuncs.o src/fsfuncs.o src/sqldb.o
OBJS_030 = src/funcs_030.o src/iGameGUI_030.o src/iGameMain_030.o src/strfuncs_030.o src/fsfuncs_030.o
OBJS_040 = src/funcs_040.o src/iGameGUI_040.o src/iGameMain_040.o src/strfuncs_040.o src/fsfuncs_040.o
OBJS_060 = src/funcs_060.o src/iGameGUI_060.o src/iGameMain_060.o src/strfuncs_060.o src/fsfuncs_060.o
Thank you @bebbo for your continues help. I tried today with the Dockerfile that exists at your repo, and with that I get the same linker issues. Of course I tested all your comments above, and the issue still remains.
So, either you have something completely different on your system where you do the compilations, or there is something missing from the repo and the compilation of the gcc is not going as it should.
So, my question is if you have anything on your system that is not synced with the repo? Have you tried recently to make a clean installation of this repo to a VM or somewhere and confirm it works fine?
the real question is: WTF is flexcat
... and why is it needed
@bebbo Flexcat is the equivalent of catcomp and it is necessary to create the catalog and translation files. It is available for many systems and is used by many when using cross-compiling environments. Why is this a problem for you? Would you like me to upload in my repo the generated files from flexcat, so that you can do your tests without the need to use flexcat?
@bebbo Flexcat is the equivalent of catcomp and it is necessary to create the catalog and translation files. It is available for many systems and is used by many when using cross-compiling environments. Why is this a problem for you? Would you like me to upload in my repo the generated files from flexcat, so that you can do your tests without the need to use flexcat?
@bebbo Flexcat is the equivalent of catcomp and it is necessary to create the catalog and translation files. It is available for many systems and is used by many when using cross-compiling environments. Why is this a problem for you? Would you like me to upload in my repo the generated files from flexcat, so that you can do your tests without the need to use flexcat?
If you really want help, then you should make it as easy as possible to reproduce the problem. Right now you can't build it out of the box, e.g. with the Dockerfile. Maybe you could provide a dockerfile for this problem here?
You are right. I will make a dockerfile, based on your own, that will have everything for you to reproduce the problem.
@bebbo Hello Stefan. I forked your repo today and edited the dockerfile to add iGame and MUI 5 examples, so to test compiling them with your gcc 6. In the dockerfile I left at the end comments on how I did the compiling and if you try iGame you will see the problems I mentioned before. Also, I was not able to compile the MUI examples.
https://github.com/walkero-gr/bebbo-amiga-gcc/blob/master/Dockerfile
Any help or ideas are well appreciated. Thank you in advance for your help.
@bebbo I just did some more changes and this seems to compile now. Let me investigate it further and will get back to you.
@bebbo OK... The problem actually was that I was using the original MUI SDK and not the one that is coming from you installation. Possibly some of the changes you have done are mandatory.
Thank you so much for your help. I will keep on tinkering with it.
glad you solved it.
I don't think your patch to proto/muimaster_lib.h is good as it basically prevents one from using the inline function path. In particular it disables functions like NewObject(). It would have been better if @walkero-gr made the choice to use or not use the INLINE macros in his projects.
I just ran into an issue with a MUI project that does not attempt to link against mui.lib and because of this patch runs into unresolved symbols.
I am a little bit lost with a problem I experience with the gcc 6 for 68k. I try to move a project I am working on from vbcc to gcc for all the supported platform. It compiles fine for OS4 with gcc 8 cross-compiler but it fails with the gcc 6 for 68k at the linker stage, although the sources seem to compile fine.
Below is the output of the linker of gcc 6 for 68k, with -v flag
As you can see it complains for multiple definition of a method from MUI 5 SDK
Here is the output of the gcc 8 linker, with -v flag
Both of them are under linux, cross compiling the same code.
Any idea why the gcc 6 complains for multiple definitions and fails to build the final binary? Thank you for your help.