| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | EMX\GNU C |
Hallo, Mick!
*** Am Donnerstag 11. Juli 1996 um 23:21 schrieb Mick Howe an Thomas Seeling:
MH> Where in Zone 3 can I get ahold of this FAQ and redir, I've been bitching
=== Cut ===
===============================================================================
faq.doc emx 0.9b Frequently asked questions 25-Feb-1996
===============================================================================
Copyright (c) 1995-1996 by Eberhard Mattes
(This file is under construction.)
1: Compiling and linking with the -Zomf option fails; LINK386
complains about not finding libraries c_alias.lib, gcc.lib,
c.lib, etc.:
LINK386 : warning L4051: c_alias.lib : cannot find library
Compiling and linking without the -Zomf option works.
You forgot to run `omflibs' in the \emx\lib directory after
unpacking the ZIP files.
2: Where can I find information about the functions in os2emx.h?
TODO (Toolkit, DEVCON, books, EDM/2)
3: My program crashes in _malloc2(), _realloc2(), or _expand2().
Your program corrupts the heap by overwriting control structures of
the heap. For instance, this happens if you write beyond the end of
a block allocated by malloc(). There are several methods for
debugging heap problems:
- Recompile the program using the following GCC options:
-fbounds-checking -fno-builtin
Note that -fbounds-checking imposes several restrictions on the
program; see the GCC manual, \emx\gnu\doc\bounds\bcreport.txt and
\emx\doc\emxgnu.doc for details.
- Recompile the program using a debugging malloc() package, such as
dbmalloc:
ftp.uni-stuttgart.de:/pub/systems/os2/emx-0.9b/contrib/dbmalloc.zip
dbmalloc replaces malloc() and friends and memcpy() and friends to
catch attempts to corrupt the heap.
- Insert _heapchk() calls to see where the heap becomes corrupt:
assert (_heapchk () == _HEAPOK);
Note that _heapchk() returns _HEAPEMPTY if malloc() has not yet
been called. Therefore you should insert a dummy malloc() call
before the first _heapchk() call or don't call _heapchk() before
calling malloc().
_heapchk() works with the emx implementation of malloc() only.
Other malloc packages may support a similar function.
- Instead of insert _heapchk() calls into the code, you can call
_heapchk() from GDB. Just insert one call to _heapchk() to pull
in _heapchk(). To call _heapchk() from GDB, type
call _heapchk()
To check the heap each time the program stops, type
display _heapchk()
_heapchk() works with the emx implementation of malloc() only.
Other malloc packages may include a similar function.
4: Has GNU readline been ported to emx?
Yes, for GDB. Just unpack the GDB sources (gdbsrc?.zip) and see
\emx\doc\build.doc for instructions for building GDB (which includes
building GNU readline).
5: Why does OS/2's VIEW command say
Cannot open input files
if I try to view an .inf file of the \emx\info directory?
There are two sorts of .inf files: OS/2 on-line books (to be viewed
with VIEW), and GNU info files (to be viewed with `info'). Type
info -f gdb
instead of
view gdb
to view gdb.inf.
6: Why does the `info' program say
info: Cannot find the node "Top".
if I try to view an .inf file of the \emx\book directory?
There are two sorts of .inf files: OS/2 on-line books (to be viewed
with VIEW), and GNU info files (to be viewed with `info'). Type
view emxdev
instead of
info -f emxdev
to view emxdev.inf. You can't view OS/2 on-line books under DOS
(TODO: add a pointer to the program for viewing a .inf file in text
mode, available on ftp-os2.cdrom.com.)
7: How can I redirect the error messages of GCC? `>errors' does not
work.
GCC, like most Unix programs, prints its error messages on standard
error, not on standard output. Under OS/2, you can redirect
standard error by using `2>' instead of `>':
gcc myprog.c 2>errors
To pipe standard error (along with standard output) into another
program, use `2>&1 |' instead of `|':
gcc myprog.c 2>&1 | more
Unfortunately COMMAND.COM cannot redirect standard error, therefore
the above operators don't work under DOS. However, you can use the
`redir' sample program of emx:
redir "2>errors" "gcc myprog.c"
Type the following commands to build redir.exe:
cd \emx\samples
gcc redir.exe
You might want to copy redir.exe to \emx\bin.
8: Where can I find a `make' tool for emx?
TODO (dmake 3.8, dmake 4.0, GNU make, ...)
9: Linking C++ programs does not work, there are a lot of undefined
symbols like `ostream::operator<<' and `_cout'. What do I miss?
See emxgnu.doc. You have to use the -lstdcpp option of GCC to link
with the standard C++ library (stdcpp.a or stdcpp.lib) which
contains code for etc. The -l option must (usually) be
used after all the object files and source files:
gcc myprog.cpp -lstdcpp
(Any object files, source files, and libraries given after an -l
option cannot reference symbols from the library specified by that
-l option.)
10: How can I open binary files in C++?
Use the ios::bin flag.
11: The header does not work, I get error messages like
c:/emx/include/sys/stat.h:14: parse error before `dev_t'
if I compile a program that uses . How can I avoid this?
You have to #include before , as required
by POSIX.1
12: Where is LINK386?
It's in the \OS2 directory. If it isn't, run `Selective Install' of
the `System Setup' folder, click on the OK button, click on
`Optional System Utilities' and its `More...' button, then select
`Linking Object Modules', and continue the installation.
13: How do I create TCP/IP programs?
TODO (headers, man pages, -lsocket, emxdev.doc)
14: How do I create X11 clients?
TODO (header files, patching header files, libraries, problems)
15: What class libraries are available for emx?
TODO (C++: libg++, STL, dho, LEDA, Touch-GUI, OCL, os2cl)
(Objective C: KPlib, libobjects, classlib)
16: Curses does not work correctly TODO: symptoms
TODO (PDCurses, ncurses)
17: What's the difference between _beginthread() and DosCreateThread?
_beginthread() creates a new thread and initializes the C runtime
environment for the new thread. DosCreateThread just creates a new
thread. Therefore, threads created by DosCreateThread cannot use
certain library functions such as malloc(), printf(), rand(), and
strtok().
18: How can I read keys without echo and without waiting for the
RETURN key?
TODO (termio, termios, _read_kbd, KbdCharIn, INT 0x16, getpass(),
_getpass1(), _getpass2())
19: RC cannot find include files, it prints
fatal error C1015: cannot open include file 'os2.h'
How can I fix this?
Use the -I option or set the INCLUDE environment variable. At least
one of them should point to the \emx\include directory. Examples:
rc -r -I c:\emx\include myprog.rc
set include=c:\emx\include
rc -r myprog.rc
If you have installed the Developer's Toolkit, INCLUDE is probably
already set up correctly, pointing to the Toolkit's include file
directory.
20: I wrote a correct PM program, but its windows are invisible.
What's wrong?
You forgot to mark the .EXE file as PM application. This is usually
done by using
NAME myprog WINDOWAPI
in the module definition file (myprog.def). To link with a module
definition file, just give its name to GCC:
gcc myprog.c myprog.res myprog.def
You can also use emxbind's -ep option, though a module definition
file is usually preferred.
21: Why do programs started by an emx program with spawn*() or
system() run out of memory under DOS?
You forgot to use the emx option -p for the emx program. Type
emxbind -a myprog.exe -p
to set the -p option.
22: I get the error message
Undefined symbol __beginthread referenced from text segment
or
error L2029: '_beginthread' : unresolved external
when linking my program. Where is _beginthread()?
_beginthread() is in the multithread libraries. Therefore you have
to use the -Zmt option.
23: I get error messages like
Undefined symbol _v_init referenced from text segment
or
error L2029: 'v_init' : unresolved external
when linking my program. Where are all those functions whose name
start with `v_' or `wm_'?
These functions are in the video.a and video.lib libraries.
Therefore you have to use the -lvideo option for linking.
24: rand() is not random enough: Why does it yield the same sequence
of `random' numbers each time I run my program?
This behavior is required by ISO 9899-1990. It makes the behavior
of your program recreatable. If you don't like this, call srand()
with a really random number (derived from the system time, for
instance).
The emx implementation of rand() is thread-safe, each thread has its
own pseudo random number generator. If you want different sequences
in different threads, use different arguments for srand() in
different threads.
25: rand() is not random enough, where can I get a better pseudo
random number generator?
Use random() which is provided in the bsd.a and bsd.lib libraries
(use -lbsd).
26: spawn*(P_SESSION, ...) fails with errno set to EINVAL, _syserrno()
returns 460. What's going on?
emx.dll uses a termination queue when it starts a session to be able
to signal SIGCHLD on termination of the session and to be able to
retrieve the return code of that session for wait().
There can be multiple queues per session, even in different
processes. However, no two or more of these queues can be attached
to a child session at a time. That is, while a process P1 has a
child session S1, only process P1 can start another session S2. In
other words, all child sessions of a session must be attached to the
same queue.
There are two ways to solve the problem:
1. Have only one queue. That is, all sessions are to be started by
the same process; don't start sessions from fork()ed processes.
2. Don't have a queue. If the P_UNRELATED flag is passed to
spawn*(), emx.dll won't use a termination queue. However,
SIGCHLD and wait() won't work.
27: Why does emxomf print `emxomf warning: Cycle detected by make_type'?
emxomf does not completely understand the debug info of the module.
Ignore this warning message, it's benign.
28: Why are .exe files so big if I use C++?
C++ debug info is quite big; use the -s option of GCC to avoid
putting debug info into the executable.
29: My application does not work if linked with LINK386 (-Zomf option
of GCC). It does work if linked with ld/emxbind. Why?
There are several possible reasons for this effect:
1. Some versions of LINK386 have a bug which causes uninitialized
variables to be initialized with *non-zero* values (ISO 9899-1990
requires all bits of uninitialized variables being initially
zero). `LINK386 3.00.000 Jul 05 1995' (of FixPak XR_W009) and
later are OK (note the date, there's at least one 3.00.000
version which does not work.)
2. The default stack size with -Zomf is only 32768 bytes. This is
usually not enough. Use, for instance, -Zstack 0x2000 (8 MBytes
of stack space) on the GCC command line
3. Using SEGMENTS in the module definition file causes a problem
with constructors and destructors (which are also used by the
startup code of the C library) unless *all* code segments are
listed
4. All versions of LINK386 (and ILINK) have a bug which under
certain circumstances causes the entire data object to be
initialized to zero. This seems to happen only if the size of
the code object is n*0x1000+4. To work around the problem, just
add some dummy code
30: Why doesn't va_arg work?
There are some restrictions on the type of the second argument of
the va_start macro and on the type passed as second argument to the
va_arg macro. For instance, `char', `short', and `float' don't
work. See emxlib.doc for details.
31: The linker complains about `malloc' being multiply defined. What's
wrong?
You are using a malloc() replacement and _tmalloc() is called by the
program. You have to specify the -ltmalloc option.
32: How can I make ILINK.EXE to be invoked instead of LINK386.EXE?
SET EMXOMFLD_LINKER=C:\IBMCPP\BIN\ILINK.EXE -NOFREE
33: Where can I find IPMD?
IPMD (aka ICSDEBUG), IBM's debugger for OS/2, is shipped as part of
IBM's Visual Age C++. It's not available for free.
34: Where can I find the crypt() function?
ftp.leo.org:/pub/comp/os/os2/crypt/gnuufc.zip
------------------------------ END OF FAQ.DOC -------------------------------
=== Cut ===
Tschau...Thomas
--- E3-32/1.11-32/2.50+
* Origin: Die TeX-Box +49-6034-930021 V.34 -930022 ISDN 24h (2:244/1130.42)SEEN-BY: 50/99 270/101 620/243 625/100 711/401 409 410 413 430 808 809 934 SEEN-BY: 711/955 712/407 515 624 628 713/888 800/1 @PATH: 244/1130 24/999 888 396/1 270/101 712/515 711/808 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.