I have downloaded the latest GLUI source code and now I am trying to compile it. When I do so, I get the following error:
g++ -O0 -Wall -pedantic -I./ -I./include -I/usr/X11R6/include -o bin/example1 example/example1.cpp -L./lib -lglui -L/usr/X11R6/lib/libXdmcp.a -lglut -lGLU -lGL -lXmu -lXext -lX11 -lXi -lm
/usr/bin/ld: cannot find -lXmu
collect2: ld returned 1 exit status
When I did a locate libXmu, I get the following output:
> %:~/src/GLUI/src$ locate libXmu
> /usr/lib/libXmu.so.6
> /usr/lib/libXmu.so.6.2.0
> /usr/lib/libXmuu.so.1
> /usr/lib/libXmuu.so.1.0.0
Do I get the error because I don't have a /usr/lib/libXmu.so? If this is the case, how can I make one? (I am not experienced with linking at all).
Thanks!
Linux distributions usually package the libraries needed for running programs separately from the files needed to build programs.
Look for packages named *-devel or *-dev.
I don't know which one you need in particular for this, but you can use apt-cache search to look for it.
The answer was actually one of the first ones here originally but the owner deleted it, it seems. I was able to solve the problem by creating a symbolic link to the latest version of the library (i.e. /usr/lib/libXmu.so.6) and compile the code successfully.
I had the same problem, if creating a symbolic link doesnt help,
try the following:
Print your $PATH ("echo $PATH"),
and check if the library file you need is in one of those directories.
Use "export PATH=/newly/added/path:$PATH" to add new directory to check.
Ive been including libevent, added "-levent" in the gcc command, and ld used file /usr/lib/libevent.so, so it looks like the "lib" prefix and extension are being added automatically by ld.
Keep it up.
Related
I am compiling a C++ application on Ubuntu 18.04.
The linker is unable to pickup the required functions from the library or it is not locating the right library
I have libcurl.so located at /usr/local/lib
nm -D lists all the functions I need with T prefix. Yet when I compile as follows
g++ -std=c++17 -lcurl tz.o main.o
I get
/usr/bin/ld: tz.o: in function 'date::curl_global()':
tz.cpp:(.text+0x9aef): undefined reference to 'curl_global_init'
I tried installing openssl-dev. No joy. So I uninstalled it.
try
g++ -std=c++17 tz.o main.o -lcurl
instead... g++ is shit in some ways, like argument ordering. (all i did was to make -lcurl the last argument instead of argument #3)
How do I get my 'make' process to show me the actual search paths and libraries found with the linker?
I have link errors for symbols I know are in libraries I am trying to use ( verified using objdump ). What I don't know is if the linker is finding the correct libraries. It should be, since all of the libraries I am using are in one directory and some of them ARE being found and used.
So I would like to get diagnostic output showing what library search paths were used, and what libraries ( with paths ) that were actually found and used by the linker.
I tried make -n and got
g++ -g -Wall -DLINUX -I../../../Common/include -I../../../Common/libs/liblua/src main.o IDUpdater.o version.o -L../../../Common/libs -lapp -lserver -lthreading -lnet -lmsgqueue -lcpp -lisam -lisamcore -ldb -ldbisam -ldbsql -Wl,--whole-archive -Wl,--no-whole-archive -o foo
I know libisam.a ,libdbisam.a and others are found and used, but libmsgqueue.a is not. These libraries are all in ../../..'Common/libs/.
I am rather new to Linux (using Ubuntu 14.04 LTS 64bit), coming from Windows, and am attempting to port over an existing CUDA project of mine.
When linking via
/usr/local/cuda/bin/nvcc -arch=compute_30 -code=sm_30,compute_30 -o Main.o Display.o FileUtil.o Timer.o NeuralNetwork.o -L/usr/lib -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu -L/usr/local/cuda/lib64 -lGLEW -lglfw3 -lGL -lGLU -lcuda -lcudart
I encounter the following error:
/usr/bin/ld: /usr/local/lib/libglfw3.a(x11_clipboard.c.o): undefined reference to symbol 'XConvertSelection'
//usr/lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [CUDANN] Error 1
The answer seems closely related to the solutions in this post (Strange linking error: DSO missing from command line), though given my inexperience with Linux I was unable to adapt them to my own problem.
Any ideas on what the problem could be?
Here is the full output during compilation: https://gist.github.com/wbolden/857eddd11e4dcb915c02
And here is my attempt at a Makefile:
https://gist.github.com/wbolden/135033daae04ed0d8cf3
Hopefully this will be of help to those, like me, who are new to Linux and don't find anything related to Linux to be particularly obvious.
As noted by talonmies, I am not able to link indirectly and as such need to specify any additional libraries required by the libraries I am using. That is to say, if I link library A, which requires libraries B and C, I need to link all three libraries for the program to link correctly.
To find what other libraries were needed I used the pkg-config command, for which I found a guide here. Running pkg-config --print-requires --print-requires-private glfw3 gave the following output, which is the list of packages required by glfw3.
x11
xrandr
xi
xxf86vm
gl
I was then able to find what libraries I needed to include by running pkg-config --libs, followed by the name of the library. For example, pkg-config --libs x11 yielded -lX11.
Note: you can pass multiple items to pkg-config as input, so running
pkg-config --libs $(pkg-config --print-requires --print-requires-private glfw3)
will print out all the additional libraries you need to link (-lX11 -lXrandr -lXi -lXxf86vm -lGL).
My program now links successfully, I hope this helpful to anyone with a similar problem.
Your linker need X11 library,You need to specify -lX11 to linker
Try
/usr/local/cuda/bin/nvcc -arch=compute_30 -code=sm_30,compute_30 -o Main.o Display.o FileUtil.o Timer.o NeuralNetwork.o -L/usr/lib -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu -L/usr/local/cuda/lib64 -lGLEW -lglfw3 -lGL -lGLU -lcuda -lcudart -lX11
Try to add -pthread at the end of the library list (command line) in the Makefile.
It worked for me.
Use the following commands to fix the issue:
FLAGS=-lX11 ./configure --prefix=/usr --disable-static
make
make install
I have an error making a code project because of what I believe is a missing routine from lapack:
HomographyInit.cc:(.text+0x385): undefined reference to `dgesvd_'
I think I need to add lapack library somehow to my Makefile. Here is part of my Makefile:
CC = g++
COMPILEFLAGS = -I MY_CUSTOM_INCLUDE_PATH -D_LINUX -D_REENTRANT -Wall -O3 -march=nocona -msse3
LINKFLAGS = -L MY_CUSTOM_LINK_PATH -lGVars3 -lcvd
I tried doing the following to no avail:
CC = g++
COMPILEFLAGS = -I MY_CUSTOM_INCLUDE_PATH -D_LINUX -D_REENTRANT -Wall -O3 -march=nocona -msse3
LINKFLAGS = -L MY_CUSTOM_LINK_PATH -lGVars3 -lcvd **-llapack**
Result:
make
...
/usr/bin/ld: cannot find -llapack
collect2: ld returned 1 exit status
How can I add lapack to my project? I am pretty sure I installed it correctly, though would be willing to double-check that somehow.
It looks like liblapack isn't in the path that ld can find. I would suggest two things:
Establish a symbolic link manually. It is possible (and sometimes common) that ld cannot recognize liblapack.so.3gf or liblapack.so.3.0.1 or so are essentially liblapack.so. You can set up a link by ln -s liblapack.so.3gf liblapack.so
Install liblapack-dev package instead if you're using ubuntu or debian repos. For some unclear reasons, liblapack3gf is not the same as liblapack-dev. I am not sure if in any circumstances, both will do or not do the same thing.
I think the first item should be able to resolve your problem (hopefully).
On my computer the dynamic library is in /usr/lib64/liblapack.so.3.4.1 and contains the requested symbol:
$ nm -D /usr/lib64/liblapack.so.3.4.1 | grep dgesvd
0000000000189200 T dgesvd_
So I would guess that the place where your lapack is installed is not in the linker search path. You should add the flag -L/path/to/the/lapackdir to LINKFLAGS
When I run a make file in Linux to compile C codes, I get the following error:
gcc -Wall -fPIC -DSOLARIS -DXP_UNIX -DMCC_HTTPD -D_REENTRANT -I/opt/profile/OraAlert_test/code/include -I/usr/netscape/server4/plugins/include -I../../pwutils -I../../database/src -I../../access/src -I/data/share/capscan/include -o getEnv.o -c ../src/
gcc: ../src/: linker input file unused because linking not done
I have tried searching for related questions in stackoverflow and tried the the solutions suggested. Still this could not be resolved.
Any suggestions?
You have a compilation command without a source file.
What is it supposed to compile?
The error is indeed misleading. It assumes you want to link with ../src/, but -c says no linkage is to be done.