Ok folks, I'm aware that there are probably not many users around here that are targeting the msdos-8086 platform. But it's the only place to ask this question, so I'll give it a try.
My problem in short: I have a QBasic program where I need to include some objects created with FPC 3.2. Basically, this works fine. I have the following files:
- main.obj: This is the output of Microsoft BC, so it's an object created from the QBasic app
- system.lib: This is fpc\3.2.0\units\msdos\8086-compact\rtl\system.a converted to a static library with Microsoft Library Manager (LIB) 3.40
- math.lib: Same for math.a
- bcl71efr.lib: Static library from QBasic
- my.lib: This is the static library create from my FPC unit which I want to link to (same conversion with LIB from my.a to my.lib)
To link all together, I use Microsoft Linker 5.0 (all Microsoft tools are used in their DOS versions):
LINK main.obj,main.exe,,my.lib+bcl71efr.lib+math.lib+system.lib,nul.def
As I said, basically it works fine and I can call the procedures and functions contained in my.pas without any restriction or problem.
It gets complicated when I try to use some particular functions in my unit. One example is Randomize (which internally calls DOS-interrupt 21h) leading to this linker error:
SYSTEM.LIB(system0s1236.o) : error L2029: 'FPC_MSDOS' : unresolved external
Obviously, FPC_MSDOS is implemented in assembler as prt0c.asm and there is a compiled object named prt0c.o (I use "compact" memory model and assume the "c" version is the correct one). So I include prt0c.o as well:
LINK main.obj+prt0c.o,main.exe,,my.lib+bcl71efr.lib+math.lib+system.lib,nul.def
And this is the point where I'm stuck. This step leads to the following missing externals:
Microsoft (R) Segmented-Executable Linker Version 5.10
Copyright (C) Microsoft Corp 1984-1990. All rights reserved.
Temporary file .\lna02064 has been created.
prt0c.o(prt0c.asm) : error L2029: 'PASCALMAIN' : unresolved external
prt0c.o(prt0c.asm) : error L2029: '___heap' : unresolved external
prt0c.o(prt0c.asm) : error L2029: '___stack' : unresolved external
system.lib(system0s896.o) : error L2029: 'INITFINAL' : unresolved external
So first question is: in which object can I find "___heap" and "___stack"?
And second, as far as I understand, system.a seems to do calls to "pascalmain" and "initfinal" which seem to be sections of an FPC main program. However, I don't have (and don't want) one, as I only need a single unit.
Is there any possibility to resolve these externals?
I hope I have explained my situation well enough to understand what I want to do.
Thanks for any help!