Defining SYSLIB when using z/OS USS to compile/link - mainframe

I'm using c++ (cxx) on z/OS USS to compile and link c programs.
I'm getting errors from IEW (linker) that it can't access SYSLIB.
I'm assuming that this has to be an export e.g.
export _CXX_LSYSLIB="CEE.SCEELKEDX:CEE.SCEELKED:CBC.SCCNOBJ:SYS1.CSSLIB"
That was my best shot but still getting errors during linking.
ABEND S013-38 OCCURRED WHILE PROCESSING PARTITIONED DATA SET DDNAME SYSLIB.

There is an easy way to get the right setting of environment variables needed to properly link an application in USS on z/OS. The following command illustrates how this works:
> xlC -v a.C
FSUM0000I Utility(xlc) Level(D170323.1712)
exec: export(export,XL_CONFIG=/bin/../usr/lpp/cbclib/xlc/etc/xlc.cfg:xlC,NULL)
exec: /usr/lpp/cbclib/xlc/exe/ccndrvr(/usr/lpp/cbclib/xlc/exe/ccndrvr,./,./a.C,*.C,CXX,CMDOPTS(DEFINE(errno=(*__errno())),NOTEST,-qoe,-qargparse,-qexecops,-qflag=i,-qhalt=16,-qnodebug,-qnolsearch,-qredir,-qlocale=POSIX,-qlongname,-qmaxmem=*,-qmemory,-qnestinc=255,-qnoexpmac,-qnoexportall,-qnogonumber,-qtarget=le,-qnolibansi,-qlist=/dev/fd1,-qnolist,-qnomargins,-qnooffset,-qnosequence,-qnoshowinc,-qsource=/dev/fd1,-qnosource,-qnoxref,-qterminal,-qnooptimize,-qplist=host,-qspill=128,-qstart,-qnoipa,DEFINE(_OPEN_DEFAULT=1),-qdigraph,-qinfo=lan,-qtempinc=tempinc,-qnortti,-qlanglvl=extended:nolibext:nolonglong,-qnoattr,-qinlrpt=/dev/fd1,-qnoinlrpt,-qtmplparse=no,-qansialias),object(./a.o),NOPPONLY,NULL)
exec: export(export,STEPLIB=CBC.SCCNCMP:CEE.SCEERUN2:CEE.SCEERUN,NULL)
exec: export(export,_CXX_ACCEPTABLE_RC=4,NULL)
exec: /bin/cxx(/bin/cxx,-v,a.o,NULL)
exec: export(export,_CXX_ACCEPTABLE_RC=4,NULL)
exec: export(export,_CXX_PVERSION=0x42030000,NULL)
exec: export(export,_CXX_PSYSIX=CEE.SCEELIB(C128N):CBC.SCLBSID(IOSTREAM,COMPLEX),NULL)
exec: export(export,_CXX_PSYSLIB=CEE.SCEEOBJ:CEE.SCEECPP,NULL)
exec: export(export,_CXX_LSYSLIB=CEE.SCEELKEX:CEE.SCEELKED:CBC.SCCNOBJ:SYS1.CSSLIB,NULL)
FSUM0000I Utility(c89) Level(D170323.1712)
//* cxx ------------------------------------------------------------------------
//LINKEDIT EXEC PGM=LINKEDIT,
// PARM='AMODE=31,RMODE=ANY,TERM=YES,
// DYNAM=DLL,ALIASES=NO,UPCASE=NO,
// LIST=OFF,MAP=NO,XREF=NO,INFO=NO,MSGLEVEL=4,
// REUS=RENT,EDIT=YES,AC=0,CALL=YES,CASE=MIXED'
//SYSLIB DD DSN='CEE.SCEELKEX',DISP=SHR,DCB=DSORG=DIR
// DD DSN='CEE.SCEELKED',DISP=SHR,DCB=DSORG=DIR
// DD DSN='CBC.SCCNOBJ',DISP=SHR,DCB=DSORG=DIR
// DD DSN='SYS1.CSSLIB',DISP=SHR,DCB=DSORG=DIR
//C8920 DD UNIT=SYSALLDA,SPACE=(32000,(100,100)),
// STORCLAS=,MGMTCLAS=,DATACLAS=,DSNTYPE=,
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=3200)
//C8961 DD DSN='CEE.SCEEOBJ',DISP=SHR,DCB=DSORG=DIR
//C8962 DD DSN='CEE.SCEECPP',DISP=SHR,DCB=DSORG=DIR
//C8921 DD DSN='CEE.SCEELIB(C128N)',DISP=SHR,DCB=DSORG=NOTDIR
//C8922 DD DSN='CBC.SCLBSID',DISP=SHR,DCB=DSORG=DIR
//SYSPRINT DD PATH='/dev/fd1',
// PATHOPTS=(ORDWR,OCREAT,OAPPEND),FILEDATA=TEXT,
// PATHMODE=(SIROTH,SIRGRP,SIRUSR,SIWOTH,SIWGRP,SIWUSR)
//SYSTERM DD PATH='/dev/fd2',
// PATHOPTS=(ORDWR,OCREAT,OAPPEND),FILEDATA=TEXT,
// PATHMODE=(SIROTH,SIRGRP,SIRUSR,SIWOTH,SIWGRP,SIWUSR)
//SYSLMOD DD PATH='a.out',
// PATHOPTS=(OWRONLY,OCREAT),
// PATHMODE=(SIRWXO,SIRWXG,SIRWXU)
//SYSDEFSD DD DUMMY,
// DCB=(RECFM=F,LRECL=80,BLKSIZE=80)
//SYSLIN DD *
INCLUDE C8920
INCLUDE './a.o'
AUTOCALL C8961
AUTOCALL C8962
INCLUDE C8921
INCLUDE C8922(IOSTREAM)
INCLUDE C8922(COMPLEX)
/*
The output of this command shows what environment variables need to be exported and what data sets are defined for each. Naturally, one does not need to use the c89 utility directly, the same can be accomplished by using the xlc utility.
In your case a cxx command can be replaced with xlC -F:cxx or simply xlC as the xlC command is equivalent to cxx command that invokes the c89 utility. The bonus from using the xlc instead of the c89 utility is that you get to use shell friendly options which are specified using -q syntax and not -Wc,"..." syntax.

You have a typo, I think. Instead of:
_CXX_LSYSLIB="CEE.SCEELKEDX:CEE.SCEELKED:CBC.SCCNOBJ:SYS1.CSSLIB"
I think you want:
_CXX_LSYSLIB="CEE.SCEELKEX:CEE.SCEELKED:CBC.SCCNOBJ:SYS1.CSSLIB"
It's the extra 'D' that's killing you. Crappy error message I agree.

Related

Convert varible to number for dd command using Shell script

I parsed /proc/PID/maps using shell script , now I have 2 variable
START_ADDR=982fe000
END_ADDR=984fe000
I want to use those variable for dd using shell script command like:
dd if=SOME_MEMORY skip=START_ADDR count=(END_ADDR-START_ADDR) of=out.bin bs=1
How can I convert those variable for dd?
As you didn't mention which shell you are using, I am assuming you are using bash.
Keeping that in mind, you can modify your above command as shown below to make it work.
dd if=$SOME_MEMORY skip=$START_ADDR count=$((0x$END_ADDR - 0x$START_ADDR)) of=out.bin bs=1
You need to make sure the variables SOME_MEMORY, END_ADDR and START_ADDR are accessible and present in current shell environment, to verify you can do
echo $SOME_MEMORY, echo $START_ADDR and similarly echo $END_ADDR

Eclipse define build variable in pre-build

I created simple shell script file in /tmp/test.sh
#!/bin/sh
echo 'aaaa'
In Eclipse->C/C++ Build->Setting->Build Step -> Pre-build steps->Command , I added TEST =/tmp/test.sh
Than in C/C++ Build->Setting->Tool Settings->Cross GCC Compiler ->Command line pattern , I tried to used this variable like -D ${TEST} so it pass -D aaaa (the output of shell script)
But in build console I didn't see that -D aaaa have been passed to gcc , In fact I didn't see -D at all
why is that? I want to set variable in pre-build that will be the output of shell script and use it with gcc command line pattern
How can I do that ?
Apparently the CDT managed build does not allow running external commands for assigning environment variables, build variables or command line flags, thus executing the script at that stage doesn't work.
Not a direct answer to the question on how to do that with the gcc command line pattern, but if you really only want to pass defines to the preprocessor with results you got from the script, you may use the script instead to update or create a header file that is included somewhere, e.g.:
#!/bin/sh
echo "#ifndef __MYVARHEADER__" > ../include/myvarheader.h
echo "#define __MYVARHEADER__" >> ../include/myvarheader.h
echo "#define aaaa" >> ../include/myvarheader.h
echo "#endif" >> ../include/myvarheader.h
In Eclipse->C/C++ Build->Setting->Build Step -> Pre-build steps->Command, just execute /tmp/test.sh

Cmake add command line argument to binary

I create a binary myBinary via cmake/CMakeLists.txt.
I would like to "include" default options on my binary.
In other words, I want my binary to be called with myBinary --option myopt even when I just run ./myBinary
How can I do that?
CMake does not have built-in support for you you want to do.
One solution is to do as #Youka said - change the source code of your program.
Another solution that I have used sometimes is to autogenerate a script that executes an executable:
# Create startup script
MACRO(GEN_START_SCRIPT binName)
# Generate content
SET(fileContent
"#!/bin/bash\n"
"\n"
"# This startup script is auto generated - do not modify!\n"
"\n"
"${binName} -a 23 -b 34 -c 976\n"
"\n"
)
# Write to file
SET(fileName ${CMAKE_CURRENT_BINARY_DIR}/${binName}.sh)
FILE(WRITE ${fileName} ${fileContent})
ENDMACRO()
Then call the macro after defining your executable:
ADD_EXECUTABLE(myBinary file1.c file.2)
GEN_START_SCRIPT(myBinary)
You can of course add other stuff to the script, like environment variables etc.
If you're in control of the sources and you want different default behavior... change the sources!
This is in no way a build system issue (CMake or otherwise).

'ld86: no start symbol' when I try to combine 2 object files

so for a small project I have for my OS course, we're supposed to make a very small kernel. We're provided with a couple of assembly files and so on; essentially for this part we're supposed to use the following lines:
bcc -ansi -c -o kernel.o kernel.c
as86 kernel.asm -o kernel_asm.o
ld86 -o kernel -d kernel.o kernel_asm.o
dd if=kernel of=floppya.img bs=512 conv=notrunc seek=3
ld86, where it's supposed to link kernel.o and kernel_asm.o, is where it goes wrong. It issue the error in the title (ld86: no start symbol), and if I then try to use the dd utility, it tells me that it failed to open kernel (because the file was never created by ld86)
I've tried looking up the error for over an hour now, and I have found nothing. Any help (even speculation) would be appreciated.

adding -pg only if make debug specified

I am new to makefile, I am trying to add a make debug mode.
I have the following:
CXXFLAGS=-Wall -c
debug: $(EXECUTABLE)
CXXFLAGS+=-pg
all:
....
for some reason it assigns it and when I put make debug it give me
CXXFLAGS+=-pg
/bin/sh: CXXFLAGS+=-pg: not found
make: *** [debug] Error 127
Is there any way to do and avoid writing the entire all command again in the debug except with -pg flags?
I tried to remove debug: target
and CXXFLAGS was concatenated with -pg flags successfully
If you are using gnumake, just add:
debug: CXXFLAGS += -pg
debug: $(EXECUTABLE)
Note that it is typical to define all first so that it is the default. If the rules for debug appear before all in the Makefile, debug becomes the default (if it is first).
All tab-indented lines below a target are piped directly to shell subprocesses, but your CXXFLAGS line is using Makefile syntax, not valid shell syntax.
Worse, even if you used shell syntax, setting the variable wouldn't carry over to lines executed under a different target; they would only affect shell commands under the same target, and then, only if all the lines are joined with \ escape characters.
Make will read the values from environment variables, so you could set the environment variable as you run make, e.g. (Bourne-family shells):
myprompt$ CXXFLAGS=" -pg $CXXFLAGS" make

Resources