The error it throws:
g++ -m64 -std=c++17 main.cpp -o vulkanprogram -lvulkan
/usr/bin/ld: cannot find -lvulkan
collect2: error: ld returned 1 exit status
what ld returns when I find it myself:
ld -lvulkan --verbose
attempt to open /usr/lib/libvulkan.so succeeded
/usr/lib/libvulkan.so
can someone help explain this to me?
This is because ld cannot search the correct path
use this before running: export LD_LIBRARY_PATH=/usr/lib
or this g++ -m64 -std=c++17 main.cpp -o vulkanprogram -I/usr/include/ -L/usr/lib/ -lvulkan
On surface, based on comments, the problem is with the LD search path. Providing the full path (/usr/lib/lib...) seems to address the problem.
g++ -m64 -std=c++17 main.cpp -o vulkanprogram /usr/lib/libvulkan.so
For permanent solution - troubleshoot with
Verbose ld output: g++ --Wl,--verbose m64 -std=c++17 main.cpp -o vulkanprogram /usr/lib/libvulkan.so
Check type of library file /usr/lib/libvulkan.so
Related
Questions asked on stackoverflow about this question,have not been able to help me, this is complete error:
/usr/bin/ld: /tmp/ccgpX9K3.o: in function `connectDB(sql::Connection*)':
/home/erasmoh/sockets_c++/src/server.cpp:128: undefined reference to `get_driver_instance'
collect2: error: ld returned 1 exit status
i have tried this commands:
sudo g++ -Wall -I/usr/include/cppconn -o server server.cpp -L/usr/lib -lmysqlcppconn
g++ -g -o0 -I/usr/local/include -I/usr/local/boost/include -c server.cpp -o server.o
g++ -g -o0 -L/usr/local/lib -L/usr/local/mysql/lib server.o -o server -lmysqlcppconn
i have tried other ways to do it, creating a shared library as well, but, i getting the same error.
----jGRASP exec: gcc -g -o C1.exe C1.c -lglu32 -lfreeglut -lopengl32`
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lfreeglut
collect2.exe: error: ld returned 1 exit status
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
I am using mingw32 compiler and I followed the instructions from the link below:
http://users.csc.calpoly.edu/~akeen/courses/csc101/references/gcc.html
Hope that someone knows what to do
thank you
You probably need to specify the location of the freeglut library with the flag -L /path/to/freeglut, so compile as
gcc -g -o C1.exe C1.c -L/path/to/freeglut -lglu32 -lfreeglut -lopengl32
or, if you use an IDE, there should be an option to specify the location of the libraries used by the linker.
See http://users.csc.calpoly.edu/~phatalsk/references/jGrasp_gcc_Setup/GCC_JGrasp_Install.html
Settings/Compiler Settings/Workspace, add the flag to C/L field.
I am working on a project in which protobuf and zmq are involved. I have finished it on VS2010 and now want to make it work under Linux. I just installed protobuf and zmq on our Linux server and the Makefile looks like this:
g++ -c -D_DEBUG TestTDFAPI_v2.cpp -I ../
g++ -c -D_DEBUG Platform.cpp
g++ -c -D_DEBUG PathHelper.cpp
g++ -c -D_DEBUG MyStruct.pb.cpp
g++ -c -D_DEBUG MyStruct.cpp
g++ -o Test_TDFAPI_v2 Platform.o PathHelper.o MyStruct.pb.o MyStruct.o TestTDFAPI_v2.o -l /usr/local/include -L /usr/local/lib -L../ -L../linux/ -lTDFAPI_v2 -lWHNetWork -lpthread -lprotobuf
After make, I got the following error:
/usr/bin/ld: cannot find -l/usr/local/include
collect2: ld returned 1 exit status
Anyone has any clue?
-l (minus ell) is for library files to search for resolving references, you want -I (minus eye) to specify include directories.
I installed Google perftools (google-perftools 1.7-1ubuntu1), and add -lprofiler to PKG_LIBS in R, when compiling the C++ code.
library(RcppArmadillo)
library(Rcpp)
Sys.setenv("PKG_CXXFLAGS"="-fopenmp")
Sys.setenv("PKG_LIBS"="-fopenmp -lprofiler")
sourceCpp('my.cpp')
The output is:
/usr/bin/ld: cannot find -lprofiler
collect2: ld returned 1 exit status
make: *** [sourceCpp_17496.so] Error 1
g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppArmadillo/include" -fopenmp -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c my.cpp -o my.o g++ -shared -Wl,-Bsymbolic-functions -Wl,-z,relro -o sourceCpp_17496.so my.o -llapack -lblas -lgfortran -lm -lquadmath -fopenmp -fopenmp -lprofiler -L/usr/lib/R/lib -lR
Error in sourceCpp("my.cpp") :
Error 1 occurred building shared library.
WARNING: The tools required to build C++ code for R were not found.
Please install GNU development tools including a C++ compiler.
Even if I run g++ in bash, I get the same error
$ g++ -shared -Wl,-Bsymbolic-functions -Wl,-z,relro -o sourceCpp_17496.so my.o -llapack -lblas -lgfortran -lm -lquadmath -fopenmp -fopenmp -lprofiler -L/usr/lib/R/lib -lR
/usr/bin/ld: cannot find -lprofiler
collect2: ld returned 1 exit status
I wonder why -lprofiler doesn't specify google perfotools? How can I solve the problem? Thanks!
My g++ is g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3.
Quick ones:
Do you actually have the package libgoogle-perftools-dev installed? Ie do you have shared and static libraries /usr/lib/libprofiler.* ? This is the mother of all development FAQs: you need package libfoo to run code against foo, and package libfoo-dev to compile against foo.
I have old working examples in the slides from my 'HPC with R' talks from a few years ago; those should all work as is.
So I have the following problem:
g++ -std=c++0x -O3 -I/usr/include/scip main.cpp locations/locationreader.cpp locations/locationassigner.cpp scheduler.o optimizer.o dbmanager.o scheduleData.o exam.o -o main -L/usr/lib -lscip -lreadline -lgmp -lz -llpispx -lsoplex -lobjscip -lnlpi.cppad -lscipopt -lzimpl -lpqxx -lpq -pthread
/usr/lib/../lib64/libpqxx.so: undefined reference to `PQescapeIdentifier'
collect2: error: ld returned 1 exit status
make: *** [main] Error 1
And I cannot figure out why it cannot find the reference because I have libpq installed and its right there in /usr/lib64
$ ls | grep pq
libpq.so
libpq.so.5
libpq.so.5.2
libpqxx-4.0.so
libpqxx.so
So if I could get any help with this that would be lovely
PQescapeIdentifier appeared in PostgreSQL 9.0, which corresponds to libpq.so.5.3
9.0 release notes have this entry:
Add libpq functions PQescapeLiteral() and PQescapeIdentifier() (Robert
Haas)
You seem to use client libraries from PostgreSQL-8.4 (libpq.so.5.2), that would be why it lacks this function.