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

2

8

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
Globulin answered 3/5, 2015 at 12:32 Comment(1)
The error message is telling you to add /lib/x86_64-linux-gnu/libm.so.6 (or better yet, the short version -lm) to your command line...Hydrocarbon
D
7

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.

Directorate answered 15/11, 2015 at 20:35 Comment(0)
F
5

You can compile your code using -lm argument.

gcc file.c -lm

Farly answered 13/2, 2018 at 13:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.