Cannot find directory for linker -lgomp - gcc

I am on an M1 Mac and I have Homebrew GCC installed. I am trying to multithread using OpenMP.
I have a setup.py file containing:
sources = ['pyTsetlinMachineParallel/ConvolutionalTsetlinMachine.c', 'pyTsetlinMachineParallel/MultiClassConvolutionalTsetlinMachine.c', 'pyTsetlinMachineParallel/Tools.c'],
include_dirs=['pyTsetlinMachineParallel'],
extra_compile_args=['-fopenmp'],
extra_link_args=['-L/usr/local/Cellar/gcc/11.2.0_3/lib/gcc/11 -lgomp' ])
When I build the file, I get the error:
ld: warning: directory not found for option '-L/usr/local/Cellar/gcc/11.2.0_3/lib/gcc/11 -lgomp'
In /usr/local/Cellar/gcc/11.2.0_3/lib/gcc/11 I have these files:
libgomp.1.dylib libgomp.a libgomp.dylib libgomp.spec
What am I getting wrong?

Related

I can't run boot0.s file using gcc command

I'm a total newbie in Ubuntu & Assembly Language. Recently one of the lab tasks asks me to compile .s file in Ubuntu to see what the output shows & explain them later. My teacher has also provided me some commands to compile and object linking with boot0.S file. But whenever I try to run this following command, I get several errors.
Building boot0: Compilation
$ gcc ‐MD ‐fno‐builtin ‐nostdinc ‐fno‐stack‐protector ‐Os ‐g ‐m32 ‐I. ‐c ‐o boot0.o boot0.S
It's giving me errors like these:
gazzali#ubuntu:~/OS Lab Task/OS-challenging-IUTCSE16/Project 0/boot/boot0$ gcc ‐MD ‐fno‐builtin ‐nostdinc ‐fno‐stack‐protector ‐Os ‐g ‐m32 ‐I. ‐c ‐o boot0.o boot0.S
gcc: error: ‐MD: No such file or directory
gcc: error: ‐fno‐builtin: No such file or directory
gcc: error: ‐nostdinc: No such file or directory
gcc: error: ‐fno‐stack‐protector: No such file or directory
gcc: error: ‐Os: No such file or directory
gcc: error: ‐g: No such file or directory
gcc: error: ‐m32: No such file or directory
gcc: error: ‐I.: No such file or directory
gcc: error: ‐c: No such file or directory
gcc: error: ‐o: No such file or directory
gcc: error: boot0.o: No such file or directory
I'm currently running Ubuntu 18.04 LTS on VMWare on Windows 10. I will also provide boot0.S file if needed. Can you please help to find a way to run this assembly file? There are more 2 assembly files which I need to run via similar commands.
Thanks in Advance.

OSX Sierra Tensorflow build error: ld: file not found: #rpath/CUDA.framework/Versions/A/CUDA

I have followed the instruction in:
https://gist.github.com/notilas/a30e29ce514970e821a34153c1e78b3f
But cannot complete it.
OSX: Sierra
Tensorflow version 1.1.0 (Google says v1.2 does not support OSX CUDA)
CUDA Tool kit : 8.0
CUDNN : 6.0
Xcode : 7.2.1
Anaconda : 4.2 (Python version 3.5)
Error Log:
ERROR: /Users/so041e/ml/tensorflow/tensorflow/python/BUILD:2534:1:
Linking of rule '//tensorflow/python:_pywrap_tensorflow_internal.so'
failed: link_dynamic_library.sh failed: error executing command
external/bazel_tools/tools/cpp/link_dynamic_library.sh no ignored
ignored ignored
external/local_config_cuda/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc
-shared -o ... (remaining 455 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process
exited with status 1.
clang: warning: argument unused during compilation: '-pthread'
ld: file not found: #rpath/CUDA.framework/Versions/A/CUDA for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
[.bash_profile]
export PATH="/Users/so041e/anaconda/bin:$PATH"
export CUDA_HOME=/usr/local/cuda
export HOME=/Users/so041e
export PATH="$CUDA_HOME/bin:$PATH"
export DYLD_LIBRARY_PATH="/usr/local/cuda/lib:/Developer/NVIDIA/CUDA8.0/lib":$DYLD_LIBRARY_PATH
export LD_LIBRARY_PATH=$DYLD_LIBRARY_PATH
export PATH=$DYLD_LIBRARY_PATH:$PATH
export PATH="//anaconda/bin:$PATH"
Moved CUDNN lib and include to /user/local/cuda
sudo mv -v cuda/lib/libcudnn* /usr/local/cuda/lib
sudo mv -v cuda/include/cudnn.h /usr/local/cuda/include
Didn't use "vent" Just used single python 3.5 at this moment.
Tried both, but no difference.
bazel build --config=cuda --config=opt --action_env PATH --action_env LD_LIBRARY_PATH --action_env DYLD_LIBRARY_PATH //tensorflow/tools/pip_package:build_pip_package
bazel build --config=cuda //tensorflow/tools/pip_package:build_pip_package
This might be a bit late, but I had this exact same problem and I managed to fix it.
First, #rpath/CUDA.framework/Versions/A/CUDA is a dynamic library install name for libcuda.dylib, which is found in /usr/local/cuda/lib. So do
otool -l /usr/local/cuda/lib/libcuda.dylib
Check where you see #rpath/CUDA.framework/Versions/A/CUDA; on my system it was in the command LC_REEXPORT_DYLIB. From here, it seems dyld doesn't resolve the #rpath for the LC_REEXPORT_DYLIB command, only LC_LOAD*_DYLIB commands. Meaning, it looks for the literal path "#rpath/CUDA.framework/Versions/A/CUDA". So you're going to have to change that by doing
sudo install_name_tool -change #rpath/CUDA.framework/Versions/A/CUDA \
/Library/Frameworks/CUDA.framework/Versions/A/CUDA \
/usr/local/cuda/lib/libcuda.dylib
This should resolve your problem.
Now why your system (and mine) has this install name for libcuda.dylib? I have absolutely no clue.

error: linking with `cc` failed: exit code: 1

I have a single .rs file. When I compile it by rustc test1.rs, I get an error:
error: linking with `cc` failed: exit code: 1
note: cc '-m64' '-L' '/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib' '-o' 'test1' 'test1.o' '-Wl,-force_load,/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib/libmorestack.a' '-Wl,-dead_strip' '-nodefaultlibs' '/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib/libstd-4e7c5e5c.rlib' '/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib/libcollections-4e7c5e5c.rlib' '/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib/libunicode-4e7c5e5c.rlib' '/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib/librand-4e7c5e5c.rlib' '/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib/liballoc-4e7c5e5c.rlib' '/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib/liblibc-4e7c5e5c.rlib' '/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib/libcore-4e7c5e5c.rlib' '-L' '/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib' '-L' '/Users/alex/Documents/projects/rust/.rust/lib/x86_64-apple-darwin' '-L' '/Users/alex/Documents/projects/rust/lib/x86_64-apple-darwin' '-lSystem' '-lpthread' '-lc' '-lm' '-lcompiler-rt'
note: ld: warning: directory not found for option '-L/Users/alex/Documents/projects/rust/.rust/lib/x86_64-apple-darwin'
ld: warning: directory not found for option '-L/Users/alex/Documents/projects/rust/lib/x86_64-apple-darwin'
ld: can't open output file for writing: test1, errno=21 for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: aborting due to previous error
$ rustc --version
rustc 1.0.0-dev
I've seen some topic related to this one but none of them helped me to solve the problem.
I was faced with three problems on Mac compiling Rust:
First: If you have any issue with writing files/dirs by ld just remove that files and try to recompile. I don't know why, but on Mac this issue happens time to time.
Second: If you have other ld errors (not about file access): try to add the following sections to your ~/.cargo/config (if you don't have this file feel free to create):
[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
[target.aarch64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
Third: Sometimes your Mac lack of some dev tools/dependencies. Install the most important of them automatically with the command:
xcode-select --install
From your command rustc test1.rs the compiler infers the name of the executable should be test1. The linker tries to open this file so it can write the executable but fails with errno=21 whose stringified version is "Is a directory".
This suggests you have a directory in your working directory called test1 which is causing a conflict.
if you have "note: /usr/bin/ld: cannot find -lsqlite3"
then install libsqlite3-dev: $ sudo apt install libsqlite3-dev
This works on Rust 1.53.0, Linux Mint 20.2(based on Ubuntu 20.04 LTS)
If you have a MacBook M1(x) with ARM processor you need to install rust from rustup https://sourabhbajaj.com/mac-setup/Rust/
When you run rustup-init, use the customize option to change aarch64-apple-darwin to x86_64-apple-darwin
Then you can add the following to .cargo/config.toml or .cargo/config (either is fine)
[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
This solution was tested with Rust 1.54 and MacBook M1
I was able to do a cargo build --release and generate a dylib file from this tutorial https://www.youtube.com/watch?v=yqLD22sIYMo
My rust project stopped building after updating my MacOS so this command fixed it for me
xcode-select --install
I had the same issue recently and I found out this solution that worked for me:
https://www.docker.com/blog/cross-compiling-rust-code-for-multiple-architectures/
On Running Rust on aarch64 I found out that libc6-dev-arm64-cross is need in order to compile rust successfully on aarch64.

Trouble compiling FUSE filesystems on OS X

OS: OS X Mavericks (v10.9)
FUSE: OSXFUSE v2.6.2
I'm trying to compile the loopback filesystem in C, but I'm getting this error:
$ make
cc -D_FILE_OFFSET_BITS=64 -I/usr/local/include/osxfuse/fuse -Wall -g -F/Library/Frameworks -o loopback loopback.c -losxfuse
ld: library not found for -losxfuse
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [loopback] Error 1
Trying to compile boxfs2 also produces this error:
$ make
Package libxml-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libxml-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libxml-2.0' found
Package libcurl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libcurl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libcurl' found
Package libapp was not found in the pkg-config search path.
Perhaps you should add the directory containing `libapp.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libapp' found
Package libjson was not found in the pkg-config search path.
Perhaps you should add the directory containing `libjson.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libjson' found
Compiling boxfs.c
cc -c boxfs.c -o boxfs.o
boxfs.c:15:10: fatal error: 'fuse.h' file not found
#include <fuse.h>
^
1 error generated.
make: *** [boxfs.o] Error 1
Can anyone point me in the right direction?
As far as the first problem, you need the OSXFUSE library somewhere the compiler can see it, or you need to tell the compiler where it is.
You may have some success using mdfind to locate the osxfuse library file, then add -L/path/to/osxfuse to the compile/configure script to the makefile.
Similarly, the for the second, try making sure boxfs2 knows about the fuse header: Looks like adding -I/usr/local/include/osxfuse/fuse might do it.

Enable LLVM + Clang in Xcode new project causes linking errors

I've done a complete clean uninstall of XCode and deleted the prefs and deleted complete /Developer folder and reinstalled XCode again.
I create a new Cocoa application, go over to Target, doing a "Get info" in the target and enable "C / C++ compiler version" to "LLVM compiler 1.0.2" and press Build.
I get:
ld: warning: directory '/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64' following -L not found
ld: warning: directory '/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64' following -L not found
ld: warning: directory '/usr/lib/i686-apple-darwin10/4.2.1' following -L not found
ld: warning: directory '/usr/lib/gcc/i686-apple-darwin10/4.2.1' following -L not found
ld: warning: directory '/usr/lib/gcc/i686-apple-darwin10/4.2.1' following -L not found
ld: warning: directory '/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../../i686-apple-darwin10/4.2.1' following -L not found
ld: warning: directory '/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../..' following -L not found
ld: library not found for -lgcc
Command /Developer/usr/bin/clang failed with exit code 1
Anyone able to help me here? LLVM + GCC frontend does work though but I really would like to use Clang (LLVM compiler 1.0.2). New XCode install, new Cocoa project still have this issue.
I fixed it by creating two symbolic links
/usr/lib/gcc -> /Developer/usr/lib/gcc
and
/usr/lib/i686-apple-darwin10 -> /Developer/usr/lib/i686-apple-darwin10/
Thanks for answering guys.

Resources