Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

找不到动态库so文件的问题 #21

Open
duanchangstar opened this issue Mar 5, 2021 · 5 comments
Open

找不到动态库so文件的问题 #21

duanchangstar opened this issue Mar 5, 2021 · 5 comments

Comments

@duanchangstar
Copy link

编译awtk-mvvm-c-hello,在ubuntu下运行正常
然后交叉编译移植到arm上,编译没有问题。
执行程序时出现如下错误:
root@TinaLinux:/mnt/SDCARD/tttt-mvvm/bin# ./demo
Error loading shared library libtable_view_mvvm.so: No such file or directory (needed by ./demo)
Error loading shared library libslidable_row.so: No such file or directory (needed by ./demo)
Error loading shared library libtable_view.so: No such file or directory (needed by ./demo)
Error loading shared library libui_automation.so: No such file or directory (needed by ./demo)
Error loading shared library libhttpd.so: No such file or directory (needed by ./demo)
Error loading shared library libmvvm.so: No such file or directory (needed by ./demo)
Error loading shared library libawtk.so: No such file or directory (needed by ./demo)

库文件已经放到程序demo的同目录,还放了一份到 tttt-mvvm/lib 里面,都一样。
在Sconscript里面,加入LIBPATH=['#/bin','#/lib'],如下:
env.Program(os.path.join(BIN_DIR, 'demo'), Glob('application.c'), LIBS=['awtk_mvvm_app'] + env['LIBS'],LIBPATH=['#/bin','#/lib']);
依然没用。
在helper里加入add_libpath,也是一样问题。

求教如何在编译时,在程序里加入编译后的动态库搜索目录 (不想因为某个app修改linux环境变量),谢谢

@xianjimli
Copy link
Member

编译时找不到库和运行时找不到库时两回事。

运行时找不到,先看bin目录里是否有需要的库(而且是交叉编译的,别把PC版本的拷贝过去里),再看看LD_LIBRARY_PATH是否正确。

@duanchangstar
Copy link
Author

duanchangstar commented Mar 5, 2021

我明白,编译一直没有问题。控制台用export LD_LIBRARY_PATH指令,执行以后就可以运行程序了。库文件就在bin目录下,跟主程序在同一个目录,加了export才能找到库文件。
但用export LD_LIBRARY_PATH并不是一个好的做法,量产可能要出问题。把动态库复制到Linux系统目录下更不可取。

我想问的是,如何在编译的时候,就指定程序搜索动态库的目录。类似-Wl,-rpath这样编译器的指令。运行程序就不需要去修改arm-linux的系统环境变量。
awtk里很多用到Scons脚本,这块不是很熟悉。

@ufbycd
Copy link

ufbycd commented May 17, 2021

编译时找不到库和运行时找不到库时两回事。

运行时找不到,先看bin目录里是否有需要的库(而且是交叉编译的,别把PC版本的拷贝过去里),再看看LD_LIBRARY_PATH是否正确。

我也发现在嵌入式平台上mvvm很难部署,究其原因:awtk的awtk_config.py配置文件只支持x86平台,“awtk/tools”目录也没有考虑交叉编译的情况。而最根本的原因应该是官方目前对于mvvm都只是在x86平台上做测试。

@xianjimli
Copy link
Member

嵌入式Linux系统用awtk-linux-fb编译,交叉编译配置在awtk-linux-fb/awtk_config.py中。

@ufbycd
Copy link

ufbycd commented May 17, 2021

嵌入式Linux系统用awtk-linux-fb编译,交叉编译配置在awtk-linux-fb/awtk_config.py中。

哦,要加编译参数 LINUX_FB=true,之前没留意。
awtk-linux-fb/awtk_config.py中的copySharedLib函数应该要修改下,否则有些库没有复制过来

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants