zlgopen / awtk-linux-fb

awtk port for linux framebuffer
110 stars 49 forks source link

怎么加载外部头文件和.so库文件 #22

Closed WeSrc-Yin closed 5 years ago

WeSrc-Yin commented 5 years ago

我自己写了一个程序,你就当它是类似于awtk-examples里面的某个例子吧,然后,我要用到以前写的一个程序库文件(.so文件)及一些头文件,那我要怎么把库文件和头文件编译进去?我要把它移植到arm-linux板子上。

xianjimli commented 5 years ago

以awtk-hello为例,你把自己的库加到APP_LIBS里就行了:

APP_LIBS = ['assets']
APP_LIBPATH = [APP_LIB_DIR]

DefaultEnvironment(
  CPPPATH   = awtk.CPPPATH,
  LINKFLAGS = awtk.LINKFLAGS,
  LIBS      = APP_LIBS + awtk.LIBS,
  LIBPATH   = APP_LIBPATH + awtk.LIBPATH,
  CCFLAGS   = APP_CCFLAGS + awtk.CCFLAGS, 
  OS_SUBSYSTEM_CONSOLE=awtk.OS_SUBSYSTEM_CONSOLE,
  OS_SUBSYSTEM_WINDOWS=awtk.OS_SUBSYSTEM_WINDOWS)
WeSrc-Yin commented 5 years ago

多谢回复,但还是编译报错:/usr/bin/ld: skipping incompatible lib/libBle.so when searching for -lBle /usr/bin/ld: cannot find -lBle

是不是路径设置不对?请指教。

我现在是这么做的: 我的库文件是libBle.so,libBleSch.so我把他们放在awtk-hello/lib/目录下,然后修改sconstruct如下: import os import sys import platform

sys.path.insert(0, '../awtk/') import awtk_config as awtk

APP_ROOT = os.path.normpath(os.getcwd()) APP_BIN_DIR = os.path.join(APP_ROOT, 'bin') APP_LIB_DIR = os.path.join(APP_ROOT, 'lib')

os.environ['APP_ROOT'] = APP_ROOT; os.environ['BIN_DIR'] = APP_BIN_DIR; os.environ['LIB_DIR'] = APP_LIB_DIR;

APP_CCFLAGS = '' APP_LIBS = ['libBlu.so'] APP_LIBS =APP_LIBS + ['libBluSch.so'] APP_LIBPATH = [APP_LIB_DIR]

DefaultEnvironment( CPPPATH = awtk.CPPPATH, LINKFLAGS = awtk.LINKFLAGS, LIBS = APP_LIBS + awtk.LIBS, LIBPATH = APP_LIBPATH + awtk.LIBPATH, CCFLAGS = APP_CCFLAGS + awtk.CCFLAGS, OS_SUBSYSTEM_CONSOLE=awtk.OS_SUBSYSTEM_CONSOLE, OS_SUBSYSTEM_WINDOWS=awtk.OS_SUBSYSTEM_WINDOWS)

SConscript(['src/SConscript'])

WeSrc-Yin commented 5 years ago

问题转移到awtk那边去,这里关闭