I am facing an error while running simple go code - rest

I am trying to run a simple go code
package main
import (
"log"
"net/http"
"fmt"
)
func homePage(w http.ResponseWriter, r *http.Request) {
}
func handleRequest() {
http.HandleFunc("/", homePage)
log.Fatal(http.ListenAndServe(":8081", nil))
}
func main() {
handleRequest()
}
Go version : go1.17.5 darwin/arm64
macOs : monterey 12.1
Error Message:
# runtime/cgo
ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd' for architecture arm64
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)

Following commands helped me. Try to reinstall Xcode command-line tools and upgrade llvm and gcc.
$ brew upgrade llvm
$ brew upgrade gcc
$ sudo rm -rf /Library/Developer/CommandLineTools
$ xcode-select --install

Related

Cannot install Cocoapods, keep getting error

I have been trying to install cocoapods but I keep getting an error. I have tried the following commands and get the same result.
sudo gem install cocoapods
sudo gem install -n /usr/local/bin cocoapods
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20200726-37338-rvqxhv.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/include/ruby.h
You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/ffi-1.13.1/gem_make.out
After a lot of searching I finally came across a solution that I believe works. If you are use Mac OS Catalina you need to use Brew.
Open Terminal on your Mac.
Now, run
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
Install cocoapods using brew
brew install cocoapods
cocoapods is ready to use now!

xcrun: error: unable to find utility "xctest", not a developer tool or in PATH

I am using Xcode command line tools instead of XCode app in my MAC.
When i use swift --version
I get Apple Swift version 5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51)
I cloned a project with
git clone https://github.com/apple/example-package-dealer.git
cd example-package-dealer
swift run Dealer
I gives me this error:
error: terminated(72): OLDPWD=/Users/sayansen/Work/EdgeAnalytics/Trial TERM_PROGRAM=Apple_Terminal PWD=/Users/sayansen/Work/EdgeAnalytics/Trial/example-package-dealer SHLVL=1 SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.9lwBmlYTAx/Listeners HOME=/Users/sayansen LIBRARY_PATH=/usr/local/lib __CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0 XPC_SERVICE_NAME=0 TMPDIR=/var/folders/kn/v4zm474x52n8zrycxs7nh5c40000gn/T/ LOGNAME=sayansen SHELL=/bin/bash TERM_PROGRAM_VERSION=433 _=/usr/bin/swift PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS CPATH=/usr/local/include SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk XPC_FLAGS=0x0 TERM=xterm-256color USER=sayansen LC_CTYPE=UTF-8 TERM_SESSION_ID=B285E686-2802-48C6-B8CE-03CA8F2314BF xcrun --sdk macosx --find xctest output:
xcrun: error: unable to find utility "xctest", not a developer tool or in PATH
I am not using XCODE.
I already did this:
sudo xcode-select -s /Library/Developer/CommandLineTools
But not helpfull.
How to solve this error without installing XCode?
Assuming you already have Xcode installed:
Start Xcode, select "Preferences -> Locations". Chances are that your Command Line Tools are not set. Select the suggested Xcode-tools location and you are done.
Additional:
You could check with:
xcode-select -p
which tools are set, mine showed:
/Library/Developer/CommandLineTools
After the location in the preferences was set, it showed:
/Applications/Xcode.app/Contents/Developer
(as it should)
Xcode -> Preferences (or command+,)
Locations tab -> Command Line tools section:
Select a tool there and you are done.
Just a wrong path, all the stuff still can be done w/o invoking GUI:
~/% sudo xcode-select -s /Library/Developer/CommandLineTools
~/% sudo xcode-select -p
/Library/Developer/CommandLineTools
~/% sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
~/% sudo xcode-select -p
/Applications/Xcode.app/Contents/Developer
The latest -s command fixes xcrun: error: unable to find utility "xctest" …

/usr/bin/ld: cannot find -lstdc++ for Ubuntu while trying to "swift build" Perfect2 project

Description:
I've followed the installation steps for Swift3 and Perfect2
and I've cloned the PerfectTemplate test project proposed by Perfect and I've tried swift build
Error Message:
warning: minimum recommended clang is version 3.6, otherwise you may
encounter linker errors. Linking ./.build/debug/PerfectTemplate
/usr/bin/ld: cannot find -lstdc++ clang: error: linker command failed
with exit code 1 (use -v to see invocation) :0: error: link
command failed with exit code 1 (use -v to see invocation)
:0: error: build had 1 command failures error: exit(1):
/etc/swift301/usr/bin/swift-build-tool -f
/home/XXXX/ClionProjects/PerfectTemplate/.build/debug.yaml
What I've tried:
I've gone on different SO questions that seemed similar but all on different projects and attempted to try their solutions without luck:
For example:
Matlab Kalman /usr/bin/ld: cannot find -lstdc++
I also noticed the warning coming from the clang version, I am aware that my current version is 3.4, but that is what was installed via sudo apt-get install clang as mentioned in the documentation.
I've also tried installing the 3.6 version of clang with: sudo apt-get install clang-3.n
However, after when I try swift build again I get the following error:
error: invalid inferred toolchain: could not find clang
Question:
How do I get rid of the /usr/bin/ld: cannot find -lstdc++ error, so I can build the PerfectTemplate project?
Try this. It might not work, but it's worth a shot.
Update packages and dependencies:
sudo apt-get update
Then install clang 3.6:
sudo apt-get install clang-3.6
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.6 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.6 100
I hope this helps, but apologies if it doesn't. Best of luck!
If this error appears:
/usr/bin/ld.gold: error: cannot open
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../libstdc++.‌​so: No
such file or directory
It's most likely that the libstdc++.so symbolic link points to an inexisting file.
In my case it was pointing to:
/usr/lib/libstdc++.so -> /usr/lib/libstdc++.so.6
Which was incorrect because libstdc++.so.6 did not exist in that area. Simply find it's location via: sudo find / -name libstdc++.so.6 which gave me:
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
Then recreate the link with:
sudo rm /usr/lib/libstdc++.so
sudo ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib/libstdc++.so
sudo apt-get install build-essential
I faced with same problem and update-alternatives didn't help me, but after
sudo apt-get update && sudo apt-get upgrade
swift build ran successfully. Looks like some dependencies were deprecated.

Error with swift installation in ubuntu 14.04

I created a new project in ubuntu, with only the main.swift, with a simple print(hello world) and display this error.
guillermo#guillermo-Latitude-E6440:~/Descargas/Hola3$ swift build
Linking Executable: .build/debug/Hola3
/usr/bin/ld: cannot find crtbegin.o: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: build had 1 command failures
error: exit(1): ["/home/guillermo/Descargas/swift-DEVELOPMENT-SNAPSHOT-2016-01-25-a-ubuntu14.04/usr/bin/swift-build-tool", "-f", "/home/guillermo/Descargas/Hola3/.build/debug/Hola3.o/llbuild.yaml"]
You need the libgcc-*-dev package that provides crtbegin.o and a few other important libraries and object files vital to building programs on Ubuntu. For example, on Ubuntu 14.04 it would be libgcc-4.8-dev. The package should be installed if you install the gcc package:
apt-get install gcc

linking to python library using EPD Canopy

Summary: I'm trying to install the theano python package, and the theano install can't find "-lpython2.7" in my EPD Canopy installation.
More details: Recently I installed the Enthought EPD Canopy python distribution (64-bit academic) in OS X 10.6.8. Next I installed pip via "easy_install pip".
Next I installed Theano via "sudo pip install theano". The install looks OK, but then python -c "import theano" fails. The full output is at https://gist.github.com/anonymous/5548936, but it seems like the main point is:
Problem occurred during compilation with the command line below:
g++ -dynamiclib -g -D NPY_ARRAY_ENSURECOPY=NPY_ENSURECOPY -D NPY_ARRAY_ALIGNED=NPY_ALIGNED -D NPY_ARRAY_WRITEABLE=NPY_WRITEABLE -D NPY_ARRAY_UPDATE_ALL=NPY_UPDATE_ALL -D NPY_ARRAY_C_CONTIGUOUS=NPY_C_CONTIGUOUS -D NPY_ARRAY_F_CONTIGUOUS=NPY_F_CONTIGUOUS -fPIC -undefined dynamic_lookup -m64 -I/Users/rkeisler/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/core/include -I/Applications/Canopy.app/appdata/canopy-1.0.0.1160.macosx-x86_64/Canopy.app/Contents/include/python2.7 -o /Users/rkeisler/.theano/compiledir_Darwin-10.8.0-x86_64-i386-64bit-i386-2.7.3/lazylinker_ext/lazylinker_ext.so /Users/rkeisler/.theano/compiledir_Darwin-10.8.0-x86_64-i386-64bit-i386-2.7.3/lazylinker_ext/mod.cpp -L/Applications/Canopy.app/appdata/canopy-1.0.0.1160.macosx-x86_64/Canopy.app/Contents/lib -lpython2.7
===============================
ld: library not found for -lpython2.7
collect2: ld returned 1 exit status
I've had some discussions with the theano google group, and the main message I get is to look for "libpython2.7.so", which I can't find. I checked /Users/rkeisler/Library/Enthought/Canopy_64bit/User/lib/. Inside is python2.7/os.py and python2.7/site-packages, but no "libpython*" files.
I also did a more thorough check for libpython* files. The only things I could find were:
/usr/lib/python2.5/config/libpython2.5.a
/usr/lib/python2.6/config/libpython2.6.a
/usr/lib/libpython.dylib
/usr/lib/libpython2.5.dylib
/usr/lib/libpython2.6.dylib
Finally, on the EPD Canopy package list, I see "libpython" listed. However, when I try to install libpython using the Canopy package manager, "libpython" doesn't appear. It's not an available package. I'm not sure where to go from here.
Following #RobertKern# information, it is now fixed in the development version of Theano.
To update to the development version, do:
pip -U --no-deps git+git://github.com/Theano/Theano.git