centos ./configure error: libevent not found despite it is installed via yum - gcc

I have a really strange problem. I am trying to compile a source (telegram-cli) which has dependency on openssl, libevent and other libraries.
The system is centos 6.9
and "Development Tools" and libevent-devel and openssl-devel are installed via yum. By the way, ./configure results in this output:
Using this repo (Telegram-CLI):
git clone --recursive https://github.com/vysheng/tg.git && cd tg
./configure :
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for library containing clock_gettime... no
checking for library containing backtrace... no
checking for event_base_new in -levent... no
configure: error: no libevent found
gcc -v -N :
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
I also added this to /etc/ld.so.conf.d/ :
/usr/lib64
/usr/lib
/usr/local/lib64
/usr/local/lib
/lib
/lib64
/usr/lib64/openssl/engines
/usr/lib64/libevent-1.4.so.2.1.3
/usr/lib64/libgcrypt.so
/usr/lib64/libevent.so
The strange point is all these configs are the same on another centos system and everything just works fine. :(
I guess the libraries exist on the system but gcc or linker could not find them. Can anyone help?
Thanks

You need libevent-devel
yum install libevent-devel

Related

warnings while trying to compile old linux kernel with gcc 12.1.0

I am currently hunting a bug using git bisect in linux staging-testing tree.
Some commits are giving following errors after I try to build them:
subcmd-util.h:58:31: error: pointer may be used after ‘realloc’ [-Werror=use-after-free]
58 | ret = realloc(ptr, 1);
check.c:2867:58: error: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 9 [-Werror=format-truncation=]
2867 | snprintf(pvname, sizeof(pvname), "pv_ops[%d]", idx);
I tried adding -Wno-error=use-after-free to KBUILD_FLAGS in main Makefile, tried adding
KBUILD_CFLAGS += $(call cc-disable-warning, use-after-free)
I even tried removing -Werror from CFLAGS in Makefile in folder where problematic files are located, but nothing worked.
More information:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.artixlinux.org/ --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror --with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.1.0 (GCC)
Linux staging tree: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git.
One of the commits that gives following warnings: 2ab9c9675fe892e7fe9fa8c0a6125e2b40d2889d.
To compile older version of kernel I needed older compiler ("Linux kernel sources are in general not forward-compatible with new compilers"). In my case the kernel version was 5.16.0 and I could compile it with gcc 11. If you have gcc 11 specific warnings then try gcc 10 and so on.
Except CC flags, I also needed set to HOSTCC flags to use gcc-11 compiler:
make HOSTCC=gcc-11 CC=gcc-11

problems when configure omnet (omnetpp-5.4.1)

I have run into probelms when configure omnetpp-5.1.1 on windows10
I have installed gcc sucessfully as showed below:
PS C:\Users\admin> gcc -v
specs
COLLECT_GCC=C:\MinGW\bin\gcc.exe
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe
mingw32
../src/gcc-6.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --with-gmp=/mingw --with-mpfr --with-mpc=/mingw --with-isl=/mingw --prefix=/mingw --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-6.3.0-1' --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --enable-libgomp --disable-libvtv --enable-nls
win32
gcc 6.3.0 (MinGW.org GCC-6.3.0-1)
2.when I follow the instructions and Type "./configure"
the problem ouccurs: here is my log
/d/softwares/omnet/omnetpp/omnetpp-5.4.1$ ./configure
configure: loading site script /mingw64/etc/config.site
checking build system type... x86_64-w64-mingw32
checking host system type... x86_64-w64-mingw32
configure: -----------------------------------------------
configure: reading configure.user for your custom settings
configure: -----------------------------------------------
checking for clang... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking for clang++... clang++
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ accepts -g... yes
checking for clang++... clang++
checking for ranlib... ranlib
checking whether clang++ supports -fno-stack-protector... yes
checking whether clang++ supports -Wl,--no-as-needed... yes
checking whether clang++ supports -Wl,--as-needed... yes
checking for swapcontext... no
checking if shared libs need -fPIC... no
checking for dlopen with CFLAGS="" LIBS=""... no
checking if --export-dynamic linker option is supported/needed... test failed
checking for flags needed to link with static libs containing simple modules... --whole-archive
configure: NOTE: Use the following syntax when linking with static libraries
configure: containing simple modules and other dynamically registered components:
configure: clang++ ... -Wl,--whole-archive <libs> -Wl,--no-whole-archive ...
checking whether linker supports -rpath... yes
checking for bison... bison -y
checking for flex... flex
checking lex output file root... lex.yy
checking lex library... none needed
checking whether yytext is a pointer... no
checking for make... make
checking for perl... perl
checking for swig... not found
checking for math with CFLAGS="" LIBS=""... yes
**checking for standard C++ lib with CFLAGS="" LIBS="-lstdc++"... no
checking for standard C++ lib with CFLAGS="" LIBS="-lc++"... no
checking for standard C++ lib with CFLAGS="" LIBS="-lcxa"... no**
configure: error: Standard C++ library -lstdc++_s or -lstdc++ or -lcxx or -lcxa or -lc++ not found
# here is the probelm
It always shows the probelms missing C++ lib, but I don't know if it's the broken lib's problem. If so, what should I do to fix this problem.
Please help me. Thanks a lot!
OMNeT++ for Windows does not require installing external GCC from MinGW. All necessary tools and libraries are already present in the ZIP package.
Make sure that real-time protection in your antivirus is turned off during calling ./configure and make.

how to fix: /bin/ld: cannot find -lgfortran error: ld returned 1 exit status

I am trying to compile a Fortran code (package) with gfortran in a Linux server, on which I have no root access.
It has a Makefile and when I run make I get this error
/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status
but gcc is already installed on cluster.
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
or libgfortran:
locate libgfortran
/usr/lib/libgfortran.so.3.0.0
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libgfortran.so
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libgfortran.spec
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libgfortranbegin.a
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libgfortran.a
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libgfortran.so
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libgfortranbegin.a
/usr/lib64/libgfortran.so.1
/usr/lib64/libgfortran.so.1.0.0
/usr/lib64/libgfortran.so.3
/usr/lib64/libgfortran.so.3.0.0
/usr/share/doc/gcc-gfortran-4.8.5/ChangeLog-2002.libgfortran.bz2
/usr/share/doc/gcc-gfortran-4.8.5/ChangeLog-2003.libgfortran.bz2
/usr/share/doc/gcc-gfortran-4.8.5/ChangeLog-2004.libgfortran.bz2
/usr/share/doc/gcc-gfortran-4.8.5/ChangeLog-2005.libgfortran.bz2
/usr/share/doc/gcc-gfortran-4.8.5/ChangeLog-2006.libgfortran.bz2
/usr/share/doc/gcc-gfortran-4.8.5/ChangeLog-2007.libgfortran.bz2
/usr/share/doc/gcc-gfortran-4.8.5/ChangeLog-2008.libgfortran.bz2
/usr/share/doc/gcc-gfortran-4.8.5/ChangeLog-2009.libgfortran.bz2
/usr/share/doc/gcc-gfortran-4.8.5/ChangeLog-2010.libgfortran.bz2
/usr/share/doc/gcc-gfortran-4.8.5/ChangeLog-2011.libgfortran.bz2
/usr/share/doc/gcc-gfortran-4.8.5/ChangeLog-2012.libgfortran.bz2
/usr/share/doc/gcc-gfortran-4.8.5/ChangeLog.libgfortran.bz2
and this is the output of installed package
yum list gcc-gfortran
Failed to set locale, defaulting to C
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Installed Packages
gcc-gfortran.x86_64 4.8.5-16.el7 #local-rhels7.4-x86_64--install-rhels7.4-x86_64
The question is why it can not find libgfortran, while gcc is installed?
I have also tried to update $PATH but it did not change anything.
I am just a user of the server without root access.

Compiler lacks asm-goto support on Fedora 28

I couldn't find an rpm for v4l2loopback so I tried to compile it on a fresh Fedora 28, but it failed :
$ LANG=en_US.utf8 make
Building v4l2-loopback driver...
make -C /lib/modules/`uname -r`/build M=/opt/v4l2loopback modules
make[1]: Entering directory '/usr/src/kernels/4.17.6-200.fc28.x86_64'
arch/x86/Makefile:184: *** Compiler lacks asm-goto support.. Stop.
make[1]: Leaving directory '/usr/src/kernels/4.17.6-200.fc28.x86_64'
make: *** [Makefile:43: v4l2loopback.ko] Error 2
I found that asm-goto has been supported since gcc 4.5, and I have 8.1.1 installed :
$ LANG=en_US.utf8 gcc -v
Using built-in specs.
COLLECT_GCC=cc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable- languages=c,c++,fortran,objc,obj-c++,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --enable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.1.1 20180712 (Red Hat 8.1.1-5) (GCC)
I managed to compile the module by simply commenting the following check in /usr/src/kernels/4.17.6-200.fc28.x86_64/arch/x86/Makefile :
# ifndef CC_HAVE_ASM_GOTO
# $(error Compiler lacks asm-goto support.)
# endif
but obviously this is a dirty workaround. Yet, the Makefile CFLAGS actually had -DCC_HAVE_ASM_GOTO set. I also tried to set CC_HAV_ASM_GOTO in the Makefile but it didn't help.
What's wrong here ? Is it the Makefile, or Fedora, or am I missing something ? I lost familiarity with Makefiles…
I got the same problem. The caches of Makefile were staled/dirty.
In my case, it seems because I terminated make on the fly.
Inspired from this old patch https://lkml.org/lkml/2018/3/19/1474, I changed from the shell-cached to shell in Makefile in base dir to avoid caching and it works:
-ifeq ($(call shell-cached,$(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y)
+ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y)
Then clean to make sure we don't have bad cache:
make clean
make -j9

Troubleshooting warning from "make -j N"

When I issue a command like (for example) make -j 4, I get the following error:
warning: jobserver unavailable: using -j1. Add `+' to parent make rule
I am using the developer toolkit from Scientific Linux 6 under RHEL6:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/opt/rh/devtoolset-2/root/usr --mandir=/opt/rh/devtoolset-2/root/usr/share/man --infodir=/opt/rh/devtoolset-2/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,fortran,lto --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/cloog-install --with-mpc=/builddir/build/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/mpc-install --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC)
I have libmpc 0.8.3 installed:
$ rpm -qa | grep mpc
libmpcdec-1.2.6-6.1.el6.x86_64
libmpc-0.8-3.el6.x86_64
Is there a way to troubleshoot my project's makefile or gcc to determine what is causing the warning and fix it? I do not seem to need the + symbol added to rules when building from OS X via Clang/LLVM. Google searches on the warning text are not returning much information that is apparently useful.
Whenever you run make from inside a makefile you should always use the $(MAKE) variable. Never use the raw, literal command make.

Resources