Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux complie problem. #2

Closed
zh794390558 opened this issue Aug 22, 2016 · 6 comments
Closed

Linux complie problem. #2

zh794390558 opened this issue Aug 22, 2016 · 6 comments

Comments

@zh794390558
Copy link

root@ubuntu:/libraries# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1
14.04.3' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)

root@ubuntu:~/libraries# ./build.sh
==== clean linux libmacro done.
==== clean linux libatomic done.
==== clean linux libtime done.
==== clean linux liblog done.
==== clean linux libgevent done.
==== clean linux libworkq done.
==== clean linux libdict done.
==== clean linux libsort done.
==== clean linux librbtree done.
==== clean linux libringbuffer done.
==== clean linux liblock done.
==== clean linux libthread done.
==== clean linux libconfig done.
==== clean linux libosal done.
==== clean linux libvector done.
==== clean linux libdebug done.
==== clean linux libfile done.
==== clean linux libskt done.
==== clean linux libstun done.
==== clean linux libptcp done.
==== clean linux librpc done.
==== clean linux libp2p done.
==== clean linux libipc done.
==== build linux libmacro done.
==== build linux libatomic done.
==== build linux libtime done.
==== build linux liblog done.
==== build linux libgevent done.
==== build linux libworkq done.
==== build linux libdict done.
==== build linux libsort done.
==== build linux librbtree done.
==== build linux libringbuffer done.
test_liblock.c: In function ‘print_mutex_lock’:
test_liblock.c:45:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (uint64_t i = 0; i < n; ++ i) {
^
test_liblock.c:45:5: note: use option -std=c99 or -std=gnu99 to compile your code
test_liblock.c: In function ‘print_spin_lock’:
test_liblock.c:72:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (uint64_t i = 0; i < n; ++ i) {
^
make: *** [test_liblock.o] Error 1
==== build linux liblock failed
In file included from libthread.c:13:0:
libthread.h:14:21: fatal error: liblock.h: No such file or directory
#include <liblock.h>
^
compilation terminated.
make: *** [libthread.o] Error 1
==== build linux libthread failed
Package lua5.2 was not found in the pkg-config search path.
Perhaps you should add the directory containing lua5.2.pc' to the PKG_CONFIG_PATH environment variable No package 'lua5.2' found Package lua5.2 was not found in the pkg-config search path. Perhaps you should add the directory containinglua5.2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lua5.2' found
Package lua5.2 was not found in the pkg-config search path.
Perhaps you should add the directory containing lua5.2.pc' to the PKG_CONFIG_PATH environment variable No package 'lua5.2' found Package lua5.2 was not found in the pkg-config search path. Perhaps you should add the directory containinglua5.2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lua5.2' found
Package lua5.2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `lua5.2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lua5.2' found
json/json_config.c:8:21: fatal error: jansson.h: No such file or directory
#include <jansson.h>
^
compilation terminated.
make: *** [json/json_config.o] Error 1
==== build linux libconfig failed
==== build linux libosal done.
==== build linux libvector done.
libdebug.c: In function ‘debug_backtrace_init’:
libdebug.c:121:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (uint32_t i = 0; i < (sizeof(signum) / sizeof(uint32_t)); ++i) {
^
libdebug.c:121:5: note: use option -std=c99 or -std=gnu99 to compile your code
make: *** [libdebug.o] Error 1
==== build linux libdebug failed
==== build linux libfile done.
test_libskt.c:17:23: fatal error: libthread.h: No such file or directory
#include <libthread.h>
^
compilation terminated.
make: *** [test_libskt.o] Error 1
==== build linux libskt failed
==== build linux libstun done.
==== build linux libptcp done.
librpc.c:15:20: fatal error: libskt.h: No such file or directory
#include <libskt.h>
^
compilation terminated.
make: *** [librpc.o] Error 1
==== build linux librpc failed
libp2p.c:21:20: fatal error: libskt.h: No such file or directory
#include <libskt.h>
^
compilation terminated.
make: *** [libp2p.o] Error 1
==== build linux libp2p failed
netlink.c:20:23: fatal error: libthread.h: No such file or directory
#include <libthread.h>
^
compilation terminated.
make: *** [netlink.o] Error 1
==== build linux libipc failed

@zh794390558
Copy link
Author

The library has depending on glibc libraries, and does this is your original intention?

root@ubuntu:~/libraries# ./build.sh
==== clean linux libmacro done.
==== clean linux libatomic done.
==== clean linux libtime done.
==== clean linux liblog done.
==== clean linux libgevent done.
==== clean linux libworkq done.
==== clean linux libdict done.
==== clean linux libsort done.
==== clean linux librbtree done.
==== clean linux libringbuffer done.
==== clean linux liblock done.
==== clean linux libthread done.
==== clean linux libconfig done.
==== clean linux libosal done.
==== clean linux libvector done.
==== clean linux libdebug done.
==== clean linux libfile done.
==== clean linux libskt done.
==== clean linux libstun done.
==== clean linux libptcp done.
==== clean linux librpc done.
==== clean linux libp2p done.
==== clean linux libipc done.
==== build linux libmacro done.
==== build linux libatomic done.
==== build linux libtime done.
==== build linux liblog done.
==== build linux libgevent done.
==== build linux libworkq done.
==== build linux libdict done.
==== build linux libsort done.
==== build linux librbtree done.
==== build linux libringbuffer done.
liblock.c: In function ‘mutex_cond_wait’:
liblock.c:236:9: error: implicit declaration of function ‘clock_gettime’ [-Werror=implicit-function-declaration]
clock_gettime(CLOCK_REALTIME, &ts);
^
liblock.c:236:23: error: ‘CLOCK_REALTIME’ undeclared (first use in this function)
clock_gettime(CLOCK_REALTIME, &ts);
^
liblock.c:236:23: note: each undeclared identifier is reported only once for each function it appears in
liblock.c: In function ‘rwlock_init’:
liblock.c:287:5: error: unknown type name ‘pthread_rwlock_t’
pthread_rwlock_t lock = (pthread_rwlock_t *)calloc(1,
^
liblock.c:287:31: error: ‘pthread_rwlock_t’ undeclared (first use in this function)
pthread_rwlock_t *lock = (pthread_rwlock_t *)calloc(1,
^
liblock.c:287:49: error: expected expression before ‘)’ token
pthread_rwlock_t *lock = (pthread_rwlock_t *)calloc(1,
^
liblock.c:293:5: error: implicit declaration of function ‘pthread_rwlock_init’ [-Werror=implicit-function-declaration]
int ret = pthread_rwlock_init(lock, NULL);
^
liblock.c: In function ‘rwlock_deinit’:
liblock.c:325:5: error: unknown type name ‘pthread_rwlock_t’
pthread_rwlock_t *lock = (pthread_rwlock_t *)ptr;
^
liblock.c:325:31: error: ‘pthread_rwlock_t’ undeclared (first use in this function)
pthread_rwlock_t *lock = (pthread_rwlock_t *)ptr;
^
liblock.c:325:49: error: expected expression before ‘)’ token
pthread_rwlock_t *lock = (pthread_rwlock_t *)ptr;
^
liblock.c:326:5: error: implicit declaration of function ‘pthread_rwlock_destroy’ [-Werror=implicit-function-declaration]
if (0 != pthread_rwlock_destroy(lock)) {
^
liblock.c: In function ‘rwlock_rdlock’:
liblock.c:337:5: error: unknown type name ‘pthread_rwlock_t’
pthread_rwlock_t *lock = (pthread_rwlock_t *)ptr;
^
liblock.c:337:31: error: ‘pthread_rwlock_t’ undeclared (first use in this function)
pthread_rwlock_t *lock = (pthread_rwlock_t *)ptr;
^
liblock.c:337:49: error: expected expression before ‘)’ token
pthread_rwlock_t *lock = (pthread_rwlock_t *)ptr;
^
liblock.c:338:5: error: implicit declaration of function ‘pthread_rwlock_rdlock’ [-Werror=implicit-function-declaration]
int ret = pthread_rwlock_rdlock(lock);
^
liblock.c: In function ‘rwlock_tryrdlock’:
liblock.c:367:5: error: unknown type name ‘pthread_rwlock_t’
pthread_rwlock_t *lock = (pthread_rwlock_t *)ptr;
^
liblock.c:367:31: error: ‘pthread_rwlock_t’ undeclared (first use in this function)
pthread_rwlock_t *lock = (pthread_rwlock_t *)ptr;
^
liblock.c:367:49: error: expected expression before ‘)’ token
pthread_rwlock_t *lock = (pthread_rwlock_t *)ptr;
^
liblock.c:368:5: error: implicit declaration of function ‘pthread_rwlock_tryrdlock’ [-Werror=implicit-function-declaration]
int ret = pthread_rwlock_tryrdlock(lock);
^
liblock.c: In function ‘rwlock_wrlock’:
liblock.c:397:5: error: unknown type name ‘pthread_rwlock_t’
pthread_rwlock_t *lock = (pthread_rwlock_t *)ptr;
^
liblock.c:397:31: error: ‘pthread_rwlock_t’ undeclared (first use in this function)
pthread_rwlock_t *lock = (pthread_rwlock_t *)ptr;
^
liblock.c:397:49: error: expected expression before ‘)’ token
pthread_rwlock_t *lock = (pthread_rwlock_t *)ptr;
^
liblock.c:398:5: error: implicit declaration of function ‘pthread_rwlock_wrlock’ [-Werror=implicit-function-declaration]
int ret = pthread_rwlock_wrlock(lock);
^
liblock.c: In function ‘rwlock_trywrlock’:
liblock.c:418:5: error: unknown type name ‘pthread_rwlock_t’
pthread_rwlock_t *lock = (pthread_rwlock_t *)ptr;
^
liblock.c:418:31: error: ‘pthread_rwlock_t’ undeclared (first use in this function)
pthread_rwlock_t *lock = (pthread_rwlock_t *)ptr;
^
liblock.c:418:49: error: expected expression before ‘)’ token
pthread_rwlock_t *lock = (pthread_rwlock_t *)ptr;
^
liblock.c:419:5: error: implicit declaration of function ‘pthread_rwlock_trywrlock’ [-Werror=implicit-function-declaration]
int ret = pthread_rwlock_trywrlock(lock);
^
liblock.c: In function ‘rwlock_unlock’:
liblock.c:442:5: error: unknown type name ‘pthread_rwlock_t’
pthread_rwlock_t *lock = (pthread_rwlock_t *)ptr;
^
liblock.c:442:31: error: ‘pthread_rwlock_t’ undeclared (first use in this function)
pthread_rwlock_t *lock = (pthread_rwlock_t *)ptr;
^
liblock.c:442:49: error: expected expression before ‘)’ token
pthread_rwlock_t *lock = (pthread_rwlock_t *)ptr;
^
liblock.c:443:5: error: implicit declaration of function ‘pthread_rwlock_unlock’ [-Werror=implicit-function-declaration]
int ret = pthread_rwlock_unlock(lock);
^
liblock.c: In function ‘sem_lock_wait’:
liblock.c:506:23: error: ‘CLOCK_REALTIME’ undeclared (first use in this function)
clock_gettime(CLOCK_REALTIME, &ts);
^
liblock.c:509:9: error: implicit declaration of function ‘sem_timedwait’ [-Werror=implicit-function-declaration]
ret = sem_timedwait(lock, &ts);
^
cc1: all warnings being treated as errors
make: *
* [liblock.o] Error 1
==== build linux liblock failed
In file included from libthread.c:13:0:
libthread.h:14:21: fatal error: liblock.h: No such file or directory
#include <liblock.h>
^
compilation terminated.
make: *** [libthread.o] Error 1
==== build linux libthread failed
Package lua5.2 was not found in the pkg-config search path.
Perhaps you should add the directory containing lua5.2.pc' to the PKG_CONFIG_PATH environment variable No package 'lua5.2' found Package lua5.2 was not found in the pkg-config search path. Perhaps you should add the directory containinglua5.2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lua5.2' found
Package lua5.2 was not found in the pkg-config search path.
Perhaps you should add the directory containing lua5.2.pc' to the PKG_CONFIG_PATH environment variable No package 'lua5.2' found Package lua5.2 was not found in the pkg-config search path. Perhaps you should add the directory containinglua5.2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lua5.2' found
Package lua5.2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `lua5.2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lua5.2' found
json/json_config.c:8:21: fatal error: jansson.h: No such file or directory
#include <jansson.h>
^
compilation terminated.
make: *** [json/json_config.o] Error 1
==== build linux libconfig failed
==== build linux libosal done.
==== build linux libvector done.
==== build linux libdebug done.
==== build linux libfile done.
In file included from libskt.c:27:0:
libskt.h:91:37: error: ‘struct tcp_info’ declared inside parameter list [-Werror]
int skt_get_tcp_info(int fd, struct tcp_info _ti);
^
libskt.h:91:37: error: its scope is only this definition or declaration, which is probably not what you want [-Werror]
libskt.c:169:37: error: ‘struct tcp_info’ declared inside parameter list [-Werror]
int skt_get_tcp_info(int fd, struct tcp_info *tcpi)
^
libskt.c:169:5: error: conflicting types for ‘skt_get_tcp_info’
int skt_get_tcp_info(int fd, struct tcp_info *tcpi)
^
In file included from libskt.c:27:0:
libskt.h:91:5: note: previous declaration of ‘skt_get_tcp_info’ was here
int skt_get_tcp_info(int fd, struct tcp_info *ti);
^
libskt.c: In function ‘skt_get_tcp_info’:
libskt.c:171:28: error: dereferencing pointer to incomplete type
socklen_t len = sizeof(_tcpi);
^
libskt.c:172:27: error: ‘SOL_TCP’ undeclared (first use in this function)
return getsockopt(fd, SOL_TCP, TCP_INFO, tcpi, &len);
^
libskt.c:172:27: note: each undeclared identifier is reported only once for each function it appears in
libskt.c: In function ‘skt_get_local_list’:
libskt.c:193:32: error: ‘IFF_UP’ undeclared (first use in this function)
if (!(ifa->ifa_flags & IFF_UP))
^
libskt.c:218:31: error: ‘IFF_LOOPBACK’ undeclared (first use in this function)
if ((ifa->ifa_flags & IFF_LOOPBACK) && !loopback)
^
libskt.c: In function ‘skt_getaddrinfo’:
libskt.c:302:21: error: storage size of ‘hints’ isn’t known
struct addrinfo hints, ai_list, *rp;
^
libskt.c:305:30: error: invalid application of ‘sizeof’ to incomplete type ‘struct addrinfo’
memset(&hints, 0, sizeof(struct addrinfo));
^
libskt.c:309:22: error: ‘AI_CANONNAME’ undeclared (first use in this function)
hints.ai_flags = AI_CANONNAME;
^
libskt.c:311:5: error: implicit declaration of function ‘getaddrinfo’ [-Werror=implicit-function-declaration]
ret = getaddrinfo(domain, port, &hints, &ai_list);
^
libskt.c:313:9: error: implicit declaration of function ‘gai_strerror’ [-Werror=implicit-function-declaration]
loge("getaddrinfo: %s\n", gai_strerror(ret));
^
libskt.c:319:43: error: dereferencing pointer to incomplete type
for (rp = ai_list; rp != NULL; rp = rp->ai_next ) {
^
libskt.c:321:48: error: dereferencing pointer to incomplete type
an->addr.ip = ((struct sockaddr_in *)rp->ai_addr)->sin_addr.s_addr;
^
libskt.c:322:56: error: dereferencing pointer to incomplete type
an->addr.port = ntohs(((struct sockaddr_in *)rp->ai_addr)->sin_port);
^
libskt.c:336:5: error: implicit declaration of function ‘freeaddrinfo’ [-Werror=implicit-function-declaration]
freeaddrinfo(ai_list);
^
libskt.c:302:21: error: unused variable ‘hints’ [-Werror=unused-variable]
struct addrinfo hints, *ai_list, *rp;
^
libskt.c: In function ‘skt_gethostbyname’:
libskt.c:348:9: error: implicit declaration of function ‘herror’ [-Werror=implicit-function-declaration]
herror("gethostbyname failed!\n");
^
libskt.c: In function ‘skt_get_tcp_info’:
libskt.c:173:1: error: control reaches end of non-void function [-Werror=return-type]
}
^
cc1: all warnings being treated as errors
make: *
* [libskt.o] Error 1
==== build linux libskt failed
==== build linux libstun done.
==== build linux libptcp done.
librpc.c:15:20: fatal error: libskt.h: No such file or directory
#include <libskt.h>
^
compilation terminated.
make: *** [librpc.o] Error 1
==== build linux librpc failed
libp2p.c:21:20: fatal error: libskt.h: No such file or directory
#include <libskt.h>
^
compilation terminated.
make: *** [libp2p.o] Error 1
==== build linux libp2p failed
netlink.c:20:23: fatal error: libthread.h: No such file or directory
#include <libthread.h>
^
compilation terminated.
make: *** [netlink.o] Error 1
==== build linux libipc failed

@core1011
Copy link

for (uint64_t i = 0; i < n; ++ i) {
^
test_liblock.c:45:5: note: use option -std=c99 or -std=gnu99 to compile your code 目前这种写法在GCC编译器下是通不过的。。。

@gozfree
Copy link
Owner

gozfree commented Aug 22, 2016

@zh794390558 Thanks for your issue report.
The only C99 mode issue has been fixed, and you should install libjasson-dev and liblua5.2-dev to compile the libconfig.
Some of the libraries are depended on glibc now, and the flexiblility will be improved when porting other platforms.
And my environment is:
$ uname -a
Linux laptop 4.4.0-34-generic #53-Ubuntu SMP Wed Jul 27 16:06:39 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/issue
Ubuntu 16.04.1 LTS \n \l
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu116.04.2' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1
16.04.2)

@gozfree
Copy link
Owner

gozfree commented Aug 22, 2016

@core1011 非常感谢您的建议。
现在部分code在-std=c89 下确实编译不过,比如libmacro,里边包含了部分linux kernel 的头文件,考虑到kernel支持c99的情况,所以为保证一致性,就没有fix c89的编译问题,其他libxxx会尽量fix。

@zh794390558
Copy link
Author

@gozfree liblock librpc libskt must use -std=gnu99 to compile, do you known the diffrence of the two options.

@gozfree
Copy link
Owner

gozfree commented Aug 24, 2016

@zh794390558 Thanks for your fix, and I have fix the compile error instead of using '-std=gnu99'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants