I'm trying to build a project created in QT Creator and unfortunately every time I try to compile I get an error. Here is my compiler output:
23:02:20: Running steps for project WallpaperAppQt...
23:02:20: Configuration unchanged, skipping qmake step.
23:02:20: Starting: "/usr/bin/make"
g++ -m64 -o WallpaperAppQt main.o mainwindow.o moc_mainwindow.o -L/usr/X11R6/lib64 -lQt5Widgets -L/usr/lib/x86_64-linux-gnu -lQt5Gui -lQt5Core -lGL -lpthread
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
make: *** [WallpaperAppQt] Error 1
23:02:20: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project WallpaperAppQt (kit: Desktop)
When executing step 'Make'
23:02:20: Elapsed time: 00:00.
You need a package that provides the libGL.so (no version suffix) symlink. In Ubuntu, it's in the libgl1-mesa-dev package. So just do:
sudo apt install libgl1-mesa-dev
I was able to fix my problem by following the instructions in this link:
http://techtidings.blogspot.com/2012/01/problem-with-libglso-on-64-bit-ubuntu.html
(the final two commands)
sudo rm /usr/lib/x86_64-linux-gnu/libGL.so
sudo ln -s /usr/lib/libGL.so.1 /usr/lib/x86_64-linux-gnu/libGL.so
I was having the same problem. Then I used the following command in the terminal:
sudo apt install mesa-common-dev libglu1-mesa-dev"
and the application run perfectly.
It's obvious that ld doesn't find lib GL in default library path which should be include /lib* /usr/lib*. You should install library GL or tell g++ where lib GL was installed with cmd args -L if that was installed already.
Related
I was getting this error while trying to run a simple crystal program in my ubuntu.
/usr/bin/ld: cannot find -levent (this usually means you need to install the development package for libevent)
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: cc "${#}" -o /home/xyz/.cache/crystal/crystal-run-test.tmp -rdynamic -L/home/xyz/.asdf/installs/crystal/1.1.1/bin/../lib/crystal/lib -lpcre -lm -lgc -lpthread -levent -lrt -ldl
Issue has been solved by installing libevent packages by running the following command:
sudo apt-get install libevent-dev
When I tried to run example of gRPC for c++ in folder grpc/examples/cpp/helloworld it requires libraries which weren't compiled when I built gRPC with Cmake
Firstly I built gRPC in Ububtu 16.04 with instructions:
$ git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc
$ cd grpc
$ git submodule update --init
$ cd third_party/protobuf
$ git submodule update --init --recursive
$ ./autogen.sh
$ ./configure --prefix=/usr
$ make
$ make check
$ sudo make install
$ sudo ldconfig # refresh shared library cache.
$ pkg-config --cflags protobuf # print compiler flags
$ pkg-config --libs protobuf # print linker flags
$ pkg-config --cflags --libs protobuf # print both
cd ../..
make
sudo make install
After that I tried to run example in folder grpc/examples/cpp/helloworld
grps/grpc/examples/cpp/helloworld$ make
i got several mistakes, which were resolved by copying grpc_cpp_plugin from folder grpc/bins/opt to /usr/local/bin and grpc++.pc and grpc++_unsecure.pc from grpc/libs/opt/pkgconfig/ to /usr/local/lib/pkgconfig.
When I tried for the next time command
grpc/examples/cpp/helloworld$ make
I've got message
g++ helloworld.pb.o helloworld.grpc.pb.o greeter_client.o -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc` -pthread -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed -ldl -o greeter_client
/usr/bin/ld: cannot find -lgrpc++
/usr/bin/ld: cannot find -lgrpc++_reflection
collect2: error: ld returned 1 exit status
Makefile:44: recipe for target 'greeter_client' failed
make: *** [greeter_client] Error 1
So, I searched these libs libgrpc++ in folder grpc/libs/opt, but there only these libraries
grpc/libs/opt$ ls --l
libaddress_sorting.a libgrpc_cronet.so.8
libaddress_sorting.so libgrpc_cronet.so.8.0.0
libaddress_sorting.so.8 libgrpc_plugin_support.a
libaddress_sorting.so.8.0.0 libgrpc.so
libares.a libgrpc.so.8
libboringssl.a libgrpc.so.8.0.0
libgpr.a libgrpc_unsecure.a
libgpr.so libgrpc_unsecure.so
libgpr.so.8 libgrpc_unsecure.so.8
libgpr.so.8.0.0 libgrpc_unsecure.so.8.0.0
libgrpc.a pkgconfig
libgrpc_cronet.a protobuf
libgrpc_cronet.so
So make didn't compile static and dynamic libraries for gRPC. Is it I did something wrong or didn't something or there is a bug? Version of protobuf is
:~$ protoc --version
libprotoc 3.8.0
:~$ which protoc
/usr/bin/protoc
Here is some output after I run "make" from root directory
[MAKE] Generating /home/user/cpp_test/grps/grpc/libs/opt/pkgconfig/grpc++.pc
[MAKE] Generating /home/user/cpp_test/grps/grpc/libs/opt/pkgconfig/grpc++_unsecure.pc
So it creates pkgconfig files for "libgrpc++*" libraries, but doesn't create these libraries.
And these having libgrpc++
libgrpc++ depbase=`echo google/protobuf/io/tokenizer.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
and
libgrpc++ depbase=`echo google/protobuf/util/delimited_message_util.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
only two lines
It looks like you only ran make from the third_party/protobuf directory (which you need to do as the first step), and ran make from the helloworld directory. If you did not do so already, you should run make from the grpc repository root directory, per the documentation. This will ensure the libgrpc++* C++ libraries are built.
So, I resolved this problem.
When I run "make" on root gRPC folder, compilation ended with such result:
[CXX] Compiling /home/user/cpp_test/grps/grpc/gens/src/proto/grpc/core/stats.pb.cc
/home/user/cpp_test/grps/grpc/gens/src/proto/grpc/core/stats.pb.cc:187:13: error: ‘dynamic_init_dummy_src_2fproto_2fgrpc_2fcore_2fstats_2eproto’ defined but not used [-Werror=unused-variable]
static bool dynamic_init_dummy_src_2fproto_2fgrpc_2fcore_2fstats_2eproto = []()
^
cc1plus: all warnings being treated as errors
Makefile:2924: recipe for target '/home/user/cpp_test/grps/grpc/objs/opt//home/user/cpp_test/august/grpc/gens/src/proto/grpc/core/stats.pb.o' failed
make: *** [/home/user/cpp_test/grps/grpc/objs/opt//home/user/cpp_test/august/grpc/gens/src/proto/grpc/core/stats.pb.o] Error 1
Because all warnings were treated as errors. And compiling of another libraries was stopped. So I manually added in Makefile in root gRPC directory flag -Wno-unused-variableat the end of 357 line. After adding this flag building of gRPC library went succesfully, and all libgrpc++* and libgrpc* libraries were built.
CPPFLAGS += -g -Wall -Wextra -Werror $(W_NO_UNKNOWN_WARNING_OPTION) -Wno-long-long -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-maybe-uninitialized -DPB_FIELD_32BIT -DOSATOMIC_USE_INLINED=1 -Ithird_party/nanopb -Ithird_party/upb -Isrc/core/ext/upb-generated -Wno-unused-variable
I've just tried to run the simple HTTP server from the language documentation. The program fails with an error.
/usr/bin/ld: cannot find -lssl
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `cc -o "/home/rasmus/dev/crystal/projects/hello/.crystal/crystal-run-hello.tmp" "${#}" -rdynamic -lssl -levent -lrt -lpcl -lpcre -lgc -lpthread -ldl`
The program has been copy-pasted from the documentation.
I can confirm that the program did/does run on my guest machine, but not on my host. Both are Ubuntu 14.04.3 installs.
The problem was simply that the SSL libraries weren't installed. If you have the same problem you can simply run sudo apt-get install libssl-dev. This should install everything needed to fix the error.
I installed GLFW3 and am trying to compile my OpenGL program with the following:
g++ -std=c++11 main.cpp -lGL -lGLEW -lglfw3
But here's the library error I get:
/usr/bin/ld: cannot find -lglfw3
collect2: error: ld returned 1 exit status
I also tried with pkg-config:
g++ `pkg-config --cflags glfw3 glew` -o myprog main.cpp `pkg-config --static --libs glfw3 glew`
it compiles but when I run myprog it says it can't find libglfw.so.3
But it is located in /usr/local/lib
http://www.brandonfoltz.com/2012/12/compile-glfw-on-ubuntu-and-fix-libglfw-so-cannot-open-error/
Ubuntu installs libglfw.so.3 in /usr/local/lib so you have to add this line to /etc/ld.so.conf
I had the same problem.
In my case was usefull following steps:
Download glfw source code
unzip it
cd glfw_folder
cmake . (with dot)
make
sudo make install
To check, copy and paste following command in your console "whereis libglfw3".
you should have output like this one: "libglfw3: /usr/local/lib/libglfw3.a" (or another path after ":").
My config: VAIO Pro 13/Ubuntu 16.04 LTS/ Intel HD4000.
P.S.: Yes, I'd tryed "sudo apt-get install libglfw3" and all dependenses.
I try to crosscompile this small program to my arm device, but get error:
arm-none-linux-gnueabi/bin/ld: cannot find -lasound
collect2: error: ld returned 1 exit status
Then i found libasound files in my target device and have copied to my folder /usr/lib but still no effect.
I use the commands:
export CFLAGS="-I/usr/include -I/usr/lib"
$CC -o play sound_playback.c $CFLAGS -lasound
I have installed libasound2-dev package on my Ubuntu 14.04 x64 and be able to compile the program on my native computer without any errors.
UPDATE WITH SOLUTION
As Marc and John have said below, i just should use -L flag to set my library path. So my command line should be:
$CC -o play sound_playback.c $CFLAGS -L/usr/lib -lasound