I have zlib and pkg-config installed and pkg-config could find zlib:
$ pkg-config --list-all | grep zlib
zlib zlib - zlib compression library
pkg-config --libs is working:
$ pkg-config --libs zlib
-lz
but pkg-config --cflags couldn't find header files of zlib:
$ pkg-config --cflags zlib
prints nothing
$ cat /usr/lib64/pkgconfig/zlib.pc
prefix=/usr
exec_prefix=${prefix}
libdir=/usr/lib64
sharedlibdir=${libdir}
includedir=/usr/include
Name: zlib
Description: zlib compression library
Version: 1.2.7
Requires:
Libs: -L${libdir} -L${sharedlibdir} -lz
Cflags: -I${includedir}
Why pkg-config couldn't find zlib? (I'm using CentOS 7 if it matters)
pkg-config did find the cflags for zlib.
However, /usr/include is one of the default include paths searched by the compiler. Therefore pkg-config filters it from the output, so that the compiler won't search it twice.
For the same reason --libs produced only -lz, not including the library path -L/usr/lib64 which is also a default.
Related
I am trying to install some luarocks packages but it seems that although lua5.3 is installed, the relevant headers are not
$ which lua
/usr/bin/lua
$ lua -v
Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
/usr/include$ ls *lua*
lua5.1:
lauxlib.h luaconf.h lua.h lua.hpp lualib.h
luajit-2.1:
lauxlib.h luaconf.h lua.h lua.hpp luajit.h lualib.h
$ locate lua.h
/usr/include/luajit-2.1/lua.h
/usr/include/luajit-2.1/lua.hpp
/usr/share/doc/texlive-doc/latex/greek-fontenc/lgr2licr.lua.html
/usr/src/linux-headers-5.4.0-31-generic/include/config/scsi/dh/alua.h
/usr/src/linux-headers-5.4.0-40-generic/include/config/scsi/dh/alua.h
/usr/src/linux-headers-5.4.0-66-generic/include/config/scsi/dh/alua.h
/usr/src/linux-headers-5.4.0-70-generic/include/config/scsi/dh/alua.h
$ sudo luarocks install luacheck
Installing https://luarocks.org/luacheck-0.24.0-2.src.rock
Missing dependencies for luacheck 0.24.0-2:
luafilesystem >= 1.6.3 (not installed)
luacheck 0.24.0-2 depends on luafilesystem >= 1.6.3 (not installed)
Installing https://luarocks.org/luafilesystem-1.8.0-1.src.rock
gcc -O2 -fPIC -I/usr/include/lua5.3 -c src/lfs.c -o src/lfs.o
src/lfs.c:84:10: fatal error: lua.h: No such file or directory
84 | #include <lua.h>
| ^~~~~~~
compilation terminated.
Any help would be really appreciated.
sudo apt install liblua5.3-dev
I am running openssl benchmarks on Ubuntu Linux. Initially, there was some problem with the missing library. Later I fixed it by installing the library with the installation command sudo apt-get install libssl-dev. When I compiled using gcc command gcc sha256t.c -o sha -lcrypto, it generates binary but when compiled using RISCV gcc command riscv64-unknown-elf-gcc sha256.S -o sha.riscv -lcrypto, it throws the following link error.
/home/user_name/fpga-zynq/rocket-chip/riscv-tools/riscv/lib/gcc/riscv64-unknown-elf/6.1.0/../../../../riscv64-unknown-elf/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status.
How to link the -lcrypto in this case.
You need a libcrypto compiled for the riscv64 architecture.
What you installed with sudo apt-get install libssl-dev is a libcrypto compiled for your host architecture (likely x86_64), it cannot be used for cross-compiling.
If you can't find a pre-built libcrypto for riscv64, you might have to compile it yourself, with that same riscv64 cross-compiler you're using.
Automating this is what yocto or buildroot is all about.
I am compiling this program:
#include <iostream>
int main()
{
}
This command
g++ -c hello_world.cpp
works.
This command
clang++ -c hello_world.cpp
gives this error:
hello_world.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
^
1 error generated.
Doing:
clang++ -c hello_world.cpp -v
gives:
Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)
Target: x86_64-pc-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.8
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.8.4
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.9.1
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8.4
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9.1
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8.4
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.1
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
"/usr/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name hello_world.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.24 -v -coverage-file /home/user/code/cpp/StackOverflow_questions/hello_world.o -resource-dir /usr/bin/../lib/clang/3.4 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++ -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/x86_64-linux-gnu -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/backward -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.4/include -internal-externc-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/user/code/cpp/StackOverflow_questions -ferror-limit 19 -fmessage-length 202 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -vectorize-slp -o hello_world.o -x c++ hello_world.cpp
clang -cc1 version 3.4 based upon LLVM 3.4 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/backward"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++
/usr/local/include
/usr/bin/../lib/clang/3.4/include
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
hello_world.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
^
1 error generated.
clang++ is talking about using gcc 4.9 stuff, but if I do:
g++ --version
it outputs:
g++ --version
g++ (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
This is where iostream is located on my machine:
/usr/share/doc/fp-docs/2.6.2/fcl/iostream
/usr/include/boost/tr1/tr1/iostream
/usr/include/c++/4.8/iostream
Seeing as how clang++ was keen on using g++ 4.9 files, I decided to install g++ 4.9
ubuntu does not have 4.9 as part of it's normal "sudo apt-get install g++". They are still on 4.8. (not sure what put the gcc 4.9 (but apparently not g++ 4.9) stuff on my system).
I found out that I could install g++ 4.9 by doing:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.9
After these commands were issued, clang++ was able to find <iostream>.
Try to install these packages,
sudo yum groupinstall "Development Tools"
sudo yum install libstdc++-static.x86_64 compat-libstdc++-33.x86_64
I have had this problem and it was solved installing these packages.
I was trying to install the latest version of cabal-install on Ubuntu 14.04 with ghc 7.8.2. Here are the error messages and versions of things:
~/D/ghc-7.8.2> cabal install cabal-install
...
Linking dist/build/cabal/cabal ...
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
cabal: Error: some packages failed to install:
cabal-install-1.20.0.3 failed during the building phase. The exception was:
ExitFailure 1
~/D/ghc-7.8.2> which ld
/usr/bin/ld
~/D/ghc-7.8.2> ld -v
GNU ld (GNU Binutils for Ubuntu) 2.24
~/D/ghc-7.8.2> ld -lz
ld: cannot find -lz
~/D/ghc-7.8.2> cabal -V
cabal-install version 1.20.0.3
It's not a huge deal since my cabal version is pretty new... but I'd like to know how to fix this. I did not have this problem in Ubuntu 13.10.
Perhaps Ubuntu 14.04 has a new version of ld that does not support the -lz flag?
Found the answer:
sudo apt-get install lib32z1-dev
I should have googled longer before asking the question. The answer was here.
Trying to get one of the samples compiled on Ubuntu 12.04
I’m using
make -f Makefile-x64-static
However, I get the error
make: gcc4: Command not found
I tried switching from gcc4 to gcc in the makefile.
However, I get the compile errors
note: #pragma message: IMPORTANT NOTE: The FBX SDK API changed substantially. Please define FBXSDK_NEW_API in your project and fix compilation errors as instructed in fbxsdk_compatibility.h.
And the link error
/usr/bin/ld: cannot find -luuid
Any tips would be appreciated.
Pre-requisites
sudo apt-get install uuid-dev
sudo apt-get install libxmu-dev libxi-dev
sudo apt-get install libx11-dev
Makefile modifications required
Change gcc4 to gcc
CC = gcc
LD = gcc
add -lX11 to LIBS
LIBS = -lfbxsdk-$(LIBFBXVERSION)$(STATIC) -lm -lrt -luuid -lc -lstdc++ -lpthread -ldl -lglut_gcc34-amd64 -lGLEW_amd64 -lGLU -lGL -lXmu -lX11
add -DFBXSDK_NEW_API to C_FLAGS and CXX_FLAGS
CFLAGS = -m64 -DFBXSDK_NEW_API
CXXFLAGS = -m64 -DFBXSDK_NEW_API