BCC->ASM->OBJ->EXE ?? 
Author Message
 BCC->ASM->OBJ->EXE ??



Quote:
>I have a C script that I compiled with BCC (v5.1) into an ASM file. I can TASM
>that file to an OBJ file, but TLINK gives me an error. Do I have to take
>special care about something? If there is no "general" solution, I can give an
>url with a demonstration script.

Without the actual error message, we're just "shooting in the dark".

If your C program has a main() function, you will need to link in the
"startup module".  Don't know what BCC uses, I'm guessing it's something
like crt0.obj.

Henry S. Takeuchi

Seattle, Washington (USA)



Sat, 21 Oct 2000 03:00:00 GMT  
 BCC->ASM->OBJ->EXE ??


muenchen.de scribbled :

Quote:
>I have a C script that I compiled with BCC (v5.1) into an ASM file. I can TASM
>that file to an OBJ file, but TLINK gives me an error. Do I have to take
>special care about something? If there is no "general" solution, I can give an
>url with a demonstration script.

BCC -S (or is it -A) files should assemble in TASM with no problems. You
can ASSEMBLE it OK, because there is nothing wrong with the source, but
when you LINK it, you need to also link in the runtime library for your
model, because your program will be calling 'printf()' or other similar
library calls, which aren't defined in ASM. You can either TLINK with
the relevant libraries (the RTL and startup code), but this may cause
pain in that you have to get hold of the right libraries. Try this
instead:

bcc -A file.c   (could be -S, haven't used BCC for ages)
edit file.asm   (and make your changes)
tasm file.asm   (add any options you might need like /m9)

bcc file.obj -o file.exe   (should work, if not then try this)
bcc file.obj -ofile.exe    (a la DJGPP)

This works in DJGPP for COFF object files produced by GASsing files
produced with the -S option. BCC should get the message that file.obj
just needs to be linked, and it should then fire TLINK up with the
relevant libraries. To be sure it links the OBJ and not rebuilds the .C
file, rename the .C file to .CCC or similar.

--
UNIX - Saving you from the Gates of Hell.



Sat, 21 Oct 2000 03:00:00 GMT  
 BCC->ASM->OBJ->EXE ??


muenchen.de scribbled :

Quote:
>your help let me do the trick. Thank you very much!

Heh.. cool.. if only Access97 queries were as simple :)

So did you link it with TLINK and specifying the libraries by hand, or
with <BCC file.obj> ?

If you did it with TLINK, what libraries did you use, and what model was
your code compiled for?

BTW: the main reason for assembling to source and then recompiling is to
do protection - you can write cool protection in ASM, using one-way
math, anti-debugging etc., which you can't do in plain C(++). Remember
to either PUSHAD (if you're on a 386, otherwise PUSH AX etc) before any
additional code and POPAD when your code is done, or you will clobber
registers, leading to a crash.
--
UNIX - Saving you from the Gates of Hell.



Mon, 23 Oct 2000 03:00:00 GMT  
 BCC->ASM->OBJ->EXE ??



Quote:
>Without the actual error message, we're just "shooting in the dark".

Not really. If BCC generates the code, it's perfect. At least for TASM,
which is a Borland tool. Anyway, it assembles OK. It's not a fixup
problem, because we assume the code is perfect. Most TLINK errors of
this sort are unresolved externals, so we assume this is the case (which
it is, because the author of the original post tried my solution and it
worked).

Quote:
>If your C program has a main() function, you will need to link in the
>"startup module".  Don't know what BCC uses, I'm guessing it's something
>like crt0.obj.

That only solves part of the problem. The startup code for BCC doesn't
do much; you also need to link the Borland C RTL into the program,
because the source is sure to call other functions.

BTW: the startup code for BCC comes in library form, and has about six
delicious flavours, one for each memory model (tiny, small, compact,
medium, large, huge). It's not as simple as DJGPP :(
--
UNIX - Saving you from the Gates of Hell.



Mon, 23 Oct 2000 03:00:00 GMT  
 BCC->ASM->OBJ->EXE ??


scribbled :

Quote:
>You should've told us what error it is.
>Try using /3 switch if your code is 32-bit

Still makes no difference. I write 386 protection, and don't use /3 - no
problems. He was trying to assemble BCC generated code, which would be
in real mode; well, you can do protected, but it's very uncommon.

His problem was that he had defined externals which he did not resolve
at link-time. So it ASSEMBLED perfectly into an OBJ, but did not LINK to
an EXE, because TLINK couldn't find the C functions, which were in a
library he had not linked. Solution: link with the library.

See my other answer for more information.
--
UNIX - Saving you from the Gates of Hell.



Mon, 23 Oct 2000 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. HELP>>>>>>>Fortran-Pascal Linking

2. >>>>>>>FROM SMTK TO C++

3. ><><><><>Heeeeeeeeeeeeeeelp on INT 14!><><><><><>

4. <<<<<YOU MUST CHECK THIS OUT >>>>>>>>>> 2103

5. >>>>>AVL tree

6. >>>>>How to read a IMAGE file?(BMP, GIF)|||||||||

7. ANNOUNCE>>>>>TOTAL FrameWork from Cincom

8. .cob files >>> .exe files

9. Slow/No Speed>>>>>>>>>

10. >>>>VHDL tutorial text: Summary >>>>

11. Graphics>>Rectangle>>intersects: erroneous code

12. **>>CO Smalltalk Developer!!>>**

 

 
Powered by phpBB® Forum Software