OS/2, eCS & ArcaOS - Technical > Programming
Compiling a PM sample with GCC
Martin Iturbide:
Hi
I'm trying to compile a little PM sample, just for the fun of it.
It is: PMWalker_r2.zip
The make file uses gcc, link386 and rc.
I run nmake and it shows me this error:
--- Quote ---{2}[e:\projects\samplepack\pmwalker_r2] nmake
Operating System/2 Program Maintenance Utility
Version 4.00.001 Oct 4 2001
Copyright (C) IBM Corporation 1988-2001
Copyright (C) Microsoft Corp. 1988-1991
All rights reserved.
gcc -c -O2 walker.c
walker.c:30:10: fatal error: os2.h: No such file or directory
30 | #include <os2.h>
| ^~~~~~~
compilation terminated.
NMAKE : fatal error U1077: 'C:\SYS\APPS\4OS2\4OS2.EXE' : return code '1'
Stop.
--- End quote ---
I have OS2.h on "C:\usr\include\os2tk45" and on the config.sys "SET INCLUDE=C:\usr\include\os2tk45"
Any idea why I have that error? Do I have to use other OS2.h ?
Regards
Lars:
gcc.exe does not know about INCLUDE env var. Try C_INCLUDE_PATH instead.
If that does not work , add -Ic:/usr/include/os2tk45 to the compiler commandline in the makefile.
Dave Yeo:
Actually, GCC wants the os2.h in @unixroot\usr\include and should find it on its own without C_INCLUDE_PATH or -I, if you want to use the one in the toolkit, you need to define USE_OS2_TOOLKIT_HEADERS 1 or edit os2.h around line 39. Should use the define though.
Likewise, if you need Toolkit header like dive.h, the toolkit headers need to be at the end of the C include search path, C_INCLUDE_PATH=/@unixroot/usr/include;c:/usr/include/os2tk45 or use -Idirafter=c:/usr/include/os2tk45.
Anyways, PMwalker seems to be designed for EMX, after editing the makefile to compile with kLIBC, I get,
--- Code: --- gcc -Zomf walker.obj walker.def
weakld: error: Unresolved symbol (UNDEF) '_ClientWndProc'.
weakld: info: The symbol is referenced by:
H:/tmp/PMwalker/walker.def
Ignoring unresolved externals reported from weak prelinker.
Warning! W1058: file ldZXONto.: line(20): protmode option not valid for an OS/2
EMX executable
Error! E2028: _ClientWndProc is an undefined reference
Error! E2044: exported symbol _ClientWndProc not found
NMAKE : fatal error U1077: 'W:\OS2\CMD.EXE' : return code '1'
Stop.
--- End code ---
with this makefile,
--- Code: ---walker : walker.exe
walker.exe : walker.obj walker.res walker.def
gcc -Zomf walker.obj walker.def
rc walker.res
walker.obj : walker.c walker.h
gcc -Zomf -los2 -c -O2 walker.c -o walker.obj
walker.res : walker.rc step1.ico step2.ico step3.ico
rc -r walker.rc
--- End code ---
Need to read the documentation, probably a define missing.
Hmm, the def file is broken, need to remove the underline prefix so it reads EXPORTS ClientWndProc rather then EXPORTS _ClientWndProc
Edit:, read the readme.txt, it was actually written for a different GCC port, GCC/2, not EMX.
Dave Yeo:
Better makefile,
--- Code: ---walker : walker.exe
walker.exe : walker.obj walker.res walker.def
gcc -Zomf walker.obj walker.def -o walker.exe
rc walker.res
walker.obj : walker.c walker.h
gcc -Zomf -c -O2 walker.c -o walker.obj
walker.res : walker.rc step1.ico step2.ico step3.ico
rc -r walker.rc
--- End code ---
along with the def change compiles and runs fine here, if it isn't finding os2.h in your setup, something is broken.
Dave Yeo:
Here's the updated package if you want to upload to Hobbes. Added a clean target to the makefile, nmake clean.
Navigation
[0] Message Index
[#] Next page
Go to full version