|
ForumsSega Master System / Mark III / Game GearSG-1000 / SC-3000 / SF-7000 / OMV |
Home - Forums - Games - Scans - Maps - Cheats - Credits Music - Videos - Development - Hacks - Translations - Homebrew |
Author | Message |
---|---|
Chris
|
DJGPP Question
Posted: Tue Jul 13, 1999 5:48 am
|
Well, I finally broke down and downloaded DJGPP, inluding the Allegro set and the Rhide IDE.
Everything is set up, including my autoexec.bat, config.sys, and the directories are all set (I don't like the way it uses / instead of ). I did a simple program like this: #include void main() { printf("If this works...Well...Kick Ass!"); } In Borland C++ it compiled without any problems. In DJGPP it said that main dosen't specify the return or exit statement. It still compiled though. So I have test.c, the compiled test.o but it won't write the exe file. What's the deal? Why won't it link and write the exe? Chris :o) |
|
|
Posted: Tue Jul 13, 1999 7:31 am |
It should be something like: int main (int param_n, char **param_c) { .. }
The file is A.EXE by default on the DOS port (it is originally A.OUT). Use the -o command line option to specificy another output filename. |
|
Chris
|
Posted: Tue Jul 13, 1999 5:05 pm |
I did everything you said and it worked like a charm :o)
Now, why is the program so fuckin huge? I know it dosen't take 103k to make dos print a message. Hell, under Borland C++ w/ small memory model you could achieve the same thing with only 34k! Ohh, wait a minute. Memory... What's the command line parameters to make the memory Tiny, Small, Medium, Large, and Huge? Also, with allegro. When I extracted it all it's contents were placed in it's own folder called allegro. Do I have to copy everything in that directory to the main DJGPP one? Chris :o) |
|
Nyef
|
Posted: Tue Jul 13, 1999 8:48 pm |
Because there is a lot of overhead involved in DJGPP.
There aren't any. DJGPP always uses 32-bit flat model (sort of like tiny model, but with more memory).
Why don't you read the Allegro docs? They should explain everything.
--Nyef |
|
Limbs a Flyin'
|
Posted: Wed Jul 14, 1999 6:48 am |
ripped from an official djgpp faq (i dont know if its the latest): 8.13 Why are DJGPP `.exe' files so large? ========================================= **Q*: I compiled a trivial "Hello world" program and got a 80KB executable file. That's ridiculously bloated!* **Q*: I switched to GCC 2.8.1, and my C++ executables are considerably larger than when compiled with GCC 2.7.2.1!* *A*: Did you link with `-s' switch to `gcc', or run `strip' on the output of the linker? If not, the executable includes the debugging symbols, which makes it quite a lot larger. (It is not recommended to strip the symbols except when distributing production programs, because this makes debugging very hard indeed; that is why `-s' is not passed to gcc by default.) C++ programs could be further bloated because the release of Binutils 2.8.1 was configured in a way that caused the assembler to put into the symbol table local labels generated when compiling code that uses exceptions. Later uploads of GNU Binutils should solve this problem, so consider upgrading to the latest `bnuNNNb.zip'. Judging code sizes by looking at the size of "Hello" programs is meaningless, since most of the power of protected-mode programming goes wasted in such programs. There is no point in switching the processor to protected mode (which requires a lot of code) just to print a 15-byte string and exit. The overhead induced by the code needed to set up the protected-mode environment is additive; the larger the program, the smaller the overhead relative to the program size. Apart from getting to protected-mode, the DJGPP startup code also includes such functionality as wildcard expansion, long command-line support, and loading the environment from a disk file; these usually aren't available with other DOS protected-mode compilers. Exception and signal handling (not available at all in v1.x), FPU detection and emulator loading (which were part of `go32' in v1.x), are now also part of the startup code. If your program doesn't need parts of the startup code, it can be made smaller by defining certain functions with empty bodies. These functions are `__crt0_glob_function', `__crt0_load_environment_file', and `__crt0_setup_arguments.' By defining empty substitutes for all three of these, you can make the "Hello" program be 28KB on disk. These functions are documented in the DJGPP libc reference, which see. Here's an example of definitions for these functions that will make the startup code as small as it gets(1): char **__crt0_glob_function (char *arg) { return 0; } void __crt0_load_environment_file (char *progname) { } void __crt0_setup_arguments (void) { } Note that if you define an empty substitute for `__crt0_setup_arguments', your program will not be able to access its command-line arguments via the `argv[]' array. So this is only recommended for programs which don't accept any arguments at all. You can make your program image still smaller by compressing it with a compressor called DJP (ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2misc/mlp107b.zip). DJP is a DJGPP-specific executable file compressor. It is fast and has no memory overhead. It also knows about DJGPP "Dynamically Loaded Modules" (DLM) technology. (Note that DJP before version 1.06 was incompatible with Binutils 2.8.1 and later(2), so you should always use the latest DJP version available on SimTel.NET mirrors.) ---------- Footnotes ---------- (1) If you define an empty substitute for `__crt0_setup_arguments', you don't need to define a substitute for `__crt0_glob_function'. (2) In particular, running `strip' on a program and then compressing it with DJP would produce a program that crashes upon startup. im sure lots of usful info can be had at the offcial djgpp site; http://www.delorie.com/djgpp/ including the faq section. check out that zip picker if you dont know what to get (if you havent been there already) |
|
Chris
|
Ohh, I see now! Thanks!
Posted: Wed Jul 14, 1999 7:46 am
|
Thanks. I guess I'll not worry about the file size and concentrate on the good stuff. I don't
want to bite off more than I can chew. Oh, and I did use the zip file picker so I should have the FAQ somewhere in the DJGPP directory. Chris :o) |
|
|
Posted: Wed Jul 14, 1999 9:51 am |
It is so big because a part of the LibC is included in the executable, as no library are shared in DOS. Under Linux, the same executable would take about 5 kb. In the FAQ there is the same question and I suggest reading the answer.
There are no memory models.
Read the documentation. |
|