0

我修改了一个makefile并试图编译一个项目。但它只是第一步失败。

即使我已经指定了编译模式规则,wrt :--
http://www.gnu.org/software/make/manual/make.html#Static-Usage

生成文件是:-

# topdir for wxWidgets base 
top_builddir = /opt/wxgtk
EXTRALIBS = -pthread -lz -ldl -lm
LDLIBS = ${APPEXTRALIBS} ${top_builddir}/lib/libwx_baseu-2.8.a ${EXTRALIBS}
CXX         = c++

CXXFLAGS = -g -O0 -pthread -I/usr/include/SDL -D_REENTRANT -Wall -Wno-ctor-dtor-privacy
CPPFLAGS = -D__WXDEBUG__  -I${top_builddir}/wx/include/base-unicode-release-static-2.8  -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D_LARGEFILE_SOURCE=1
CFLAGS = ${APPEXTRACFLAGS} ${CPPFLAGS} -O2 -MMD -pthread -Wall
CFLAGS  += -DLINUX

CANALOBJS =     ../../common/listenthread_unix.o ../../common/clientthread_level1_unix.o ../../common/devicethread_unix.o \
        ../../common/canalshmem_level1_unix.o ../../common/clientlist.o ../../common/controlobject.o \
        ../../common/devicelist.o ../../common/udpreceivethread_unix.o ../../../vscp/common/vscp.o \
        ../../common/clientthread_level2_unix.o ../../common/canalshmem_level2_unix.o \
        ../../common/tcplistenthread.o
CANALHDRS = ../../common/clientlist.h ../../common/controlobject.h ../../common/devicelist.h \
        ../../common/canal.h ../../common/canaldlldef.h \
        ../../common/version.h ../../common/canal_unix_ipc.h ../../common/CanalShMem_level1_unix.h \
        ../../common/CanalShMem_level2_unix.h ../../common/clientthread_level1_unix.h ../../common/clientthread_level2_unix.h
PROJOBJS    = ../../../common/dllist.o ../../../common/configfile.o ../../../common/crc.o
PROJHDRS    = ../../../common/dllist.h ../../../common/configfile.h
OBJS        = canald.o
HDRS        = canald.h

all:        canald

# Build the Linux executable
canald:     $(OBJS) $(HDRS) $(CANALOBJS) $(CANALHDR) $(PROJOBJS) $(PROJHDRS)
        $(CXX)  -o canald $(OBJS) $(CANALOBJS) $(PROJOBJS) -L$(LIBS) $(LDLIBS)

$(OBJS) $(CANALOBJS) $(PROJOBJS):%.o: %.cpp
        $(CXX) -c $(CFLAGS) $< -o $@

我得到的错误:--

make
make: *** No rule to make target `canald.cpp', needed by `canald.o'.  Stop.

请建议如何解决此错误?

已编辑:--------

文件丢失...正在编译...但出现以下错误

vscpd.cpp:47:19: fatal error: wx/wx.h: No such file or directory
compilation terminated.
make: *** [vscpd.o] Error 1

我在以下位置安装了 wxgtk :---

/opt/wxgtk

.profile 已修改:--

PATH = $PATH:/opt/wxgtk
export LD_LIBRARY_PATH=/usr/lib:/usr/local/lib:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/opt/wxgtk/lib:$LD_LIBRARY_PATH

make 找不到

#include<wx/wx.h> 

如何解决?

4

1 回答 1

1

必须使用wx-config而不是直接指定包含路径,请参见例如this answer

您的 makefile 很奇怪,因为您CXXFLAGS只定义了从不使用它,而是将CPPFLAGS其用作CFLAGS. 因此,在您的情况下,您需要用调用替换CPPFLAGS定义,例如wx-config

WX_CONFIG := /opt/wxgtk/bin/wx-config
CPPFLAGS := $(shell $(WX_CONFIG) --cxxflags)

更好的是,摆脱CPPFLAGS并像这样定义CXXFLAGS并使用它。

还要更新您LDLIBS的使用wx-config

LDLIBS := ${APPEXTRALIBS} $(shell $(WX_CONFIG) --libs)

EXTRALIBS通常不再需要)。

于 2013-03-27T18:31:14.137 回答