1 (edited by JohnWasilewski 2020-09-29 08:22:47)

Topic: Does SF look up system variables properly?

SF MacOS version

When I use system variables that I have set to pathnames, such as $HOME, and $DISLIN, this seems not to work in all parts of Simply Fortran.

Although I'm not yet certain of this, here's what appears initially to be the case:

SF DOES see look up the strings in these variables whem I enter them in Project options>Compiler flags
eg   -L$DISLIN  -ldislin  -L/Applications/OpenMotif21/libs  -lXm

...but

it seems not to work when I enter them in Project options>File locations. 
eg $DISLIN, $DISLIN/gf/Real64, and $HOME/DEV/IoWinLib/Modules64
It works to expand these to the full pathnames but not when I use the $ system variables as above.

I discovered this by looking in the Makefile.  When trying to 'build' a project, I was getting errors about libraries not being found, so I examined the Makefile and was surprised to see error messages in there as well (surprised because I thought the Makefile was auto generated and then simply read, but it appears to receive error messages as well).  Anyway, the Makefile showed me what was going wrong, which was helpful.  I don't recall the exact error message but it was something about the pathnames it was trying to read, that contained system variables, not being found.

Is there something I am not doing correctly here?
Was it intended that SF should be able to look up system variables?
---
John

Re: Does SF look up system variables properly?

John,

Simply Fortran uses a modified version of Open Watcom Make to control the build process.  The syntax for specifying environment variables is different than many UNIX utilities.  To access an environment variable, you need to use:

$(%name_of_env_var)

so in your options string, you would want to use:

-L$(%DISLIN)  -ldislin  -L/Applications/OpenMotif21/libs  -lXm 

and it should expand properly.

Jeff Armstrong
Approximatrix, LLC

Re: Does SF look up system variables properly?

Many thanks Jeff.  Is that in the 'Help' manual?  I'm sorry if I missed it.
Also, ought I to be using the $(%name_of_env_var) syntax in Project options, not only in >File locations but also in >Compiler flags?
---
John

Re: Does SF look up system variables properly?

John,

Yes, you can use that syntax in both locations.  And no, the syntax isn't anywhere in the manual.  I should add it.

Jeff Armstrong
Approximatrix, LLC

Re: Does SF look up system variables properly?

Jeff,

I really want to get this right, so I've tried to do, to the letter, what you have explained, using system variables, but I just can't seem to get SF to do what I want !

To show my system variables, without 'typo' errors, the following is copied and pasted from a CLI window:

➜  ~ echo $DISLIN
/Users/john/Library/dislin

➜  ~ echo $HOME
/Users/john

These are my Options/File locations, which I typed here, in this forum posting, then copied and pasted into my SF settings (done that way roiund because I can't seem to 'copy' from the SF settings dialog):
Modules:
    $(%DISLIN)/gf/Real64
    $(%HOME)/Documents/DEV/IOlibWin/Mac.SF/modules64
Libraries:
    $(%DISLIN)
    $(%HOME)/Documents/DEV/IOlibWin/Mac.SF

With the settings as above,

(1) Trying to BUILD gives this result:

Fatal Error: Cannot open module file 'dislin.mod' for reading at (1): No such file or directory
compilation terminated.
Error: Last command making (./build64/Alloc.o) returned a bad status
Error: Make execution terminated
 
* Failed *

..and (2) I get these errors in the Makefile:

IDIR=-I"/Applications/Simply Fortran.app/Contents/Resources/gcc/include/" -I/Users/john/Documents/DEV/INCLUDE 
# warning - directory error: $(%DISLIN)/gf/Real64
# warning - directory error: $(%HOME)/Documents/DEV/IOlibWin/Mac.SF/modules64

LDIR=-L"/Applications/Simply Fortran.app/Contents/Resources/gcc/lib/" 
# warning - directory error: $(%DISLIN)
# warning - directory error: $(%HOME)/Documents/DEV/IOlibWin/Mac.SF/modules64

When I use these settings instead of the above, in my Options/File locations:
Modules:
    /Users/john/Library/dislin/gf/Real64
    /Users/john/Documents/DEV/IOlibWin/Mac.SF/modules64
Libraries:
    /Users/john/Library/dislin
    /Users/john/Documents/DEV/IOlibWin/Mac.SF

..these errors no longer appear. 

(althought the build does still fail, but this time it fails because of coding errors, not because of being unable to find libraries.
---
John

Re: Does SF look up system variables properly?

Ah, I had forgotten that "feature" in Simply Fortran.  For include and library directories, the development environment makes sure they exist before passing them to the make utility.  But the development environment does not expand environment variables; that process happens in the make utility only.

I'll have to add environment variable expansion to the library and include directory detection in the development environment.  It might take a few days.

Jeff Armstrong
Approximatrix, LLC

Re: Does SF look up system variables properly?

Oh great - thanks Jeff.