linking issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi guys,

I'm new to pjsip and run into a weird linking issue.

I checkout the 1.5.5 and latest from svn, build them using "./configure 
&& make dep && make". the whole build goes smoothly. I can even run the 
sample apps.

However, gcc complains "undefined reference to `pj_init'" during linking 
my "hello world". I then copied playsine.c from sample apps and change 
my TARGET to playsine.c. It gives me the same error.

Both 1.5.5 and svn comes out the same. Here's some command outputs as 
well as the source.

Looks like my Makefile is not right. Any suggestions?

Cheers,

Kelvin Chan

---- uname -a ----
Linux debian 2.6.26-2-686 #1 SMP Wed Nov 4 20:45:37 UTC 2009 i686 GNU/Linux

---- gcc -v ----
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 
4.3.2-1.1' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs 
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr 
--enable-shared --with-system-zlib --libexecdir=/usr/lib 
--without-included-gettext --enable-threads=posix --enable-nls 
--with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc 
--enable-mpfr --enable-targets=all --enable-cld 
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu 
--target=i486-linux-gnu
Thread model: posix
gcc version 4.3.2 (Debian 4.3.2-1.1)

---- test.c ----
#include <pjlib.h>
#include <pjlib-util.h>
#include <pjmedia.h>
#include <pjmedia-codec.h>
#include <pjsip.h>
#include <pjsip_simple.h>
#include <pjsip_ua.h>
#include <pjsua-lib/pjsua.h>

#define LOG_1(m) (1, (__FILE__,m))
#define LOG_2(m) (2, (__FILE__,m))
#define LOG_3(m) (3, (__FILE__,m))
#define LOG_4(m) (4, (__FILE__,m))

#define LOG(m) LOG_3(m)

int main(int argv, char **argc)
{
     pj_status_t res;

     res = pj_init();

     LOG("Hello World!");

     return 0;
}

---- Makefile ----
TARGET = test

PJBASE = /usr/local/src/pjproject
include $(PJBASE)/build.mak
CC      = $(PJ_CC)
CFLAGS  = $(PJ_CFLAGS)
LDLIBS  = $(PJ_LDLIBS)
LDFLAGS = $(PJ_LDFLAGS) $(LDLIBS)

$(TARGET): $(TARGET).o
     $(CC) $(LDFLAGS) -o $@ $<

.c.o: %.c
     $(CC) -c $(CFLAGS) -o $@ $<

.PHONY: all clean

all: $(TARGET)

clean:
     $(RM) $(TARGET) *.o


---- build output ----
debian:~/pjmedia# make
gcc -c -DPJ_AUTOCONF=1 -O2 -I/usr/local/src/pjproject/pjlib/include 
-I/usr/local/src/pjproject/pjlib-util/include 
-I/usr/local/src/pjproject/pjnath/include 
-I/usr/local/src/pjproject/pjmedia/include 
-I/usr/local/src/pjproject/pjsip/include -o test.o test.c
gcc -L/usr/local/src/pjproject/pjlib/lib 
-L/usr/local/src/pjproject/pjlib-util/lib 
-L/usr/local/src/pjproject/pjnath/lib 
-L/usr/local/src/pjproject/pjmedia/lib 
-L/usr/local/src/pjproject/pjsip/lib 
-L/usr/local/src/pjproject/third_party/lib  -lpjsua-i686-pc-linux-gnu 
-lpjsip-ua-i686-pc-linux-gnu -lpjsip-simple-i686-pc-linux-gnu 
-lpjsip-i686-pc-linux-gnu -lpjmedia-codec-i686-pc-linux-gnu 
-lpjmedia-i686-pc-linux-gnu -lpjmedia-audiodev-i686-pc-linux-gnu 
-lpjnath-i686-pc-linux-gnu -lpjlib-util-i686-pc-linux-gnu 
-lresample-i686-pc-linux-gnu -lmilenage-i686-pc-linux-gnu 
-lsrtp-i686-pc-linux-gnu -lgsmcodec-i686-pc-linux-gnu 
-lspeex-i686-pc-linux-gnu -lilbccodec-i686-pc-linux-gnu 
-lg7221codec-i686-pc-linux-gnu -lportaudio-i686-pc-linux-gnu 
-lpj-i686-pc-linux-gnu -lm -lnsl -lrt -lpthread  -o test test.o
test.o: In function `main':
test.c:(.text+0x12): undefined reference to `pj_init'
collect2: ld returned 1 exit status
make: *** [test] Error 1
debian:~/pjmedia#





[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux