2015-02-10 95 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