Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2002-02

FPC & c-library

7 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Peter Beisel

Hi all,
I am trying to link to a C-library generated by Watcom C-compiler. The library has 32bit format; target system: DOS (Dos4GW)

FP compiler: ver.1.0.4; target system: DOS (cwsDpmi)

The compiler runs well, but the linker generates no EXE-file ! What could be wrong?

1. Is it possible to link to 32bit librarys generated by Watcom?
2. Which file do I have to link to: *.lib or *.obj?
3. Any recomended switches for FPC?
4. Are Dos4GW and CwsDpmi compatible?

greetings
Peter

Alan Grimes
to Peter Beisel
Show quoted text 7 lines
FP compiler: ver.1.0.4; target system: DOS (cwsDpmi) The compiler runs well, but the linker generates no EXE-file ! What could be wrong? 1. Is it possible to link to 32bit librarys generated by Watcom? 2. Which file do I have to link to: *.lib or *.obj? 3. Any recomended switches for FPC? 4. Are Dos4GW and CwsDpmi compatible?

Linkers are evil.

There is a utility called "PMODE/W" a DOS4GW replacement... Its utility, PMWBIND, can strip the 180k DOS4GW header off of any file. I use it to reduce the redundant information on my drive... What is left is a .LE file, or Linear Executable. These LE files require a DOS extender that provides some other services too...

The basic function of a DOS extender such as DOS4GW is to create a virtual 32bit OS for DOS programs. AS there are no rules about DOS extenders, DOS can support any type of 32-bit environment immaginable. =)

Go look at the output of your linking process, if there is a .LE file there, attempt to run it with dos4gw...

Example:
---------------

DOS4GW DOOM2.LE

---------------

There is probably a linker command or something similar to add the stub...

OTOH, if the Pascal object is not fully recognised by the linker, it might assume that you are creating a DLL or something...

People who think that destructive brain uploading is an acceptable and positive choice should be committed to the mental hospital for suicidal tendancies. http://users.rcn.com/alangrimes/ <my website.
Peter Beisel
to Alan Grimes

thank you,

but I couldn't find PMODE/W or PMWBIND anywhere.

1. DOS4GW & EXE (by WatCom) <----> CWSDPMI & EXE (by FPC)

Without such a tool it seems impossible to run a DOS4GW executable generated by a WatCom Compiler under CWSDPMI.

On the other hand an EXE-file generated by FPC can't be executed under DOS4GW. DOS4GW doesn't recognise the EXE, because of the CWSDPMI-Header added by the stub under FPC. Now I tried to remove this header. The FPC docs explain the usage of the tool EXE2COFF. But this tool is nowhere. I found EXE2COFF in the DJGPP tools and I tried this: EXE2COFF myFPprog.EXE (myFPProg.EXE = generated by FPC) Result:
myFPprog; Permission denied (EACCES)

Are there different EXE2COFFs?

2.
I found no way to link a WatCom generated *.LIB or *.OBJ to a FPC programm. The FP linker doesn't accept them.

Regards, Peter

Show quoted text 43 lines
> FP compiler: ver.1.0.4; target system: DOS (cwsDpmi) > The compiler runs well, but the linker generates no EXE-file ! > What could be wrong? > 1. Is it possible to link to 32bit librarys generated by Watcom? > 2. Which file do I have to link to: *.lib or *.obj? > 3. Any recomended switches for FPC? > 4. Are Dos4GW and CwsDpmi compatible? Linkers are evil. There is a utility called "PMODE/W" a DOS4GW replacement... Its utility, PMWBIND, can strip the 180k DOS4GW header off of any file. I use it to reduce the redundant information on my drive... What is left is a .LE file, or Linear Executable. These LE files require a DOS extender that provides some other services too... The basic function of a DOS extender such as DOS4GW is to create a virtual 32bit OS for DOS programs. AS there are no rules about DOS extenders, DOS can support any type of 32-bit environment immaginable. =) Go look at the output of your linking process, if there is a .LE file there, attempt to run it with dos4gw... Example: --------------- > DOS4GW DOOM2.LE --------------- There is probably a linker command or something similar to add the stub... OTOH, if the Pascal object is not fully recognised by the linker, it might assume that you are creating a DLL or something... -- People who think that destructive brain uploading is an acceptable and positive choice should be committed to the mental hospital for suicidal tendancies. http://users.rcn.com/alangrimes/ <my website. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Marco van de Voort
to Peter Beisel
Show quoted text 6 lines
Are there different EXE2COFFs? 2. I found no way to link a WatCom generated *.LIB or *.OBJ to a FPC programm. The FP linker doesn't accept them.

I don't know if this is probably it is easier to search for a way to link those Watcom formats to DJGPP. If you find a procedure for that, it could probably get easily adapted for FPC

Alan Grimes
to Peter Beisel: but I couldn't find PMODE/W or PMWBIND anywhere. 1. DOS4GW & EXE (by WatCom) <---->…
Peter Beisel wrote 8 lines
but I couldn't find PMODE/W or PMWBIND anywhere. 1. DOS4GW & EXE (by WatCom) <----> CWSDPMI & EXE (by FPC) Without such a tool it seems impossible to run a DOS4GW executable generated by a WatCom Compiler under CWSDPMI. On the other hand an EXE-file generated by FPC can't be executed under DOS4GW. DOS4GW doesn't recognise the EXE, because of the CWSDPMI-Header added by the stub under FPC.

CWSDPMI is merely a generic DPMI server, a DOS extender... I use QDPMI that comes with QEMM97.

There is no CWSDPMI header, rather there is a "Go32v2" header... This stub checks for the presence of any DPMI and installs CWSDPMI if necessary.

Now I tried to remove this header.

You shouldn't have to remove any header...
The compiler should leave the raw object in the source/build directory...

XYZ.PAS
should become something like:
XYZ.o
and then be linked into:
XYZ.EXE

Its the .o file you need...

2. I found no way to link a WatCom generated *.LIB or *.OBJ to a FPC programm. The FP linker doesn't accept them.

Linkers suck. =(
I hate them.

See what you can do with the watcom linker, or get a linker over the net and h4x0r it... You'll be doing the world a great service if you do it right! =)

People who think that destructive brain uploading is an acceptable and positive choice should be committed to the mental hospital for suicidal tendancies. http://users.rcn.com/alangrimes/ <my website.
Alan Grimes
to Alan Grimes
Alan Grimes wrote 11 lines
> Now I tried to remove this header. You shouldn't have to remove any header... The compiler should leave the raw object in the source/build directory... XYZ.PAS should become something like: XYZ.o and then be linked into: XYZ.EXE Its the .o file you need...

I should add that the PPC386.exe compiler can output several formats (pasted from the on-line help)...

----------------------------------------
-A<x> output format:
-Aas assemble using GNU AS
-Aasaout assemble using GNU AS for aout (Go32v1) -Anasmcoff coff (Go32v2) file using Nasm
-Anasmelf elf32 (Linux) file using Nasm
-Anasmobj obj file using Nasm
-Amasm obj file using Masm (Microsoft)
-Atasm obj file using Tasm (Borland)
-Acoff coff (Go32v2) using internal writer
-Apecoff pecoff (Win32) using internal writer
----------------------------------------

The watcom compiler will probably have similar options.... From there it shouldn't be impossible to find one that works. =)

People who think that destructive brain uploading is an acceptable and positive choice should be committed to the mental hospital for suicidal tendancies. http://users.rcn.com/alangrimes/ <my website.
Peter Beisel
to Alan Grimes

Thank you very much,
I will try this.
Regards, Peter

Show quoted text 41 lines
Alan Grimes wrote: > > Now I tried to remove this header. > You shouldn't have to remove any header... > The compiler should leave the raw object in the source/build > directory... > XYZ.PAS > should become something like: > XYZ.o > and then be linked into: > XYZ.EXE > > Its the .o file you need... I should add that the PPC386.exe compiler can output several formats (pasted from the on-line help)... ---------------------------------------- -A<x> output format: -Aas assemble using GNU AS -Aasaout assemble using GNU AS for aout (Go32v1) -Anasmcoff coff (Go32v2) file using Nasm -Anasmelf elf32 (Linux) file using Nasm -Anasmobj obj file using Nasm -Amasm obj file using Masm (Microsoft) -Atasm obj file using Tasm (Borland) -Acoff coff (Go32v2) using internal writer -Apecoff pecoff (Win32) using internal writer ---------------------------------------- The watcom compiler will probably have similar options.... >From there it shouldn't be impossible to find one that works. =) -- People who think that destructive brain uploading is an acceptable and positive choice should be committed to the mental hospital for suicidal tendancies. http://users.rcn.com/alangrimes/ <my website. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal