Environment variable error while trying to create a solver in OpenFOAM 9 - c++

I'm trying to create a solver in my /opt/OpenFOAM/OpenFOAM-9/applications/solvers/electromagnetics directory using sudo foamNewSource App newSolver. But, I keep getting the following error:
foamNewSource: Creating new interface file newSolver.C
wmakeFilesAndOptions error: environment variable $WM_OPTIONS not set
And then, although I can see a newSolver.C file, I cannot see a Make directory and neither the rest of the files.
I'm running EndeavourOS Linux x86_64 with kernel 5.15.6-arch2-1 and shell bash 5.1.12. I installed the openfoam-org package from the AUR, and in order to set it up, I have the following in my .bashrc config file:
source /opt/OpenFOAM/OpenFOAM-9/etc/bashrc
At first, when I did env | grep WM I couldn't find WM_OPTIONS in my system. So, after googling a little bit, I added this to my .bashrc file:
source /opt/OpenFOAM/OpenFOAM-9/etc/bashrc
export WM_OPTIONS=linux64GccDPOpt
And now, doing env | grep WM I get:
WM_COMPILER=Gcc
WM_PRECISION_OPTION=DP
WM_PROJECT_USER_DIR=/home/username/OpenFOAM/username-9
WM_MPLIB=SYSTEMOPENMPI
WM_OPTIONS=linux64GccDPOpt
WM_ARCH=linux64
WM_LABEL_SIZE=32
WM_PROJECT=OpenFOAM
WM_THIRD_PARTY_DIR=/opt/OpenFOAM/ThirdParty-9
WM_LABEL_OPTION=Int32
WM_CC=gcc
WM_CFLAGS=-m64 -fPIC
WM_LINK_LANGUAGE=c++
WM_OSTYPE=POSIX
WM_PROJECT_VERSION=9
WM_DIR=/opt/OpenFOAM/OpenFOAM-9/wmake
WM_ARCH_OPTION=64
WM_CXXFLAGS=-m64 -fPIC -std=c++0x
WM_PROJECT_INST_DIR=/opt/OpenFOAM
WM_LDFLAGS=-m64
WM_CXX=g++
WM_COMPILE_OPTION=Opt
WM_PROJECT_DIR=/opt/OpenFOAM/OpenFOAM-9
WM_COMPILER_TYPE=system
WM_COMPILER_LIB_ARCH=64
Now I can see the WM_OPTIONS environment variable (just above WM_ARCH=linux64 and below WM_MPLIB=SYSTEMOPENMPI), but I still get the same wmakeFilesAndOptions error.
I don't know what configuration I'm messing up, so I'd appreciate some help!
Thanks!

Using sudo in this case is not a good idea, instead run the scripts on your home directory:
mkdir -p $FOAM_RUN
cd $FOAM_RUN
foamNewSource App newSolver
For WM_OPTIONS environment variable, don't set it manually, instead use:
export WM_OPTIONS=$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION$WM_COMPILE_OPTION

Related

Need help on compiling DPDK hello world

I try to learn DPDK using the following link: https://doc.dpdk.org/guides/prog_guide/build_app.html
I have downloaded DPDK 19.11.1 version in Ubuntu 16 virtual machine. Then unzipped the tar.gz file. Then I have given the following commands
~/DPDK$ cd examples/helloworld/
~/DPDK/examples/helloworld$ export RTE_SDK=/home/vijay/dpdk
~/DPDK/examples/helloworld$ export RTE_TARGET=x86_64-native-linuxapp-gcc
~/DPDK/examples/helloworld$ make
The following error is displayed:
/home/vijay/dpdk/mk/internal/rte.extvars.mk:29 cannot find .config in /home/vijay/dpdk/build. stop
If I put sudo make, the following error is displayed
Makefile:44: *** "Please define RTE_SDK environment variable". stop
When I put echo $RTE_SDK and echo $RTE_TARGET the values are printed correctly. I tried x86_64-native-linux-gcc for RTE_TARGET also.
I tried multiple times and referred to different sources. Not sure whether I miss any steps in the process. What can I try next?
Based on the error logs, it looks like you have not built dpdk libraries in the desired target folder. To do it correctly
cd dpdk-main-folder
export RTE_SDK=$PWD
export RTE_TARGET=x86_64-native-linuxapp-gcc
make config T=$RTE_TARGET O=$RTE_TARGET
cd $RTE_TARGET
make -j 10
With these done go to your desired example and execute make

Running configure file in MinGW64: default build_alias command and default prefix not found

I'm using MinGW64 via an MSYS2 download and am currently trying to install the Solar Geometry 2 library (http://www.oie.mines-paristech.fr/Valorisation/Outils/Solar-Geometry/) for use. I'm following their install README, which states to navigate to the directory and "configure" (I've been typing "./configure". However, when I do so, I get the following message in my terminal:
$ ./configure
configure: loading site script /mingw64/etc/config.site
/mingw64/etc/config.site: line 13: config.site:13: default build_alias set to x6_64-w64-mingw32: command not found
/mingw64/etc/config.site: line 20: config.site:20: default prefix set to /mingw4: No such file or directory
configure: error: cannot find install-sh or install.sh in . ./.. ./../..
When I initially installed MSYS2 I set up the etc/fstab file as recommended. However, I'm quite new to MSYS so I'm assuming I botched something in my setup. I haven't edited anything in the config.site file mentioned in the errors, so I'm wondering if it's something in there.
Any help is greatly appreciated, thank you
No where in the directions for "Solar Geometry" do I see reference to MSys or MSys2.
I suggest you install the compiler toolchain and base development file. No idea if you editing /etc/fstab will cause problems. I do not normmaly edit it!
Install MinGW Package build packages. You might need more packages installed.
pacman -S --needed base-devel mingw-w64-x86_64-toolchain

clang compiler not working on terminal Mac OSX

I just upgraded to El Capitan and found out that the C compiler (Clang) is not working under the command line. I wrote a "hello word" test, tried to compile and I get the following error:
$ cc test.c -o test
$ error: unable to open output file
'/var/folders/Ge/GeRStfi8Ek8jojLcqf1vsE+++TI/-Tmp-/test-ad7039.o': 'No
such file or directory'
1 error generated.
... do I have a permission problems somewhere? Thanks!
Either you're running into permissions problems (the compiler is unable to create a folder inside var, and so there's no such file or directory) or the ability to open the file in the current directory of compilation isn't allowed. Check your permissions on
The file
The directory
Run the command under sudo. If that fixes your problem, then use ls -la to check your permissions in the current folder. Then, use chown or chmod to change the permissions on the file/folder.
Example:
chown owner-user test.c
Now, you may actually not actually have access to the /var/ folder. If so, then the temp folder cc is creating is the problem. So then, you'd sudo call cc. For a more permanent fix, you can chown the binary or directory clang is in.

Getting Leiningen & Cygwin Working

I am trying to get Leiningen and Cygwin working together.
One of the problems I think I have is that I have Java installed in "C:\Program Files\Java..." directory. The space appears to be causing issues.
When I try to run the lein script in Cygwin, I am getting the following error:
./lein: line 325: C:\Program Files\Java\jdk1.8.0_05\bin\java.exe : command not found
Then I thought the issue was the space. So I changed line 325 from:
"$LEIN_JAVA_CMD" \
to (for testing purposes):
"$'C:\\\Program Files\\\Java\\\jdk1.8.0_05\\\bin\\\java.exe'" \
But, I am still getting this error:
./lein: line 325: $'C:\\Program Files\\Java\\jdk1.8.0_05\\bin\\java.exe' : commande introuvable
However, this file clearly exists:
Owner#Owner-PC ~
$ ls -alh $'C:\\Program Files\\Java\\jdk1.8.0_05\\bin\\java.exe'
-rwxr-xr-x 1 Owner None 187K 8 mai 15:39 C:\Program Files\Java\jdk1.8.0_05\bin\java.exe
The lein script appears to be properly configuring Leiningen for Cygwin, however I can't get it to work.
Note that I previously installed Leiningen outside of Cygwin (I was running it in Windows' normal shell).
What could be wrong with my setup, any ideas?
I use Leiningen via Cygwin with no problems.
Start over
Start over with a fresh copy of the lein script. There should be no need to edit it.
Set your PATH to include java
The easiest solution is to set your path in ~/.profile to include the path to Java's bin directory. Lein will then find java on the path and you'll have access to java and its related tools in your shell.
export JAVA_HOME="/cygdrive/c/Program Files/Java/jdk1.8.0_05/"
export PATH="${JAVA_HOME}/bin/:${PATH}"
Restart your shell or source ~/.profile. Verify that which java finds java command. And run java to verify you get the help output.
And/or explicitly set the LEIN_JAVA_CMD and JAVA_CMD variables
Alternatively, set the LEIN_JAVA_CMD and JAVA_CMD variables used by lein in your ~/.profile
export JAVA_HOME="/cygdrive/c/Program Files/Java/jdk1.8.0_05/"
export LEIN_JAVA_CMD="${JAVA_HOME}/bin/java"
export JAVA_CMD=`cygpath -w "${LEIN_JAVA_CMD}"`
Restart your shell or source ~/.profile.
Note: You can also set a separate LEIN_JVM_OPTS and JVM_OPTS if desired, but this should not be necessary.
If you have lein previously installed on Windows and want to reach it from cygwin, then do:
on cmd:
cd C:/Users/%userprofile%/.lein/bin
mklink lein lein.bat
on cygwin:
export CYGWIN=winsymlinks:nativestrict
I feel your pain. I tried something like this myself several years ago.
You have at least two problems. One is getting lein to run as under unix as you noted. There are really two lein scripts - one for unix, the other a batch script for use under windows.
Your bigger problem is java.exe - getting the windows java executable to behave as a cygwin shell, and particular the unix lein script running in a cygwin shell, expects is messy and fragile undertaking.
I would strongly recommend either using a clojure ide that supports Windows (perhaps LightTable) or installing a full linux virtual machine with the unix java SDK and doing clojure development in that environment. Ubuntu running on virtualbox is freely available and an option I have used in the past for just this purpose.
You need to create a symbolic link to the "lein.bat" file.so you use it properly in Cygwin.
Open CMD and go to the ".lein" path (cd %userprofile%\.lein\bin) and run this: mklink lein lein.bat
#a-webb is almost right ,but there are still some steps to complete.First,you will find a folder called “.lein” where you run the lein script in cygwin,go in,copy the folder "self-installs" inside to C:\Users\yourUserName.lein
,then,add C:\Users\yourUserName.lein\bin to the environment variable $Path.
I've found the easiest way is to:
Install via the windows binaries and
Copy the lein bash script into .lein/bin
Then it should just work in cygwin.

Need to solve "Can't locate VMware/VIRuntime.pm" in cygwin

I have a (maybe) unusual situation. I need to run VMware CLI commands in a Windows box, but via the cygwin CLI inside a shell script. I can NOT change this for now, so any suggestions to "why not do this instead" may be futile, although appreciated. Here's a sample script.
#!/bin/bash
# Paths for vmware-cmd.pl file to run vmware commands from vsphere cli
_vcli_dir="/cygdrive/c/Program Files (x86)/VMware/VMware vSphere CLI"
_vcli_bin="$_vcli_dir/bin"
_vcli_perl="$_vcli_dir/Perl"
_vcli_perl_bin="$_vcli_perl/bin"
_vcli_perl_lib="$_vcli_perl/lib"
_vcli_perl_vlib="$_vcli_perl_lib/VMware"
_vcmd=vmware-cmd.pl
export _orig_path=$PATH
# Add above directories to path variable
export PATH=$PATH:$_vcli_dir:$_vcli_bin:$_vcli_perl:$_vcli_perl_bin:$_vcli_perl_lib:$_vcli_perl_vlib
echo $PATH
$_vcmd /?
export PATH=$_orig_path
echo $PATH
When I run the above script, I get
Can't locate VMware/VIRuntime.pm in #INC (#INC contains:
/usr/lib/perl5/site_perl/5.14/i686-cygwin-threads-64int
/usr/lib/perl5/site_perl/5.14
/usr/lib/perl5/vendor_perl/5.14/i686-cygwin-threads-64int
/usr/lib/perl5/vendor_perl/5.14
/usr/lib/perl5/5.14/i686-cygwin-threads-64int /usr/lib/perl5/5.14
/usr/lib/perl5/site_perl/5.10 /usr/lib/perl5/vendor_perl/5.10
/usr/lib/perl5/site_perl/5.8 .) at /cygdrive/c/Program Files
(x86)/VMware/VMware vSphere CLI/bin/vmware-cmd.pl line 8. BEGIN
failed--compilation aborted at /cygdrive/c/Program Files
(x86)/VMware/VMware vSphere CLI/bin/vmware-cmd.pl line 8.
I can run the same vmware-cmd.pl script from a DOS command prompt
c:> vmware-cm.pl
So I now my installation is correct.
Any clues please?
This post gave me the idea to fix it. But now I get a core dump.
How is Perl's #INC constructed? (aka What are all the ways of affecting where Perl modules are searched for?)
The added line is the second export PERL5LIB line.
#!/bin/bash
# Path for vmware-cmd.pl file to run vmware commands from vsphere cli
_vcli_dir="/cygdrive/c/Program Files (x86)/VMware/VMware vSphere CLI"
_vcli_bin="$_vcli_dir/bin"
_vcli_perl="$_vcli_dir/Perl"
_vcli_perl_bin="$_vcli_perl/bin"
_vcli_perl_lib="$_vcli_perl/lib"
_vcli_perl_vlib="$_vcli_perl_lib/VMware"
_vcmd=vmware-cmd.pl
export _orig_path=$PATH
# Add above directories to path variable
export PATH=$PATH:$_vcli_dir:$_vcli_bin:$_vcli_perl:$_vcli_perl_bin:$_vcli_perl_lib:$_vcli_perl_vlib
export PERL5LIB=$_vcli_dir:$_vcli_bin:$_vcli_perl:$_vcli_perl_bin:$_vcli_perl_lib:$_vcli_perl_vlib
echo $PATH
$_vcmd /?
export PATH=$_orig_path
echo $PATH
I solved by going through my elbow to get to my a**, as the saying goes.
What I did was
- Install vmware cli on my Windows box to the default directory
- Added environment variables for the VMware main directory, the bin directory, the Perl directory and the Perl/bin directory
- Added these environment variables to my PATH variable.
Then I created a vmware-cli.bat file that takes parameters and concatenates them into a vmware-cli command with the correct values. For example, I call this to list the VMs in the server
cygwin:> ./vmware-cli.bat vmware-cmd.pl --server MyServer --username User --password PW -l
Inside the batch file I essentailly do
REM Get first parm as the command, and then concatenate the rest of the parms
set VCLI_CMD=%1
shift
:LOOP
if %1x==x goto :EXECUTE
set VCLI_CMD=%VCLI_CMD% %1
shift
goto LOOP:
:EXECUTE
%VCLI_CMD%
This is an alternative to the previous posted that will allow you to keep it in the same shell script
VIMCMD="/cygdrive/C/Program Files (x86)/VMware/VMware vSphere CLI/bin/vmware-cmd.pl"
VIMCMD_DOS=$(cygpath -d "$VIMCMD")
DOS_VIMCMD="cmd /c $VIMCMD_DOS"
Then you can run:
$ $DOS_VIMCMD --version
vSphere SDK for Perl version: 6.0.0
Script 'vmware-cmd.pl' version: 6.0.0