libc.h: No such file or directory when compiling nanomsg pipeline sample
Asked Answered
B

2

6

Trying to get a simple nanomsg file running, starting with the first one here: https://github.com/dysinger/nanomsg-examples

Installed nanomsg to /usr/local/lib/nanomsg-0.2-alpha. Ran sudo ./configure, sudo make check, sudo make install and sudo ldconfig as the instructions said. All tests pass.

When I run it says libc.h is not found:

$ gcc pipeline.c /usr/local/lib/libnanomsg.a -o pipeline
pipeline.c:2:18: fatal error: libc.h: No such file or directory
compilation terminated.

What is libc.h? I haven't done any C programming since college. Is it part of nanomsg or a C library?

$ which gcc
/usr/bin/gcc
Ubuntu 12.04.4 LTS
Backdate answered 14/2, 2014 at 0:26 Comment(0)
E
7

Libc.h just contains small list of includes. To compile nanomsg sample its enough to (src):

Replacing:

#include <libc.h> 

with

#include <unistd.h>
#include <string.h>
#include <pthread.h>

I used this cmd for static compilation:

gcc -pthread bus.c ../nanomsg/.libs/libnanomsg.a -o test -lanl

Note -pthread and -lanl at the end of line.

Engels answered 5/12, 2014 at 18:53 Comment(1)
This worked well, however note that I needed to run ./configure --enable-static when building nanomsg to get this to work properly, otherwise there were missing symbols in libnanomsg.a.Sheepdog
A
1

try the following:

$ sudo updatedb
$ locate libc.h

find the path where libc.h located. eg, if your libc.h is /usr/local/include

gcc -I/usr/local/include pipeline.c /usr/local/lib/libnanomsg.a -o pipeline
Affixation answered 14/2, 2014 at 8:17 Comment(1)
Well, that helped but now I've got a bunch of these: /usr/local/go/include/../src/lib9/utf/utf.h:46:1: error: expected identifier or ‘(’ before ‘/’ token and so on.Backdate

© 2022 - 2024 — McMap. All rights reserved.