clang compiler not working on terminal Mac OSX - c++

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.

Related

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

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

Emscripten installation error: "./emcc no such file or directory"

I tried installing Emscripten on the latest version Arch Linux but was unsuccessful. I recieved no errors during the installation process, but when I attempted to verify the installation it threw an error: "bash: ./emcc no such file or directory". To the best of my ability I followed the instrcutions at https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html.
Installation Steps:
1) Dependencies (GCC ships complete with Arch, so no need to install)
pacman -S cmake python2 nodejs git
2) Download and unzip emsdk-portable.tar.gz
mkdir emscripten && cd empscripten
tar -xvf emsdk-portable.tar.gz
3) Installation
cd emsdk-portable
./emsdk update
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
source ./emsdk outputs:
Adding directories to PATH:
PATH += /home/myuser/emscripten/emsdk-portable
Setting environment variables:
EMSDK = /home/myuser/emscripten/emsdk-portable
EM_CONFIG = /home/myuser/.emscripten
Running echo $PATH outputs:
/home/myuser/emscripten/emsdk-portable:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
Running ./emcc -v or ./em++ -v outputs:
bash: ./emcc: No such file or directory
Any thoughts?
Here is my ~/.emscripten file:
import os
SPIDERMONKEY_ENGINE = ''
NODE_JS = 'node'
V8_ENGINE = ''
TEMP_DIR = '/tmp'
COMPILER_ENGINE = NODE_JS
JS_ENGINES = [NODE_JS]
Most usually, a current directory (.) is not added to the PATH variable, AFAIK it is for security reasons, so don't add it yourself too. :) When someone executes ./emcc, they specify the relative path to the program to be executed: "a program emcc residing precisely in the current directory".
On the other hand, executing just emcc (without the ./ prefix) means "iterate through the directories from the PATH variable left-to-right and execute the first found emcc executable". When you source the emsdk_env.sh you, among other things, adjust the PATH variable.
In comments you told that which emcc cannot find the emcc executable. It is strange, but even when you manage to fix the installation problem, you have to most usually specify emcc on the command line without the ./ prefix.

gcc returns "No such file or directory"

I'm trying to install Mathtex on my Ubuntu 16.04 server for my engineering wiki. It has been a nightmare, just as it was in the past when I tried this.
First, I've installed mathtex via apt-get. That complains of a missing directory. After manually creating those directory it moves on to complain of another. Finally complains of a missing cache directory. I create the cache just like the others and mathtex still complains that the cache directory is missing...
Then I attempt to install via the instructions on the website (http://www.forkosh.com/mathtex.html). In other words, install the dependencies LaTeX and dvipng. Then compile the program using cc (although I use gcc). I've gotten this to work in previous installations of Ubuntu - 12.04 or 14.04 - but can't find those instructions anymore. I was paying for a service until this summer when they went out of business.
Here is the compile line:
cc mathtex.c –DLATEX=\"$(which latex)\" –DDVIPNG=\"$(which dvipng)\" –o mathtex.cgi
Here is the return:
cc: error: –DLATEX="/usr/bin/latex": No such file or directory
cc: error: –DDVIPNG="/usr/bin/dvipng": No such file or directory
cc: error: –o: No such file or directory
I've also tried replacing $(which latex) with $(which pdftex) (/usr/bin/latex is a symbolic link to /usr/bin/pdftex) and /usr/bin/pdftex, /usr/bin/tex, /usr/bin, and /usr/bin/. Same result, the error says there is no such file or directory for all of them.
Googling this error only returns help for people who can't get Ubuntu to recognize gcc as the cc compiler. That's not my issue though.
Did you copy that command from a document? You have the wrong kind of dashes on your options.
Delete the – (en dash) and replace it with -.

Installing the Qt SDK shows the message: cannot execute binary file

My environment is Linux 11.04
When I want to install Qt SDK
I download the SDK:qt-creator-linux-x86_64-opensource-2.5.2.bin
I move this file to /opt
and then
chmod u+x qt-creator-linux-x86_64-opensource-2.5.2.bin
./qt-creator-linux-x86_64-opensource-2.5.2.bin
but it shows that: cannot execute binary file
I think whether if it is because my Ubuntu is belong to 32-bit architecture
so I download qt-creator-linux-x86-opensource-2.5.2.bin
also move it to /opt file
and give the command:
chmod u+x qt-creator-linux-x86-opensource-2.5.2.bin
./qt-creator-linux-x86-opensource-2.5.2.bin
The same message still shows.
I give another command:
sudo ./qt-creator-linux-x86-opensource-2.5.2.bin
but it shows that Syntax error: ")" unexpected
how can I resolve this problem?

wodi64: ocamlopt issues an error

I installed wodi64 on windows 7. When I try to compile a simple hello world program with:
ocamlopt -o hello hello.ml
I get an error:
File "hello.ml", line 1:
Error: Corrupted compilation unit description
C:/wodi64/opt/wodi64/lib/ocaml/std-lib\pervasives.cmx
The contents of the hello.ml file are just:
print_string "Hello world!\n";;
Any idea on how to solve this?
Thanks.
First of all, check that your files are still ok. There are various anti-virus software, that don't like the ocaml compiler and manipulates/remove it's files.
Instructions (from the installed cygwin shell):
cd /tmp # or: wget 'http://wodi.forge.ocamlcore.org/wodi64o.md5sum' -O /tmp/wodi64o.md5sum
godi_console wget 'http://wodi.forge.ocamlcore.org/wodi64o.md5sum'
cd /opt/wodi64
md5sum -c /tmp/wodi64o.md5sum
# install md5sum via cygwin's setup, if it's not already installed
There can be some mismatches, because configuration files will be updated during operation (e.g /opt/wodi64/lib/ocaml/std-lib/ld.conf, Makefile.config will differ ); but binary files should be identical.