Yuvi
Yuvi

Reputation: 1350

Getting undefined reference in Shared Library

I have created an sample shared library, that uses libcurl. Here is the corresponding Makefile to create shared library:

CC= arm-none-linux-gnueabi-gcc
CPPFLAGS= -I/home/yuvi/development/libcurl/curl-7.24.0/build_arm/include -Wall -g 
LDFLAGS= -L/home/yuvi/development/libcurl/curl-7.24.0/build_arm/lib \
    -l:libcurl.a -l:libssh2.a -l:libssl.a -l:libcrypto.a  \
    -L/home/yuvi/development/CD/VAR-SOM-OM35_VAR-SOM-OM37_VAR-SOM-AM35/Software/Linux/host_tools/linux/arm-2009q3/arm-none-linux-gnueabi/libc/lib -lrt 

all: resume.o libresume.so

resume.o:
    $(CC) $(CPPFLAGS) -c -fPIC resume_download.c -o resume_download.o $(LDFLAGS) 

libresume.so:
    $(CC)  -shared -Wl,-soname,libresume.so.1 -o libresume.so  resume_download.o

clean:
    rm -f resume_download.o libresume.so

Now I have created one sample program that gonna to use this shared library, the Makefile for that program is :

CC= arm-none-linux-gnueabi-gcc
CPPFLAGS= -I/home/yuvi/development/libcurl/curl-7.24.0/build_arm/include -Wall -g 
LDFLAGS= -L/home/yuvi/development/libcurl/curl-7.24.0/build_arm/lib \
    -l:libcurl.a -l:libssh2.a -l:libssl.a -l:libcrypto.a  \
    -L/home/yuvi/development/CD/VAR-SOM-OM35_VAR-SOM-OM37_VAR-SOM-AM35/Software/Linux/host_tools/linux/arm-2009q3/arm-none-linux-gnueabi/libc/lib -lrt \
    -L/home/yuvi/development/libcurl/sample_program -lresume 

all:
    $(CC) $(CPPFLAGS) resume_app.c -o app $(LDFLAGS)

But If I make the above Makefile, I am getting the following errors :

/home/yuvi/development/libcurl/sample_program/libresume.so: undefined reference to `curl_easy_setopt'
/home/yuvi/development/libcurl/sample_program/libresume.so: undefined reference to `curl_global_cleanup'
/home/yuvi/development/libcurl/sample_program/libresume.so: undefined reference to `curl_easy_init'
/home/yuvi/development/libcurl/sample_program/libresume.so: undefined reference to `curl_easy_perform'
/home/yuvi/development/libcurl/sample_program/libresume.so: undefined reference to `curl_easy_cleanup'
/home/yuvi/development/libcurl/sample_program/libresume.so: undefined reference to `curl_global_init

Now how can I eliminate these error, Is there something wrong in creating shared library or compiling sample program. Please Help....!

Upvotes: 0

Views: 2842

Answers (1)

nos
nos

Reputation: 229098

Add -lresume before libcurl

-lresume  -l:libcurl.a -l:libssh2.a -l:libssl.a -l:libcrypto.a  .... 

Upvotes: 2

Related Questions