tags:

views:

222

answers:

4

Hello, I wrote a makefile:

all: server client
server: server.o des.o sha1.o
/usr/local/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -o server server.o des.o sha1.o -I /usr/local/include/ -lgmp 
client: client.o des.o sha1.o
/usr/local/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -o -lgmp client client.o des.o sha1.o -I /usr/local/include/ 
server.o: server.c
/usr/local/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -c -lgmp server.c -I /usr/local/include/
client.o: client.c
/usr/local/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -c -lgmp client.c -I /usr/local/include/
des.o: des.c des.h
/usr/local/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -c -lgmp des.c -I /usr/local/include/
sha1.o: sha1.c sha1.h /usr/local/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -c -lgmp sha1.c -I /usr/local/include/

clean: -rm *.o server client

then gcc told me that cannot find -lgmp. I tried to put it in other places, there were other different errors...

In plus, I want to know if it's possible to put 2 elements in the target.

Thanx a lot

+2  A: 

Please use -L option and specify the path where gmp is present before adding -lgmp in your makefile.

Jay
+3  A: 

You probably need to provide a -L option to the compiler to add the directory containing the gmp library to the list of directories searched.

e.g.

-L/usr/local/lib

or

-L/usr/local/arm-2009q1/lib

As you appear to be cross-compiling you need a cross-compiled version of the gmp available in a path that you pass with a -L option.

Charles Bailey
A: 

a german tutorial on make: http://www.ijon.de/comp/tutorials/makefile.html

It is possible to use wildcards in targets, yes.

you can specify a path along with -l/some/where/libgmp.so e.g.

Or have a look at the -L option in gcc

Ronny
A: 

Thanx again for the answers above! It finds the library.. but comes another problem:

/usr/local/arm-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/../../../../arm-none-linux-gnueabi/bin/ld: warning: library search path "/usr/local/lib" is unsafe for cross-compilation
/usr/local/arm-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/../../../../arm-none-linux-gnueabi/bin/ld: skipping incompatible /usr/local/lib/libgmp.so when searching for -lgmp
/usr/local/arm-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/../../../../arm-none-linux-gnueabi/bin/ld: skipping incompatible /usr/local/lib/libgmp.a when searching for -lgmp
/usr/local/arm-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lgmp
collect2: ld returned 1 exit status
make: *** [server] Error 1
This isn't an 'answer' it's a further question. You should either ask a new question or (probably better in this case) update this question as 'answers' can't be answered.
Charles Bailey