Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling: //lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing

I am having trouble compiling code intended for 32bit unix system on my 64bit Ubuntu, Linux. Does anyone have any ideas what may be the problem?

gcc main.o test.o render.o transform.o model.o vector.o color.o -o the_thing -lSDL
/usr/bin/ld: transform.o: undefined reference to symbol 'cos@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
like image 338
Cat Matrix Avatar asked May 03 '15 12:05

Cat Matrix


2 Answers

You should link libm as well when you are dealing with code that uses mathematical functions.

From this answer:

If your code includes mathematical functions (like exp, cos, etc.), you need to link to the mathematics library libm.so. This is done, just like for serial compiling, by adding -lm to the end of your compile command, that is,

mpicc -o sample sample.c -lm

A plus

I saw in your compile line that you are using -lSDL. SDL works with C and C++, so, if you are using pure C you should include the default math C header, which is:

#include <math.h>

I think that you made something like this:

#include <cmath>

If you are working with C++ you should not compile using the C compiler, use g++ instead.

like image 98
ranu Avatar answered Sep 20 '22 19:09

ranu


You can compile your code using -lm argument.

gcc file.c -lm

like image 45
alhelal Avatar answered Sep 19 '22 19:09

alhelal