English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 13 April 2020, 02:36   #1
ouya
Registered User

 
Join Date: Apr 2020
Location: Germany
Posts: 8
vbcc linker issue

Hi,

trying to get some amiga demo code running i installed a vs-code vbcc integration and am facing a strange linker issue

I described the issue here:
https://github.com/prb28/vscode-amig...ample/issues/7

but still i do not understand why an object file could cause the program to "not call" its main method at startup
Even it was corrupt the linked exe should work fine , right?
I tested it so,that I removed all audio.o. related stuff from main.c and it works fine without linking to audio.o, but once I add it to the executable (same code in main.c) it just stops calling main()

Any experience on why vbcc executables can be blocked by object files on startup?
did not see this behaviour ever when working with gcc on x64-systems.

Thanks for any comment.

Last edited by ouya; 13 April 2020 at 02:44.
ouya is offline  
Old 13 April 2020, 08:53   #2
robinsonb5
Registered User
 
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 1,030
Quote:
Originally Posted by ouya View Post
Any experience on why vbcc executables can be blocked by object files on startup?
did not see this behaviour ever when working with gcc on x64-systems.

Without seeing your actual code I can only guess, but the most likely explanation is that audio.c contains an init function (i.e. a function whose name starts with _INIT) which is getting called before main.


See http://www.ibaug.de/vbcc/doc/vbcc_2....ctor-functions for more details on this facility.
robinsonb5 is offline  
Old 13 April 2020, 12:08   #3
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,919
I didn’t find the code to audio.c on that Github page so it’s hard to make any qualified comments. Provided that you linked with the standard startup code the only reason for a program to fail before entry into main() is a constructor function, as robinsonb5 already pointed out. Or you are linking with mieee.lib and the mathieee*.library cannot be opened. Or you are linking with auto.lib and another referenced library cannot be opened.

You may want to link with -M to generate a map file. Also have a look at the return code after executing your program.
phx is offline  
Old 13 April 2020, 12:32   #4
ouya
Registered User

 
Join Date: Apr 2020
Location: Germany
Posts: 8
https://github.com/Zalewa/snekorama/...r/snek/amiga_c

is the code I want to compile and link.

System: MacOS Catalina, VsCode with VsCode-Amiga-Vbcc integration, Includes/Headers NDK3.9

I am using the Makefile ( adapted from https://github.com/prb28/vscode-amiga-vbcc-example )

CC=vc -c99
VASM=vasmm68k_mot
VLINK=vlink
LDFLAGS=-stdlib -noixemul -s
CONFIG=+aos68k
ODIR=build-vbcc

EXE=fs-uae/hd0/main
_OBJ = game.o main.o audio.o view.o list.o vec2.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))

# Prepare variables for target 'clean'
ifeq ($(OS),Windows_NT)
RM:=del
PATHSEP:=\\
CONFIG:=${CONFIG}_win
else
RM:=rm -f
PATHSEP:=/
endif

all: $(EXE)

$(EXE) : $(OBJ)
$(VLINK) -x -bamigahunk -Bstatic -Cvbcc -nostdlib -mrel $(VBCC)/targets/m68k-amigaos/lib/startup.o $(OBJ) -lauto -lamiga -L$(VBCC)/targets/m68k-amigaos/lib -lvc -o $(EXE)

$(ODIR)/%.o : %.c
$(CC) $(CONFIG) -g -c -o $@ $<

$(ODIR)/%.o : %.s
$(VASM) -m68000 -linedebug -o $@ $<

clean:
-$(RM) $(ODIR)$(PATHSEP)*.o
-$(RM) $(subst /,$(PATHSEP),$(EXE))

I noticed not only audio but also view are the files that when linked result in the described problem. The other object files work well and main() is called

Last edited by ouya; 13 April 2020 at 13:51.
ouya is offline  
Old 13 April 2020, 12:46   #5
ouya
Registered User

 
Join Date: Apr 2020
Location: Germany
Posts: 8
__INIT_5_DataTypesBase: global reloc, value 0x16a8, size 0
__INIT_5_IntuitionBase: global reloc, value 0x205c, size 0
__INIT_5_GfxBase: global reloc, value 0x20e0, size 0

These __INIT are added to the map file when linking all object files, but are not present when removing audio and view.

How can I see the return code? main() is not called, so no return value
ouya is offline  
Old 13 April 2020, 13:09   #6
robinsonb5
Registered User
 
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 1,030
Quote:
Originally Posted by ouya View Post
__INIT_5_DataTypesBase: global reloc, value 0x16a8, size 0

The datatypes.library and individual datatypes are disk-based - are they present and correctly set up in your test environment?
robinsonb5 is offline  
Old 13 April 2020, 13:37   #7
ouya
Registered User

 
Join Date: Apr 2020
Location: Germany
Posts: 8
maybe not

first time i read about datatypes.library

i downloaded a version from a forum link. Should I just link it?

ps: in both audio.c and view.c I do #include <proto/datatypes.h>

pss: all missing include dirs: I added them from NDK3.9 - until it compiled. Maybe its not the correct libs or missing stuff although not complaining and compiling?

psss: datatypes only around since AmigaOs 3.0. So if I also want to target amiga500 it will not work with NDK3.9 right?

Last edited by ouya; 13 April 2020 at 14:22.
ouya is offline  
Old 13 April 2020, 14:32   #8
robinsonb5
Registered User
 
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 1,030
Quote:
Originally Posted by ouya View Post
maybe not

first time i read about datatypes.library

OK I'm not talking about your build environment - I mean the Amiga environment in which you're trying to run your executable.


You said you're using FS-UAE. Which kickstart are you using, and which files are on your boot disk?



I suspect the datatypes.library is missing from that boot disk, or something else about your Amiga boot environment is preventing datatypes.library from opening.
robinsonb5 is offline  
Old 13 April 2020, 15:01   #9
ouya
Registered User

 
Join Date: Apr 2020
Location: Germany
Posts: 8
i guess that is right. All points to a problem with the datatypes.lib

launch.json

"--chip_memory=1024",
"--hard_drive_0=${workspaceFolder}/fs-uae/hd0",
"--joystick_port_1=none",
"--amiga_model=A1200",
"--slow_memory=1792",
"--remote_debugger=200",
"--use_remote_debugger=true",
"--automatic_input_grab=0"

no special files on FS-UAE. assuming 1200 uses kickstart 3.1 or higher
ouya is offline  
Old 13 April 2020, 16:31   #10
Samurai_Crow
Total Chaos forever!

Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 46
Posts: 1,693
One more thought: if you don't link against amiga.lib, the libraries won't be defined either.
Samurai_Crow is offline  
Old 13 April 2020, 23:04   #11
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,919
Quote:
Originally Posted by ouya View Post
psss: datatypes only around since AmigaOs 3.0. So if I also want to target amiga500 it will not work with NDK3.9 right?
You can use NDK3.9 to create executables which are compatible with Kickstart 1.3, but you have to take care not to use any features which appeared in 2.0 or later, like datatypes. You also shouldn't use the -Rshort option with vlink, which generates relocations with 16-bit offsets (only supported since OS 2.0) - this is the default setting with vbcc's aos68k config.

For Kickstart 1.3 development I would recommend the m68k-kick13 target together with the original 1.3-NDK.

Quote:
Originally Posted by Samurai_Crow View Post
One more thought: if you don't link against amiga.lib, the libraries won't be defined either.
Not sure what you mean. You can call AmigaOS funtions without linking amiga.lib when you include <proto/xyz.h>. This makes sure vbcc is doing OS calls directly with inline-code. amiga.lib would only be needed for the OS-call stub routines, when no inline-calls are used. Or for the few support functions which are not in a shared library, like CreatePort(), DoMethod(), etc.
phx is offline  
Old 14 April 2020, 02:27   #12
ouya
Registered User

 
Join Date: Apr 2020
Location: Germany
Posts: 8
thanks phx

I downloaded NDK 1.3 and in the Include-Strip1.3/lib folder , there is only amiga.lib, ddebug.lib, debug.lib , diskfont_lib.lib , mathieesdoubbas_lib.lib , small.lib whereas in my vscode integration I have many many libs (most seem vbcc libs).

What are the essential vbcc libs needed to compile on 1.3 and on amigaos3+ ?
ouya is offline  
Old 15 April 2020, 00:22   #13
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,919
Although the linker libs from the NDK might work there is usually no reason to use them. vbcc comes with all libraries you need.
phx is offline  
Old 15 April 2020, 13:32   #14
ouya
Registered User

 
Join Date: Apr 2020
Location: Germany
Posts: 8
really?

http://sun.hasenbraten.de/vbcc/ has some minimal includes (maybe it has all libs)
most projects for amigaos 2/3 require many more include headers (folders exec, hardware , graphics etc....)

Any source for a complete vbcc include/lib setup ? for any platform (1.3, 3.0) . I am struggeling to get anything together. Its like copypasting tons of includes from NDKs.
ouya is offline  
Old 15 April 2020, 14:25   #15
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,919
Quote:
Originally Posted by ouya View Post
really?
Yes. Maybe debug.lib is the only one missing in the vbcc distribution.

Quote:
http://sun.hasenbraten.de/vbcc/ has some minimal includes (maybe it has all libs)
I only talked about linker libraries, as you did in the post before. Of course you need the header files from the official NDK!
I'm not sure about the current legal situation, but in the past it was not allowed for a compiler to include the NDK without license.

Quote:
Any source for a complete vbcc include/lib setup ? for any platform (1.3, 3.0) . I am struggeling to get anything together. Its like copypasting tons of includes from NDKs.
I'm surprised that this is a problem. You should want to download the NDKs anyway, for various development tools.
But there is nothing to copy. When using the installer under AmigaOS/MorphOS just point it to the directory with the NDK includes.
When you do it manually, just add the NDK include path to vincludeos3:, or add another -I option to the config file, for Unix/MacOS,Windows.
phx is offline  
Old 15 April 2020, 14:45   #16
ouya
Registered User

 
Join Date: Apr 2020
Location: Germany
Posts: 8
ok, sorry libs i have

includes from NDK3.9 also cover anything the amiga c program would ever need, but then again: my initial problem.

trying now with another sample project:
I can get main() running with a setup of AmigaOs(2,3) libs and NDK3.9 !

new error after startup:
"Sanity check on memory list failed"...somehow InitView fails

Last edited by ouya; 15 April 2020 at 14:59.
ouya is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
VLINK / VBCC / VASM linking order issue adrianpbrown Coders. C/C++ 6 14 January 2020 07:10
vbcc 0.9e signed multiplication issue? dalton Coders. C/C++ 3 09 January 2018 08:47
vbcc bss clearing issue dalton Coders. C/C++ 3 02 December 2017 22:50
vbcc 0.9f (windows) local includes issue? dalton Coders. C/C++ 4 29 July 2017 21:33
gcc linker mritter0 Coders. C/C++ 3 21 December 2014 16:54

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:49.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Page generated in 0.10558 seconds with 15 queries