Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
127 views
in Technique[技术] by (71.8m points)

c++ - API function called from within another API function of the same library - turns out to not be from the same library

I'm working with linux64 C/C++. I have an *.so library that has a set of API function calls (all properly defined).

All is fine if I load this library from the .exe file without its full path (libName) - via dlopen(libName, RTLD_LAZY) - then dlopen() will search, for example LD_LIBRARY_PATH, and if it finds libName it will load it. Then, when I call a specific API function (e.g. function1_api(HBML* handle)), and within this function another API function is called from the same library (e.g. function2_api(HBML* handle)) - all is OK, and I have printouts from both functions with their handles and the handles are identical.

However, if I load the library with its full path - then I have the following anomaly. The first API function that I call is fine (function1_api(HBML* handle)), and I see my printout with a handle value. However, I do not see any printout whatsoever for the 2nd API function (function2_api(HBML* handle)) that is called from within the first. The 2nd API function then returns an error - as if the handle it is using is not the same as the first function's handle. Here dlopen() does not have to search for the library as its full path is given.

Any explanation of what is going on?

question from:https://stackoverflow.com/questions/65892135/api-function-called-from-within-another-api-function-of-the-same-library-turns

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...