openzwave-1.4.164 移植到MTK openwrt-3.10.14 遇到的一些坑

匿名 (未验证) 提交于 2019-12-03 00:25:02
openzwave-1.4.164 移植到MTK openwrt-3.10.14 遇到的一些坑
一)wcsdup的编译错误
http://www.man7.org/linux/man-pages/man3/wcsdup.3.html
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
       wcsdup():
           Since glibc 2.10:
               _POSIX_C_SOURCE >= 200809L
           Before glibc 2.10:
               _GNU_SOURCE
【解决办法】
修改cpp\hidapi\libusb\hid.c,增加如下行
#define _GNU_SOURCE /* needed for wcsdup() before glibc 2.10 */

二)解决静态库编译问题
Creating vers.cpp
Building vers.o
Linking Static Library
mipsel-openwrt-linux-uclibc-ar: invalid option -- '/'
Usage: mipsel-openwrt-linux-uclibc-ar [emulation options] [-]{dmpqrstx}[
abcDfilMNoPsSTuvV] [member-name] [count] archive-file file...
       mipsel-openwrt-linux-uclibc-ar -M [<mri-script]
 commands:
  d            - delete file(s) from the archive
  m[ab]        - move file(s) in the archive
  p            - print file(s) found in the archive
  q[f]         - quick append file(s) to the archive
  r[ab][f][u]  - replace existing or insert new file(s) into the archive
  s            - act as ranlib
  t            - display contents of archive
  x[o]         - extract file(s) from the archive
 command specific modifiers:
  [a]          - put file(s) after [member-name]
  [b]          - put file(s) before [member-name] (same as [i])
  [D]          - use zero for timestamps and uids/gids
  [N]          - use instance [count] of name
  [f]          - truncate inserted file names
  [P]          - use full path names when matching
  [o]          - preserve original dates
  [u]          - only replace files that are newer than current archive
contents
 generic modifiers:
  [c]          - do not warn if the library had to be created
  [s]          - create an archive index (cf. ranlib)
  [S]          - do not build a symbol table
  [T]          - make a thin archive
  [v]          - be verbose
  [V]          - display the version number
  @<file>      - read options from <file>
  --target=BFDNAME - specify the target object format as BFDNAME
 emulation options:
  No emulation specific options
mipsel-openwrt-linux-uclibc-ar: supported targets: elf32-tradlittlemips elf32-
tradbigmips ecoff-littlemips ecoff-bigmips elf32-ntradlittlemips elf64-
tradlittlemips elf32-ntradbigmips elf64-tradbigmips elf64-little elf64-big
elf32-little elf32-big srec symbolsrec verilog tekhex binary ihex
make[5]: *** [/home/pengfeiz/openwrt/mt7621_7623/20150311/openwrt-3.10.14/
build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/openzwave/libopenzwave.a]
Error 1
make[5]: Leaving directory `/home/pengfeiz/openwrt/mt7621_7623/20150311/
openwrt-3.10.14/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/openzwave/
cpp/build'
make[4]: *** [all] Error 2

【解决办法】
修改cpp\build\Makefile
 @echo "Linking Static Library"
# @$(AR) $@ $+
 @$(AR) cqs $@ $+
 @$(RANLIB) $@

三)解决编译动态库问题
Linking Shared Library
mipsel-openwrt-linux-uclibc-ld: unrecognized option '-Wl,-soname,libopenzwave.
so.1.4'
mipsel-openwrt-linux-uclibc-ld: use the --help option for usage information
【解决办法】
修改cpp\build\Makefile
#LDFLAGS += -shared -Wl,-soname,libopenzwave.so.$(VERSION)
LDFLAGS += -shared -soname libopenzwave.so.$(VERSION)

四)编译MinOZW时的问题
Linking /openwrt-3.10.14/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/
openzwave/.lib/MinOZW
mipsel-openwrt-linux-uclibc-ld -L/openwrt-3.10.14/staging_dir/target-
mipsel_24kec+dsp_uClibc-0.9.33.2/usr/lib -L/openwrt-3.10.14/staging_dir/target
-mipsel_24kec+dsp_uClibc-0.9.33.2/lib -L/openwrt-3.10.14/staging_dir/toolchain
-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/usr/lib -L/openwrt-3.10.14/
staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/lib    
-o /openwrt-3.10.14/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/
openzwave/.lib/MinOZW /openwrt-3.10.14/build_dir/target-mipsel_24kec+
dsp_uClibc-0.9.33.2/openzwave/.lib/Main.o /openwrt-3.10.14/build_dir/target-
mipsel_24kec+dsp_uClibc-0.9.33.2/openzwave/libopenzwave.so -pthread
mipsel-openwrt-linux-uclibc-ld: unrecognized option '-pthread'
mipsel-openwrt-linux-uclibc-ld: use the --help option for usage information
make[5]: *** [/openwrt-3.10.14/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33
.2/openzwave/.lib/MinOZW] Error 1

/openwrt-3.10.14/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/openzwave/
libopenzwave.so -lpthread -lc -ludev
mipsel-openwrt-linux-uclibc-ld: warning: cannot find entry symbol __start;
defaulting to 0000000000400f10
/openwrt-3.10.14/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/openzwave/.
lib/Main.o: In function `_Z41__static_initialization_and_destruction_0ii.part.
37':
Main.cpp:(.text+0x28): undefined reference to `operator delete(void*)'
Main.cpp:(.text+0x4c): undefined reference to `std::ios_base::Init::~Init()'
/openwrt-3.10.14/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/openzwave/.
lib/Main.o: In function `OnNotification(OpenZWave::Notification const*, void*)
':
Main.cpp:(.text+0x138): undefined reference to `std::__detail::_List_node_base
::_M_unhook()'
Main.cpp:(.text+0x140): undefined reference to `operator delete(void*)'
Main.cpp:(.text+0x1c4): undefined reference to `operator new(unsigned int)'

hidden symbol ... is referenced by DSO
mipsel-openwrt-linux-uclibc/bin/ld: final link failed: Bad value
【解决办法】
1)修改cpp\examples\MinOZW\Makefile
$(OBJDIR)/MinOZW: $(patsubst %.cpp,$(OBJDIR)/%.o,$(minozwsrc))
 @echo "Linking $(OBJDIR)/MinOZW"
# $(LD) $(LDFLAGS) $(TARCH) -o $@ $< $(LIBS) -pthread
 $(CXX) $(LDFLAGS) $(TARCH) -o $@ $< -ludev -lc -lpthread $(LIBS)

2)修改cpp\build\Makefile
编译libopenzwave.so 动态库时,添加上-lgcc_s -lc

else
#LDFLAGS += -shared -Wl,-soname,libopenzwave.so.$(VERSION)
LDFLAGS += -shared -fPIC -soname libopenzwave.so.$(VERSION)
LIBS  += -ludev -lgcc_s -lc
endif
CFLAGS  += $(CPPFLAGS)


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!