问个C++的问题
Tofloor
poster avatar
billy123456
deepin
2018-07-05 04:48
Author
我在test.cpp上写了函数main()和k(),其中main函数用dlopen加载了libtest.so的i(),编译成test
然后在test1.cpp上写了函数i(),里面调用k(),编译成libtest.so
但是运行时函数i()找不到k(),求怎么把k()暴露给libtest.so



Reply Favorite View the author
All Replies
avatar
weichongjian
deepin
2018-07-05 05:12
#1
试一下在libtest.so用extern声明外面的函数
Reply View the author
avatar
linusboyle
deepin
2018-07-05 06:14
#2
如果没有耦合,把k放和i一起
还有这应该是个c的问题
Reply View the author
Comments
daytrader
2018-07-05 17:49
是的,算是个C语言的问题,感谢解答!
avatar
牧野
deepin
2018-07-05 06:15
#3
这种写回调函数吧~~
Reply View the author
avatar
海天鹰
deepin
2018-07-05 15:56
#4
完整代码呢
Reply View the author
avatar
duanyao
deepin
2018-07-05 18:45
#5
这个问题应该与楼主的相同,加上 -rdynamic and -fPIC
https://www.linuxquestions.org/q ... -shared-lib-750046/
Reply View the author
avatar
billy123456
deepin
2018-07-05 23:03
#6
https://bbs.deepin.org/post/160122
这个问题应该与楼主的相同,加上 -rdynamic and -fPIC
https://www.linuxquestions.org/questions/programm ...

可以了 
Reply View the author
avatar
billy123456
deepin
2018-07-06 02:53
#7
https://bbs.deepin.org/post/160122
这个问题应该与楼主的相同,加上 -rdynamic and -fPIC
https://www.linuxquestions.org/questions/programm ...

这是什么原理呢?
Reply View the author