While building gcc, I get this error:
In file included from /usr/include/bits/errno.h:25,
from /usr/include/errno.h:36,
from ../.././gcc/tsystem.h:96,
from ../.././gcc/crtstuff.c:68:
/usr/include/linux/errno.h:4:23: error: asm/errno.h: No such file or directory
make[2]: *** [crtbegin.o] Error 1
make[2]: Leaving directory `/opt/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc'
I am building gcc 4.1 from source. I think I have to install build-essential. However installing that package in ubuntu 12.04 will automatically download and install gcc 4.6 and I don't want that.
Is there any other way?
I think the package you want is linux-libc-dev . I encountered this when building 32-on-64; so I needed linux-libc-dev:i386 .
This worked for me:
ln -s /usr/include/asm-generic /usr/include/asm
This worked for me:
sudo ln -s /usr/include/asm-generic /usr/include/asm
The reason being that what GCC expects to be called /usr/include/asm is renamed to /usr/include/asm-generic in some distros.
This fixed it for me.
sudo apt-get install linux-libc-dev:i386
This solved it for me on Debian 10, even though I was compiling with an LLVM-based compiler:
sudo apt install gcc-multilib
/usr/include/asm/errno.h is part of the linux headers. I can't speak directly to Ubuntu 12.04, but in general you can download the linux sources as a package for your distro and it shouldn't require you to download/install gcc. Failing that, you can manually download the linux headers for the version of your kernel (uname -a) and use an include directive to CFLAGS to specify the directory to look for those.
Edit: sudo apt-get install linux-headers-generic may work for you.
You are missing part of the development packages. I don't know Ubuntu, but you should be able to ask it's package management system to install the package containing /usr/include/asm/errno.h.
Do not copy some file with a similar name from somewhere on your system (or, even worse, from somewhere else). Missing files might mean that some package is damaged; again, ask your package manager to check everything and (re)install missing/broken pieces.
Unless you are running some LTS release, upgrade. Your Ubuntu is some 2 years old, i.e., ancient.
While we are at this, why on this beautiful planet are you building such an ancient compiler? Current GCC is just released 4.9.0, anything before 4.7 is ancient history, not longer supported.
On Ubuntu 16.04 x86_64 you could try this:
ln -s /usr/include/x86_64-linux-gnu/asm /usr/include/asm
This works on my server.
If you want to use errno.h that is in the asm file, simply go to /usr/(ctrl + l, type /usr/) and then search for errno.h and errno-base.h. Once you did find them, copy the code in these two files, and place them in your include folder. And be careful, in "errno.h" the file includes "errno-base.h" as:
#include <asm-generic/errno-base.h>
Either create a directory with the same name above or change the code above to something different which is suitable for you to use.
If you can find:
usr/include/asm-generic/errno.h
by executing:
find /usr/include -name errno.h
then try to execute:
cp --archive /usr/include/asm-generic /usr/include/asm
It may fix that problem.
I had this issue while compiling Asterisk 1.8.24.0 and solved it with:
mkdir /usr/include/asm-generic
cp /usr/include/asm/errno-base.h /usr/include/asm-generic/
Don't know if it is the "right way" but i've read the comments above and that gave me the idea... and it worked :)
Related
I have a problem using Paho MQTT client in C.
I downloaded the pre built binaries for my system (Windows 10 64) from their projects page. I unpacked the zip file to a folder in the documents folder, where I also created a .c file with the example at the bottom of the Paho product page. My editor is atom and my compiler is gcc.
When I tried to compile it in Atom, I got this error:
undefined reference to MQTTClient_create'
So I went searching and found plenty of topics, but I still couldn't figure out, how to resolve this issue. From this stackoverflow topic I gather that it's a linker problem and that I need to link the files during compile, so here's what I tried:
gcc MQTT.c -L "C:\Users\Pete\Documents\MQTT on C\Examples\Paho\lib" -l paho-mqtt3c
Which still gives me the same undefined reference error. When I try to link to the dll of the same name, the compiler does not find the file.
Can anyone point me in the right direction, please?
Any help is appreciated!
I'd be interested to know if you have registered the Paho MQTT dll in Windows?
You should have paho-mqtt3c.dll as part of the download.
I don't know if this will work for you, but I have the same issue (undefined reference to MQTTClient_create)...
Copy the dll file into c:/windows/system32
Run CMD Prompt as Administrator and type:
regsvr32 i/ paho-mqtt3c.dll
Worth a try.
The problem was that I was compiling the program with the 32-bit gcc compiler for the 64-bit library. Installing and using MinGW64 worked.
I had the same issue in OS X. This is how I resolved it
I compiled the paho-mqtt library in Linux/EC2 instance.
Installed all the dependencies:
sudo yum install install build-essential gcc make cmake cmake-gui cmake-curses-gui
sudo yum install cmake
sudo yum install doxygen graphviz
cmake -DPAHO_WITH_SSL=TRUE -DPAHO_BUILD_DOCUMENTATION=FALSE -DPAHO_BUILD_STATIC=TRUE -DPAHO_BUILD_SHARED=FALSE -DPAHO_MQTT_C_PATH=../paho.mqtt.c/ -DPAHO_MQTT_C_LIB=../paho.mqtt.c/src/libpaho.mqtt3as-static.a
make
make html
make install
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/ec2-user/paho.mqtt.c/src
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH
sudo ldconfig
gcc test1.c -o test1 -lpaho-mqtt3c
Compiled successfully..
./test1
This solution works for OS X as well. Replace step 2 with
brew install cmake doxygen openssl-devel
Working with embedded C-projects. There are libraries, include files and so on - for micro controllers. No need for me to use GCC for a host machine and OS (Linux Mint 64 bit). As a rule...
But now I'm trying to compile mspdebug project from a Github - with a GCC of course. And I get an error at the very begin of make:
mspdebug$ make
cc -DUSE_READLINE -O1 -Wall -Wno-char-subscripts -ggdb -I. -Isimio -Iformats -Itransport -Idrivers -Iutil -Iui -DLIB_DIR=\"/usr/local/lib/\" -o util/btree.o -c util/btree.c
util/btree.c:19:20: fatal error: assert.h: No such file or directory
#include <assert.h>
^
compilation terminated.
I search for the includes in all possible paths (I've got the list of them via gcc -v command) - there are no assert.h file, as well, as stdio.h and so on. Except virtual box directories there is only one place (where GCC does not search includes): /usr/lib/syslinux/com32/include
AFAIK, all standard libs and includes are installed with the GCC. So I try to reinstall GCC (4.8.4) - nothing changes.
What is the normal way to give GCC all standard environment it needs?
Thanks to the right direction set by Sam Varshavchik I found the info in the stackoverflow. So I did the following:
1) installed build-essential:
sudo apt-get install build-essential
2) installed libusb (since my try to build the package revealed the absence of usb.h):
sudo apt-get install libusb-dev
And it is OK! The mspdebug (v.023) is compiled and successfully tested!
So, Linux Mint 17.2 (at least) requires installing some libs to a GCC, the most basic is build-essential.
assert.h is not part of gcc, it's a part of glibc.
Most likely, your Linux distribution puts the system headers into a separate package that you need to install.
Fedora, for examples, puts the header files in the glibc-headers package. However, you can't be using Fedora, because Fedora's gcc package has a dependency on glibc-headers, to make sure that it gets pulled in.
Whatever Linux distribution you're using, you need to research which distribution package will install the system header files you need to build stuff with.
I am totally new to swift. It has just been released as open source for linux and I wanted to try it. This is on ubuntu 14.04. clang is installed as per prerequisites.
<Edit>: requirements here request clang version 3.6 also on ubuntu 14.04. I had first tried these first steps with clang 3.4, but have since updated to 3.6 following the instructions in the link and retried. Same result.</Edit>
I have downloaded https://swift.org/builds/ubuntu1404/swift-2.2-SNAPSHOT-2015-12-01-b/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04.tar.gz to ~/Downloads/. Transcript of installation and first step in swift:
$ cd /tmp
$ tar xf ~/Downloads/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04.tar.gz
$ PATH=/tmp/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/bin/:"$PATH"
$ clang++ --version
Ubuntu clang version 3.6.0-2ubuntu1~trusty1 (tags/RELEASE_360/final) (based on LLVM 3.6.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ which swift
/tmp/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/bin//swift
$ swift --version
Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift 778f82939c)
Target: x86_64-unknown-linux-gnu
$ swift
Welcome to Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift 778f82939c). Type :help for assistance.
1> 1 + 2
opening import file for module 'SwiftShims': No such file or directory
1>
According to this getting started guide it should have printed instead
$R0: Int = 3
What's wrong and how can I fix it?
Edit: Trying to find that file manually: It is apparently not contained in the installation:
$ find swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/ | grep -i shims
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/FoundationShims.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/SwiftStddef.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/module.map
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/UnicodeShims.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/GlobalObjects.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/HeapObject.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/RuntimeShims.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/RefCount.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/RuntimeStubs.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/LibcShims.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/CoreFoundationShims.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/SwiftStdint.h
Edit: When I try the swift build helloworld example, this output is produced:
/tmp/Hello$ swift build
<unknown>:0: error: opening import file for module 'Swift': No such file or directory
swift-build: exit(1): ["/tmp/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/bin/swiftc", "--driver-mode=swift", "-I", "/tmp/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/pm", "-L", "/tmp/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/pm", "-lPackageDescription", "/tmp/Hello/Package.swift"]
Edit: new findings up to 2015-12-22
Since I posted this question, at least two more snapshots of swift for linux have been released: 2015-12-10 and 2015-12-18. I have tried these, but they do not fix the issue.
This mailing list thread here (post 1, post 2, post 3) is about the same problem. It was suggested there that installation of swift under the home directory would help. It did not help in my case, the error message is still the same.
More interestingly, that mailing list thread contains an analysis of the REPL error created with strace. It would be interesting to compare that particular strace output with the strace output from a system where REPL works.
Edit: More info up to 2015-12-26:
A new swift release is out, dated 2015-12-22. This release exhibits the same problem.
Another thread concerning this problem has appeared on the swift mailing list starting here. The user experiencing the problem has also posted strace output here.
I had the exact same problem. It turns out that I had added the ppa:ubuntu-toolchain-r/test repo in order to install g++-4.9 on my Mint distro (17.2). Once I purged the repository and restored various libraries to their original versions, swift finally worked for me.
Specifically, I had to run
sudo apt-get install ppa-purge
sudo ppa-purge -d trusty ppa:ubuntu-toolchain-r/test
While cleaning up, ppa-purge was complaining that in order to resolve conflicts, it would have to remove quite a few packages it could not find in the Ubuntu Trusty repo (including really core ones like build-essential, xorg, gcc, x11-xserver-utils...), so I made a note and reinstalled these right away after the purge. Just be very careful.
I think some of the libraries overridden when installing g++ 4.9 were creating a conflict. I've verified all this on a fresh Mint install too.
This is not really an answer -- I have the same problem as OP -- but SwiftShims is actually defined the module.map file in your file listing above:
module SwiftShims {
header "CoreFoundationShims.h"
header "FoundationShims.h"
header "GlobalObjects.h"
header "HeapObject.h"
header "LibcShims.h"
header "RefCount.h"
header "RuntimeShims.h"
header "RuntimeStubs.h"
header "SwiftStddef.h"
header "SwiftStdint.h"
header "UnicodeShims.h"
export *
}
https://github.com/apple/swift/blob/8d9ef80304d7b36e13619ea50e6e76f3ec9221ba/stdlib/public/SwiftShims/module.map
I repeated the same steps as you described on a brand-new Ubuntu 14.04 Azure VM and got the expected
$R0: Int = 3
Interestingly, it worked fine even without Clang or GCC! Later I installed Clang-3.5, and it worked as well.
Is it possible that they have sneaked in a new tarball with the same name? The MD5 hash of the one I got is here:
user#ubuntu1:/tmp/junk$ md5sum swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04.tar.gz
a93f52921c491b747cad256904c8742f swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04.tar.gz
Does yours match? If so, you may want to try a different installation of Ubuntu 14.04 if you have access to one.
I have also been able to successfully use swift build as instructed in https://swift.org/getting-started/#using-the-build-system . Removing the clang-3.5 package broke swift build, just as I had suspected, but REPL swift still worked as it did originally, before installing Clang for the first time. Then I installed Clang-3.4, and swift build was back in business.
Update 1/3/2016:
Using the hints from the various comments on this question, I've been able to reproduce the error on my Ubuntu 14.04 Azure VM. As an alternative solution, the problem can also be addressed by manipulating $LD_LIBRARY_PATH, see Unable to compile "hello world" program with Swift on Ubuntu 14.04.
Had the same issue, what I missed was that I didn't get the keys for the package and verify it before extracting.
Download the package
wget -q -O - https://swift.org/keys/all-keys.asc | gpg --import
gpg --keyserver hkp://pool.sks-keyservers.net --refresh-keys Swift
gpg --verify swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04.tar.gz.sig
tar xzf swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04.tar.gz
add PATH=/path/to/usr/bin:"${PATH}" to your .bashrc
finally run swift
You should see:
Welcome to Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift 778f82939c). Type :help for assistance.
1> 1+1
$R0: Int = 2
Following the advice of James D, I tried to run
sudo apt-get install ppa-purge
sudo ppa-purge -d trusty ppa:ubuntu-toolchain-r/test
However, this did not work. What's strange, is that what did work doesn't make sense. For me, I got it working by installing the above ppa first and then purging it. The whole command set that got me working was
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.9 # This step may be optional
sudo apt-get install ppa-purge
sudo ppa-purge -d trusty ppa:ubuntu-toolchain-r/test
I am using Linux Mint and I installed clang_complete using the makefile from Clang Complete, but it does not work. When I open a cpp file, there is an error message:
Loading libclang failed, completion won't be available. Consider setting g:clang_library_path
I already did some research on this topic and tried to find the libclang.so file to put g:clang_library_path= '...' into my vimrc, but I cannot find the file so I cannot define the path in my vimrc.
$ find / -name libclang -type f 2> /dev/null doesn't return anything.
How do I make clang_complete work?
You probably have libclang.so.1 in /usr/lib/x86_64-unknown-linux or somewhere similar. Make a symbolic link named as libclang.so in any of your library path would solve the problem (at least for me).
cd /usr/lib/x86_64-unknown-linux
ln -s libclang.so.1 libclang.so
You need to install libclang. On my Ubuntu system it is in the "libclang1" package. Clang compiler and libclang are in different packages.
I ran into this issue with Ubuntu 20.04.3 LTS:
Loading libclang failed, completion won't be available. Are you sure '/usr/lib/x86_64-linux-gnu/libclang-6.0.so.1' contains libclang?
I fixed it using:
Install libclang
sudo apt install clang
Add following in .vimrc to use latest installed libclang
let g:clang_library_path = '/usr/lib/x86_64-linux-gnu/libclang-10.so.1'
If needed, adjust "libclang-10.so.1" to use the clang version that was installed.
You should be good with Vim at this point.
In $clang_complete/plugin/libclang.py, there is a code like this:
debug = int(vim.eval("g:clang_debug")) == 1
So use let g:clang_debug=1 to enable clang debug.
For me, the error is:
/lib64/libstdc++.so.6: version 'GLIBCCC_3.x.xx' not found
Set LD_LIBRARY_PATH and PKG_CONFIG_PATH to a third libstdc++ will solve this.
I am trying to compile a library using android-ndk-r5 standalone toolchain and autotools. When doing a ./configure, it fails with:
$ ./configure --host=arm-linux-androideabi
...snip...
checking host system type... Invalid configuration `arm-linux-androideabi': system `androideabi' not recognized
configure: error: /bin/sh ./config.sub arm-linux-androideabi failed
Explicitly setting CC and CXX does not work either (configure says to use --host).
The NDK docs and various materials online seems to indicate that using the standalone toolchain in this manner should be possible. What is wrong here? and how can I resolve it? (besides simply ditching autoconf and going back to Android.mk)
You might need a newer config.sub and config.guess, 2010-05-20 or later.
You can get the newer config.sub and config.guess from here
I took the newest from both, but that lead to errors, so I took the mentioned ones of Peter Eisentraut's date.
You can also grab config.sub and config.guess from the Ubuntu autotools-dev package:
sudo apt-get install autotools-dev
cp /usr/share/misc/config.{sub,guess} .