2015-02-10 90 views
2

我從使用lib555編譯程序中得到這個錯誤。我看來,我失去了一些東西在Makefile:每個live555元素的undefined參考

testrtsp.o: In function `main': 
testrtsp.cpp:(.text+0x470): undefined reference to BasicTaskScheduler::createNew(unsigned int)' 
testrtsp.cpp:(.text+0x480): undefined reference to `BasicUsageEnvironment::createNew(TaskScheduler&)' 
testrtsp.cpp:(.text+0x49c): undefined reference to `Port::Port(unsigned short)' 
testrtsp.cpp:(.text+0x4b0): undefined reference to `RTSPServer::createNew(UsageEnvironment&, Port, UserAuthenticat 
ionDatabase*, unsigned int)' 

collect2: error: ld returned 1 exit status 
Makefile:64: recipe for target 'testrtsp' failed 

我的Makefile文件看起來是這樣的:

# generated from pkg-config --cflags gstreamer-0.10 
CFLAGS=-pthread -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libxml2 

LIVE_INCLUDES=-I/home/root/live/UsageEnvironment/include -I/home/root/live/groupsock/include -I/home/root/live/liveMedia/include -I/home/root/live/BasicUsageEnvironment/include 
LIVE_LIBS=/home/root/live/liveMedia/libliveMedia.a /home/root/live/groupsock/libgroupsock.a /home/root/live/BasicUsageEnvironment/libBasicUsageEnvironment.a /home/root/live/UsageEnvironment/libUsageEnvironment.a 

LIVE_LIBS+=-lpthread   
         CXXFLAGS=$(CFLAGS)                
    # generated from pkg-config --libs gstreamer-0.10 
LDFLAGS=-lgstreamer-0.10 -lgobject-2.0 -lgmodule-2.0 -pthread -lgthread-2.0 -pthread -lglib-2.0 -lxml2 -lgstapp-0.10 

CFLAGS+=-I/usr/include/opencv2       
CFLAGS+=-I/home/root/live/liveMedia/include    
CFLAGS+=-I/home/root/live/groupsock/include   
CFLAGS+=-I/home/root/live/UsageEnvironment/include 
CFLAGS+=-I/usr/include/gtk-2.0     
CFLAGS+=-I/usr/include/cairo       
CFLAGS+=-I/usr/inlcude/pango-1.0       
CFLAGS+=-I/usr/lib/gtk-2.0/include      
CFLAGS+=-I/usr/include/gdk-pixbuf-2.0       
CFLAGS+=-I/usr/include/atk-1.0       
CFLAGS+=-I/usr/include/rtsp-server      
CFLAGS+=-I/home/root/live/BasicUsageEnvironment/include/  
CFLAGS+=-I/usr/include/ 

LDFLAGS+=-lstdc++ -lopencv_core -lopencv_features2d -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_video 

all: testrtsp 
testrtsp: testrtsp.o              
      gcc -L. $(LDFLAGS) -o [email protected] $(LIVE_LIBS) $<         

      testrtsp.o: testrtsp.cpp             


       gcc -c $(CFLAGS) $(LIVE_INCLUDES) -o [email protected] $< 

我包括我的程序所需的所有LIVE555頭。

編輯:右側的切斷應該是固定的

+0

你縮進的是一個爛攤子,你可以請清理。此外,您的線條似乎在右側被切斷了一點。 – 2015-02-10 19:35:12

回答

1

該解決方案非常簡單。我改變了這一點:

testrtsp:testrtsp.o              
gcc -L. $(LDFLAGS) -o [email protected] $(LIVE_LIBS) $< 

這樣:

testrtsp: testrtsp.o              
gcc -L. $(LDFLAGS) -o [email protected] $< $(LIVE_LIBS) 
+0

這個解決方案並不適合我。對我來說,以錯誤的順序鏈接沒有工作,給了我很多未定義的參考。使用您在makefile中使用的相同順序適用於我=) – Micka 2015-06-29 11:13:14