Go 1.8 plugins, fatal error: stddef.h: No such file - c

Observe:
$ cat /tmp/plugin.go
package main
import "fmt"
var V int
func F() { fmt.Printf("Hello, number %d\n", V) }
$ go build -buildmode=plugin -o /tmp/plugin.so /tmp/plugin.go
# runtime/cgo
cgo-builtin-prolog:1:57: fatal error: stddef.h: No such file or directory
compilation terminated.
Why is that?
This is under Ubuntu 17.04, and I have build-essentials installed:
$ go version
go version go1.9 linux/amd64
$ uname -r
4.10.0-37-generic
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 17.04
Release: 17.04
Codename: zesty
$ apt-cache policy build-essential
build-essential:
Installed: 12.1ubuntu2
Candidate: 12.1ubuntu2
please not the "Compilation error: "stddef.h: No such file or directory"" is NOT the answer as my gcc-core package and gcc-g++ are of the same version -- here are my gcc related packages:
gcc_4:6.3.0-2ubuntu1
gcc-6_6.3.0-12ubuntu2
gcc-6-base:amd64_6.3.0-12ubuntu2
libgcc-6-dev:amd64_6.3.0-12ubuntu2
libgcc1:amd64_1:6.3.0-12ubuntu2
UPDATE:
thanks #peterSO, seems to be my gcc's own problem:
$ cat /tmp/foo.c
#include <stdio.h>
$ gcc /tmp/foo.c
In file included from /tmp/foo.c:1:0:
/usr/include/stdio.h:33:21: fatal error: stddef.h: No such file or directory
# include <stddef.h>
While searching for solution for it, I found someone suggested to reinstall gcc, so I did, together with libc6-dev:
apt-get --reinstall install libgcc-6-dev gcc-6 gcc-6-base:amd64 libc6-dev:amd64
Now my simple .c file compiles OK now, but I'm bumped into a new problem with cgo:
$ go build -buildmode=plugin -o /tmp/plugin.so /tmp/plugin.go
# runtime/cgo
In file included from /usr/include/errno.h:35:0,
from cgo-gcc-prolog:21:
/usr/include/x86_64-linux-gnu/bits/errno.h:24:26: fatal error: linux/errno.h: No such file or directory
# include <linux/errno.h>
^
compilation terminated.
I know this might be a Ubuntu/gcc specific problem (Ref: Why is stddef.h not in /usr/include? and my stddef.h is under /usr/src/linux-headers-4.10.0-37/include/linux/stddef.h), but anybody here knows Go and gcc good enough to know how to fix it, so that Go plugins can be compiled properly?
Thx!

Related

Faulty TensorFlow C install on MacOS?: dyld errors "Library not loaded: #rpath/libtensorflow.1.dylib" and "Symbol not found: __cg_DGifCloseFile"

Question
How should I install the TensorFlow C library on MacOS or otherwise address the errors:
dyld: Library not loaded: #rpath/libtensorflow.1.dylib
Referenced from: /Users/Me/./hello_tf
Reason: image not found
Abort trap: 6
and
dyld: Symbol not found: __cg_DGifCloseFile
Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /usr/local/lib/libGIF.dylib
in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Abort trap: 6
Context
I followed the installation instructions for MacOS using the “macOS CPU only” library verbatim until the sudo ldconfig bit. This being Mac, I substituted update_dyld_shared_cache for ldconfig and restarted, then built the example program provided.
#include <stdio.h>
#include <tensorflow/c/c_api.h>
int main() {
printf("Hello from TensorFlow C library version %s\n", TF_Version());
return 0;
}
I got:
~$ gcc hello_tf.c -ltensorflow -o hello_tf
~$ ./hello_tf
dyld: Library not loaded: #rpath/libtensorflow.1.dylib
Referenced from: /Users/Me/./hello_tf
Reason: image not found
Abort trap: 6
Following the instructions’ advice, I rebuild with gcc -I/usr/local/include -L/usr/local/lib hello_tf.c -ltensorflow -o hello_tf and got the same result.
The installation instructions say to set LIBRARY_PATH and DYLD_LIBRARY_PATH for installs in non-system directories. I decided to give it a shot:
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/lib
Compiling with both methods (that is, without and with -I/usr/local/include -L/usr/local/lib) now give me:
dyld: Symbol not found: __cg_DGifCloseFile
Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /usr/local/lib/libGIF.dylib
in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Abort trap: 6
(Well, at least it’s a different error.)
My /usr/local/lib contains the TensorFlow files:
libtensorflow.1.14.0.dylib
libtensorflow.1.dylib
libtensorflow.dylib
libtensorflow_framework.1.14.0.dylib
libtensorflow_framework.1.dylib
libtensorflow_framework.dylib
libtensorflow.dylib and libtensorflow.1.dylib are links that point to libtensorflow.1.14.0.dylib, and libtensorflow_framework.dylib and libtensorflow_framework.1.dylib likewise point to libtensorflow.1.14.0.dylib, as in the provided .tar.gz archive.
Desired Outcome
The primary desired effect is that the following occurs:
~$ gcc hello_tf.c -ltensorflow -o hello_tf
~$ ./hello_tf
Hello from TensorFlow C library version 1.14.0
(That’s the version I’m using.)
A secondary desired effect is understanding of why the mentioned errors occurred.
I fixed it by installing with Homebrew, adding /usr/local/lib to LD_LIBRARY_PATH, and compiling with the -ltensorflow flag as the last of the GCC arguments. It seems dyld is rather picky; if possible, I’d still like to have a better explanation than that.
~$ brew install libtensorflow
# Homebrew output omitted
~$ export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib"
~$ gcc hello_tf.c -o hello_tf -ltensorflow
~$ ./hello_tf
TensorFlow C lib version 1.14.0
This also didn’t work with the modifications to DYLD_LIBRARY_PATH and LIBRARY_PATH mentioned in the question.
It might be wise to add /usr/local/lib to LD_LIBRARY_PATH in ~/.bash_profile or some build script.

fatal error: omp.h: No such file or directory using arm-unknown-linux-uclibcgnueabi (crosstool-ng)

It seems that any gcc created with crosstool-ng is missing omp.h, is there a way to solve this issue?
tomas#ubuntu:~/eHHAlgorithm/infoli_static$ /home/tomas/x-tools/arm-unknown-linux-uclibcgnueabi/bin/arm-unknown-linux-uclibcgnueabi-gcc infoli.c main.c -o infoli_arm_ns100_ss10_noout_nobench -lm -O3 -DNETWORK_SIZE=100 -DSIMULATION_STEPS=10 -DNO_OUTPUT -DNO_BENCH -static
infoli.c:3:10: fatal error: omp.h: No such file or directory
#include <omp.h>
^~~~~~~
compilation terminated.
If I use arm-linux-gnueabi-gcc, which I installed with apt-get directly in Ubuntu I don't get this error.
Solution:
./ct-ng arm-unknown-linux-uclibcgnueabi
./ct-ng menuconfig -> C compiler -> Compile libgomp (enable pressing < y >). Save changes.
./ct-ng build
This will enable the LIBGOMP option in the .config file:
tomas#ubuntu:~/crosstool-ng$ grep LIBGOMP .config*
.config:CT_CC_GCC_LIBGOMP=y
.config.old:# CT_CC_GCC_LIBGOMP is not set

How fix Error of error of crt1.o,crti.o in Build TinyCCompiler(TCC) from Source?

How fix Error of crt1.o,crti.o in Build TinyCCompiler(TCC) from Source?
https://github.com/LuaDist/tcc
i'm test this at my Desktop system(ubuntu) and also test on server(centos).
at both OS , show error.
Error :
tcc: file '/usr/lib/crt1.o' not found
tcc: file '/usr/lib/crti.o' not found
Details :
guest#Base:~/Gits/tcc-compiler$ ./configure --prefix=build
Binary directory build/bin
TinyCC directory build/lib/tcc
Library directory build/lib
Include directory build/include
Manual directory build/man
Doc directory build/share/doc/tcc
Target root prefix
Source path /home/guest/Gits/tcc-compiler
C compiler gcc
CPU x86-64
Big Endian no
gprof enabled no
cross compilers no
use libgcc no
Creating config.mak and config.h
config.h is unchanged
guest#Base:~/Gits/tcc-compiler$ sudo make
....
....
guest#Base:~/Gits/tcc-compiler$ sudo make install
mkdir -p "build/bin"
install -s -m755 tcc "build/bin"
mkdir -p "build/man/man1"
install tcc.1 "build/man/man1"
mkdir -p "build/lib/tcc"
mkdir -p "build/lib/tcc/include"
install -m644 libtcc1.a "build/lib/tcc"
install -m644 include/stdarg.h include/stddef.h include/stdbool.h include/float.h include/varargs.h include/tcclib.h "build/lib/tcc/include"
mkdir -p "build/share/doc/tcc"
install -m644 tcc-doc.html "build/share/doc/tcc"
mkdir -p "build/lib"
install -m644 libtcc.a "build/lib"
mkdir -p "build/include"
install -m644 libtcc.h "build/include"
guest#Base:~/Gits/tcc-compiler$ cat test2.c
#include <tcclib.h>
int main()
{
printf("Hello World\n");
return 0;
}
Error :
guest#Base:~/Gits/tcc-compiler$ build/bin/tcc test2.c
tcc: file '/usr/lib/crt1.o' not found
tcc: file '/usr/lib/crti.o' not found
$ find /usr/ -name crti*
/usr/mipsel-linux-gnu/lib/crti.o
/usr/lib32/crti.o
/usr/libx32/crti.o
/usr/lib/i386-linux-gnu/crti.o
/usr/lib/x86_64-linux-gnu/crti.o
$ find /usr/ -name crt1*
/usr/mipsel-linux-gnu/lib/crt1.o
/usr/lib32/crt1.o
/usr/libx32/crt1.o
/usr/x86_64-w64-mingw32/lib/crt1.o
/usr/x86_64-w64-mingw32/lib/crt1u.o
/usr/i686-w64-mingw32/lib/crt1.o
/usr/i686-w64-mingw32/lib/crt1u.o
/usr/lib/i386-linux-gnu/crt1.o
/usr/lib/x86_64-linux-gnu/crt1.o
(Full Commands available at https://pastebin.ubuntu.com/26211506/)
how can fix error?
i'm can install tcc using sudo apt install tcc.(without bug and error)
but i want install tcc from source.(this have error)
New Update
in tcc.h file :
#define CONFIG_TCC_CRT_PREFIX CONFIG_SYSROOT "/usr/lib"
i'm change /usr/lib to /usr/lib/x86_64-linux-gnu.
$ build/bin/tcc test.c -run
Hello World
$ /build/bin/tcc test.c
tcc: undefined symbol '__libc_csu_fini'
tcc: undefined symbol '__libc_csu_init'
tcc: undefined symbol '__libc_start_main'
tcc: undefined symbol 'printf'
New Update
#include <tcclib.h>
int main()
{
printf("Hello World\n");
return 0;
}
guest#Base:~/Gits/tcc-try/_build/_install/bin$ ./tcc test.c
test.c:1: include file 'tcclib.h' not found
How fix error of include files not found?!
Related Question : How fix Error of error of include files in TinyCCompiler(TCC)?
The LuaDist project aims to build a complete Lua ecosystem using CMake. So you should use the CMake build system instead of the original makefiles. Typically you would do the following CMake invocation.
$ mkdir _build && cd _build
$ cmake .. -DCMAKE_INSTALL_PREFIX=_install
$ cmake --build . --target install
After this you should have working tcc in _install/bin
Sorry this is not exactly an answer to a question, but initially I had the same problem and this is my solution (Ubuntu 18.04):
git clone https://github.com/TinyCC/tinycc
cd tinycc
./configure
make
make test
cd ..
echo '#include <stdio.h>
int main() {
printf("Hi!\n");
}' > a.c
tinycc/tcc -Btinycc a.c -o a.o
./a.o

MOTIF compiling error / X11/intrinsic.h missing

i have MOTIF installed X11
a easy program is saved as hello.c
there is the following message
where can i get the X11/intrinsic.h , file ???
need help to compile
my system : MX-16 Linux Debian Jessie / i386
Code:
hans#mx1:~/Documents
$ cc push.c -o push -lXm -lXt -lX11
In file included from push.c:2:0:
/usr/include/Xm/Xm.h:59:27: fatal error: X11/Intrinsic.h: No such file or directory
#include <X11/Intrinsic.h>
^
compilation terminated.
hans#mx1:~/Documents
I installed the libxt-dev package on my Debian box:
apt-get install libxt-dev
Then the proper header will be installed:
# find /usr -name "Intrinsic.h" -print
/usr/include/X11/Intrinsic.h
Been using xv for several decades now -- I always find myself trying to rebuild it.
The copy on my system came from libxt-dev
$ locate Intrinsic
/usr/include/X11/Intrinsic.h
/usr/include/X11/IntrinsicI.h
/usr/include/X11/IntrinsicP.h
$ dpkg-query -S /usr/include/X11/Intrinsic.h
libxt-dev:amd64: /usr/include/X11/Intrinsic.h
You may want to install and use apt-file - you can ask it for a filename and it will tell you which packages (that you don't even have to have installed - just from the repos in your sources.lists) contain a file with that name

Pkg-config file is on the pkg-config path but can not be found by configure script

I am trying to install libvirt from source. The version I am trying to install is 1.2.7. I want libssh2 enabled. Here is how I call the configure script:
./configure --prefix=/home/administrator/dev/workspaces/libvirt/built/libvirt-1.2.7/ --with-sasl --with-qemu --with-lxc --with-gnutls --with-remote --with-ssh2 --with-polkit
I got the following error:
configure: error: You must install the libssh2 >= 1.3 pkg-config module to compile libvirt
I downloaded the libssh2 lib version 1.4.3 and installed it using the default options:
$ ./configure
$ make
$ sudo make install
Here is some useful info:
$ sudo ldconfig
$ sudo updatedb
$ locate libssh2.so
/usr/local/lib/libssh2.so
/usr/local/lib/libssh2.so.1
/usr/local/lib/libssh2.so.1.0.1
$ locate libssh2.pc
/usr/local/lib/pkgconfig/libssh2.pc
$ pkg-config --variable pc_path pkg-config
/usr/local/lib/x86_64-linux-gnu/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
Obviously the libssh2.pc file is on the pkg-config path. However, when I tried executing the configure script for libvirt, the same error occurred. Any ideas what I am doing wrong ? Thank you.
EDIT: Fragment of the config.log file:
34475 configure:59141: checking for SSH2
34476 configure:59148: $PKG_CONFIG --exists --print-errors "libssh2 >= 1.3"
34477 configure:59151: $? = 0
34478 configure:59165: $PKG_CONFIG --exists --print-errors "libssh2 >= 1.3"
34479 configure:59168: $? = 0
34480 configure:59182: result: no
34481 Package libssl was not found in the pkg-config search path.
34482 Perhaps you should add the directory containing `libssl.pc'
34483 to the PKG_CONFIG_PATH environment variable
34484 Package 'libssl', required by 'libssh2', not found
34485 configure:59225: error: You must install the libssh2 >= 1.3 pkg-config module to compile libvirt
...
34576 ac_cv_env_PKG_CONFIG_LIBDIR_set=
34577 ac_cv_env_PKG_CONFIG_LIBDIR_value=
34578 ac_cv_env_PKG_CONFIG_PATH_set=
34579 ac_cv_env_PKG_CONFIG_PATH_value=
34580 ac_cv_env_PKG_CONFIG_set=
34581 ac_cv_env_PKG_CONFIG_value=
...
34874 ac_cv_path_ac_pt_PKG_CONFIG=/usr/bin/pkg-config
36432 PKG_CONFIG='/usr/bin/pkg-config'
36433 PKG_CONFIG_LIBDIR=''
36434 PKG_CONFIG_PATH=''

Resources