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
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
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.
You can compile your code using -lm
argument.
gcc file.c -lm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With