Troubleshooting clang error to get C++ code in CLion to work - clion

I'm an inexperienced programmer so bear with me if this little sense. I'm trying to run a basic "hello world" kind of program in CLion, except I'm trying to print out a value in the main.cpp file from a header and cpp file. I'm using MacOS and everything is update in terms of software. When I try to build or run the program, it gives me these errors:
====================[ Build | untitled1 | Debug ]===============================
/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake --build /Users/anshuldaga/untitled1/cmake-build-debug --target untitled1 -- -j 2
[ 33%] Building CXX object CMakeFiles/untitled1.dir/main.cpp.o
[ 66%] Building CXX object CMakeFiles/untitled1.dir/test.cpp.o
make[3]: /Library/Developer/CommandLineTools/usr/bin/c++: Permission denied
make[3]: /Library/Developer/CommandLineTools/usr/bin/c++: Permission denied
make[3]: *** [CMakeFiles/untitled1.dir/main.cpp.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: *** [CMakeFiles/untitled1.dir/test.cpp.o] Error 1
make[2]: *** [CMakeFiles/untitled1.dir/all] Error 2
make[1]: *** [CMakeFiles/untitled1.dir/rule] Error 2
make: *** [untitled1] Error 2
I've already tried running the sudo g++ main.cpp command and it gives me this error:
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Based off my research, I know that clang is the compiler for c++ and a linker error is basically when something can't find the right files or library.
I've uninstalled and reinstalled Xcode, did the
sudo xcode-select -switch /Library/Developer/CommandLineTools/
command. I'm not sure what to do at this point. Any help would be greatly appreciated, thank you!

According to this(archive.org) old post from the CLion forum, the xcode license agreement might be the issue. Try to start xcode and agree to the license, or run sudo xcodebuild -license.

Related

VLC 3.0.12/3.0.14 once command source build fails on macOS

Running mac osx 10.14.6 and have previously successfully built 3.0.10 and 3.0.11. Trying to build VLC 3.0.12 & 3.0.14 from source downloaded from here: http://www.videolan.org/vlc/download-sources.html
and using recommended build from here: https://wiki.videolan.org/MacOSCompile/ AND using the recommended:
../extras/package/macosx/build.sh -c
Build runs for about 20 minutes and then stops here (snip of output):
CCLD libprefetch_plugin.la
CCLD libhds_plugin.la
CCLD librecord_plugin.la
ld: library not found for -lzstd
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[4]: *** [libarchive_plugin.la] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
mysystem:build xx$
What am I missing or doing wrong?
Note: in previous builds I could find a cmake/Utilities/cmzstd/lib directory in vlc-3.0.x/extras/tools that had various zstd files however it is not there in either 3.0.12 or 3.0.14 - only a cmake-enable-ALPN-support-on-macOS-109.14.patch file.
Where do I find zstd? Thanks.
Seems the issue is related to how macOS and packagers (homebrew, etc.) load components. macOS provides a compiled version of libarchive but no headers, so you are unable in trying to compile. You will either need to pass the location of your libarchive respository with headers via your build script or set an environment variable telling the compiler or linker where to look for them. Perhaps someone more familiar with your VLC package can weigh in.

make [2]: **** [Makefile:44: envi_slc_decode] Error 1, while installing gmtsar in fedora 32

This is my first question in stack overflow and hope I make it clear.
I am trying to install a program (gmtsar) in fedora 32. However, the compilation was not complete and two errors return at the end.
I ran the following commands:
sudo -i
cd /usr/local
git clone --branch 6.0 https://github.com/gmtsar/gmtsar GMTSAR
cd GMTSAR
autoconf
./configure --with-orbits-dir=/usr/local/orbits
make
make install
after make and mak install the following errors return:
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:44: envi_slc_decode] Error 1
make[2]: Leaving directory '/usr/local/GMTSAR/preproc/ENVI_preproc/ENVI_SLC_decode'
make[1]: *** [Makefile:8: all] Error 2
make[1]: Leaving directory '/usr/local/GMTSAR/preproc/ENVI_preproc'
make: *** [Makefile:37: preprocess] Error 2
I followed the same procedures in ubuntu 16.04 and the compilation was complete without errors.
Can anyone help me understand why I got these errors and how to fix them, please?

Compile Ruby from source on AIX 7.1

I am trying to compile Ruby 2.4.5 from source using gcc compiler on AIX 7.1. The configure works fine, but the make fails giving an error C is not a recognized flag. Anybody faced the same issue and managed to compile ruby on AIX 7.1?
Steps followed:
1) ./configure --disable-install-doc CC="gcc" CFLAGS="-maix64 -mminimal-toc" CXX="g++" CXXFLAGS="-maix64 -mminimal-toc" NM="nm -X64" AR="ar -X64" LDFLAGS="-maix64" EXTLDFLAGS=" -- works perfectly fine
2) make - fails with the below error
make: Not a recognized flag: C
usage: make [-einqrst] [-k|-S] [-d[A|adg[1|2]mstv]] [-D variable] [-f makefile] [-j [jobs]] [variable=value ...] [target ...]
make: 1254-004 The error code from the last command is 2.
Stop.
make: 1254-004 The error code from the last command is 2.
Stop.
make: 1254-004 The error code from the last command is 2.
Update :
Switching to GNU make gives the below error:
Making all in man
make[5]: Entering directory '/test/ruby-2.4.5/tst/ext/fiddle/libffi-3.2.1/man'
make[5]: Nothing to be done for 'all'.
make[5]: Leaving directory '/test/ruby-2.4.5/tst/ext/fiddle/libffi-3.2.1/man'
make[5]: Entering directory '/test/ruby-2.4.5/tst/ext/fiddle/libffi-3.2.1'
CC src/prep_cif.lo
CC src/types.lo
CC src/raw_api.lo
CC src/java_raw_api.lo
CC src/closures.lo
CC src/powerpc/ffi_darwin.lo
../../../../ext/fiddle/libffi-3.2.1/src/powerpc/ffi_darwin.c: In function 'ffi_p rep_args':
../../../../ext/fiddle/libffi-3.2.1/src/powerpc/ffi_darwin.c:112:17: warning: un used variable 'abi' [-Wunused-variable]
const ffi_abi abi = ecif->cif->abi;
^
CPPAS src/powerpc/aix.lo
libtool: compile: unable to infer tagged configuration
libtool: compile: specify a tag with `--tag'
Makefile:1335: recipe for target 'src/powerpc/aix.lo' failed
make[5]: *** [src/powerpc/aix.lo] Error 1
make[5]: Leaving directory '/test/ruby-2.4.5/tst/ext/fiddle/libffi-3.2.1'
Makefile:1596: recipe for target 'all-recursive' failed
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory '/test/ruby-2.4.5/tst/ext/fiddle/libffi-3.2.1'
Makefile:730: recipe for target 'all' failed
make[3]: *** [all] Error 2
make[3]: Leaving directory '/test/ruby-2.4.5/tst/ext/fiddle/libffi-3.2.1'
Makefile:370: recipe for target 'libffi-3.2.1/.libs/libffi_convenience.a' failed
make[2]: *** [libffi-3.2.1/.libs/libffi_convenience.a] Error 2
make[2]: Leaving directory '/test/ruby-2.4.5/tst/ext/fiddle'
exts.mk:212: recipe for target 'ext/fiddle/all' failed
make[1]: *** [ext/fiddle/all] Error 2
make[1]: Leaving directory '/test/ruby-2.4.5/tst'
uncommon.mk:220: recipe for target 'build-ext' failed
make: *** [build-ext] Error 2
The issue is that you are using AIX's built-in copy of make and it does not support the command-line option -C. That option is available in GNU make.
If you run make -v and do not see output like the following then you are not using GNU make:
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
Run the command which make and it will return either /usr/bin/make or /opt/freeware/bin/make (or a similar path outside of /usr/bin):
If it returns /usr/bin/make then you do not have GNU make installed on your system and will need to follow one of several tutorials to get it installed on AIX.
If it returns /opt/freeware/bin/make then you do have GNU make installed, but it's not reflected in $PATH. You can add it to your path temporarily while you compile Ruby by running export PATH=/opt/freeware/bin:$PATH before you run the make command.
Update:
I would encourage you to open a separate question for your current build trouble, since the original question was about the -C flag for make not working on AIX, and now you have a separate question about running GNU make with an entirely different set of issues and possible solutions.
That said, it's possible you may be able to resolve your issue by starting over and running ./configure LIBTOOL='/usr/bin/libtool --tag=CC' (or whatever your path is to libtool). This is based off the following messages:
libtool: compile: unable to infer tagged configuration
libtool: compile: specify a tag with `--tag'
If this doesn't work then you'll probably have to edit the Makefile by looking for those specific invocations of libtool and append --tag=CC to them one by one until you're able to progress beyond these errors.
Both solutions are assuming that the only code being compiled is C. To my knowledge, everything in MRI that needs to be compiled is written in C, but if anything is written in C++ then the libtool invocations would require --tag=CXX. You can read more about tags here.

error: /NVIDIA_CUDA-9.0_Samples$ make CUDA-9.1_Samples$ make CUDA-9.2_Samples$ make CUDA-9.3_Samples$ make

I've had CUDA Toolkit 9.0 correctly installed on Ubuntu 16.04 with the package manager-based method since both the two commands
cat /proc/driver/nvidia/version
nvcc -V
returne the right infomation. However, it fails to make correctly when I tried to compile the official example NVIDIA_CUDA-9.0_Samples.
io#msi:~/NVIDIA_CUDA-9.0_Samples$ make
The main output is
/usr/bin/ld: can't find -lcudart
collect2: error: ld returned 1 exit status
Makefile:334: recipe for target 'simpleMPI' failed
make[1]: *** [simpleMPI] Error 1
make[1]: Leaving directory '/home/io/NVIDIA_CUDA-9.0_Samples/0_Simple/simpleMPI'
Makefile:52: recipe for target '0_Simple/simpleMPI/Makefile.ph_build' failed
make: *** [0_Simple/simpleMPI/Makefile.ph_build] Error 2
can anyone give me a hand? Thank you.
I think I've solved this problem. As I mentioned in the question, I've had CUDA Toolkit correctly installed in my computer, but it fails when execute
io#msi:~/NVIDIA_CUDA-9.0_Samples$ make
However, the following two commands
$ ~/NVIDIA_CUDA-9.0_Samples/1_Utilities/deviceQuery/deviceQuery
$ ~/NVIDIA_CUDA-9.0_Samples/1_Utilities/bandwidthTest/bandwidthTest
gives correct response "Result = pass". It's ok to ignore the "make error" listed above- I think.

Xcode project built - Permission denied

I built an Xcode project from CMake and when I attempt to build it I get the following error.
PhaseScriptExecution CMake\ Rules /Users/LaserTech/NewBuild/Myjob2/NameCreate.build/Debug/lsjob2.build/Script-E70CB352E1334BCA9B8BE7C1.sh
cd /Users/LaserTech/NameCreate-OSG-Qt5
/bin/sh -c /Users/LaserTech/NewBuild/Myjob2/NameCreate.build/Debug/Myjob2.build/Script-E70CB352E1334BCA9B8BE7C1.sh
make: *** No rule to make target `/Users/LaserTech/NameCreate-OSG-Qt5/Myjob2/PROTOBUF_PROTOC_EXECUTABLE-NOTFOUND', needed by `/Users/LaserTech/NewBuild/Myjob2/common.pb.cc'. Stop.
Command /bin/sh failed with exit code 2
I am not sure what this means. I would appreciate it if someone could shine some light onto what I should be looking at ?
Update:
I did have thoses packages installed. I needed to simply add the path to the binaries to the environment variable. However now xcode is giving me this
echo "Running C++ protocol buffer compiler on protocol/common.proto"
Running C++ protocol buffer compiler on protocol/common.proto
/Users/..../cmake/osxbuild/Release --cpp_out /Users/..../Myjob2 -I /Users/.../Myjob2/protocol /Users/../Myjob2/protocol/common.proto
make: /Users/.../protobuf/cmake/osxbuild/Release: Permission denied
make: *** [/Users/../NewBuild/Myjob2/common.pb.cc] Error 1

Resources