C dlopen failed when use dlopen function in the shared library file
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am using CLion with CMake (MinGW) and C language (C11)
I want to create a shared library file with a single function which "dlopen()" function is called inside it (using "dlfcn.h" header). now i want to create an executable file and open the created shared library file but when i try to use "dlopen()" to open the created library file, this function returns an error (126 (can not find)) but if i delete the "dlopen()" function in the created library's function, the library is loaded in executable file without any problem. in fact, the problem is calling the "dlopen()" function in the shared library ... it seams that the library is required the "dlopen()" function Main library !!!!
mysharedlib.c
#include <dlfcn.h>
void hello(void)
{
void * handle = dlopen("xyz.dll", RTLD_LAZY);
}
in this file, the parameters of dlopen function, are not important ... just when i use the "dlopen" function, i got the error to open the library when i build it
executable-file main.c
#include <stdio.h>
#include <dlfcn.h>
int main()
{
void * handle = dlopen("mysharedlib.dll", RTLD_LAZY);
if(handle == NULL)
{
printf("failed to open the shared library");
return 1;
}
return 0;
}
these are 2 diffrents projects ... the first one is my shared library which i tried to open another library inside it and the second project is an executable file which tries to open the project 1 (the shared library)
here in my executable file, i got the "failed to open the shared library" error message !
but if i remove this part from the shared library (project 1),
void * handle = dlopen("xyz.dll", RTLD_LAZY);
and then build the project 1 as a shared library, i get no error and the library will open in executable file without any problem
what is the problem ? why when i use "dlopen" function in a shared library and then I try to open that built library in an executable file, i got error but when i remove the "dlopen" function in the shared library and then i try to open that library in executable file, there is no any problem ?
c shared-libraries dlopen
add a comment |
I am using CLion with CMake (MinGW) and C language (C11)
I want to create a shared library file with a single function which "dlopen()" function is called inside it (using "dlfcn.h" header). now i want to create an executable file and open the created shared library file but when i try to use "dlopen()" to open the created library file, this function returns an error (126 (can not find)) but if i delete the "dlopen()" function in the created library's function, the library is loaded in executable file without any problem. in fact, the problem is calling the "dlopen()" function in the shared library ... it seams that the library is required the "dlopen()" function Main library !!!!
mysharedlib.c
#include <dlfcn.h>
void hello(void)
{
void * handle = dlopen("xyz.dll", RTLD_LAZY);
}
in this file, the parameters of dlopen function, are not important ... just when i use the "dlopen" function, i got the error to open the library when i build it
executable-file main.c
#include <stdio.h>
#include <dlfcn.h>
int main()
{
void * handle = dlopen("mysharedlib.dll", RTLD_LAZY);
if(handle == NULL)
{
printf("failed to open the shared library");
return 1;
}
return 0;
}
these are 2 diffrents projects ... the first one is my shared library which i tried to open another library inside it and the second project is an executable file which tries to open the project 1 (the shared library)
here in my executable file, i got the "failed to open the shared library" error message !
but if i remove this part from the shared library (project 1),
void * handle = dlopen("xyz.dll", RTLD_LAZY);
and then build the project 1 as a shared library, i get no error and the library will open in executable file without any problem
what is the problem ? why when i use "dlopen" function in a shared library and then I try to open that built library in an executable file, i got error but when i remove the "dlopen" function in the shared library and then i try to open that library in executable file, there is no any problem ?
c shared-libraries dlopen
is xyz.dll available to the main process? What happens if you try to dlopen xyz.dll from main()? Without knowing all the details, my guess would be that xyz.dll is not locatable from the main process.
– Shawn
Jan 3 at 22:07
add a comment |
I am using CLion with CMake (MinGW) and C language (C11)
I want to create a shared library file with a single function which "dlopen()" function is called inside it (using "dlfcn.h" header). now i want to create an executable file and open the created shared library file but when i try to use "dlopen()" to open the created library file, this function returns an error (126 (can not find)) but if i delete the "dlopen()" function in the created library's function, the library is loaded in executable file without any problem. in fact, the problem is calling the "dlopen()" function in the shared library ... it seams that the library is required the "dlopen()" function Main library !!!!
mysharedlib.c
#include <dlfcn.h>
void hello(void)
{
void * handle = dlopen("xyz.dll", RTLD_LAZY);
}
in this file, the parameters of dlopen function, are not important ... just when i use the "dlopen" function, i got the error to open the library when i build it
executable-file main.c
#include <stdio.h>
#include <dlfcn.h>
int main()
{
void * handle = dlopen("mysharedlib.dll", RTLD_LAZY);
if(handle == NULL)
{
printf("failed to open the shared library");
return 1;
}
return 0;
}
these are 2 diffrents projects ... the first one is my shared library which i tried to open another library inside it and the second project is an executable file which tries to open the project 1 (the shared library)
here in my executable file, i got the "failed to open the shared library" error message !
but if i remove this part from the shared library (project 1),
void * handle = dlopen("xyz.dll", RTLD_LAZY);
and then build the project 1 as a shared library, i get no error and the library will open in executable file without any problem
what is the problem ? why when i use "dlopen" function in a shared library and then I try to open that built library in an executable file, i got error but when i remove the "dlopen" function in the shared library and then i try to open that library in executable file, there is no any problem ?
c shared-libraries dlopen
I am using CLion with CMake (MinGW) and C language (C11)
I want to create a shared library file with a single function which "dlopen()" function is called inside it (using "dlfcn.h" header). now i want to create an executable file and open the created shared library file but when i try to use "dlopen()" to open the created library file, this function returns an error (126 (can not find)) but if i delete the "dlopen()" function in the created library's function, the library is loaded in executable file without any problem. in fact, the problem is calling the "dlopen()" function in the shared library ... it seams that the library is required the "dlopen()" function Main library !!!!
mysharedlib.c
#include <dlfcn.h>
void hello(void)
{
void * handle = dlopen("xyz.dll", RTLD_LAZY);
}
in this file, the parameters of dlopen function, are not important ... just when i use the "dlopen" function, i got the error to open the library when i build it
executable-file main.c
#include <stdio.h>
#include <dlfcn.h>
int main()
{
void * handle = dlopen("mysharedlib.dll", RTLD_LAZY);
if(handle == NULL)
{
printf("failed to open the shared library");
return 1;
}
return 0;
}
these are 2 diffrents projects ... the first one is my shared library which i tried to open another library inside it and the second project is an executable file which tries to open the project 1 (the shared library)
here in my executable file, i got the "failed to open the shared library" error message !
but if i remove this part from the shared library (project 1),
void * handle = dlopen("xyz.dll", RTLD_LAZY);
and then build the project 1 as a shared library, i get no error and the library will open in executable file without any problem
what is the problem ? why when i use "dlopen" function in a shared library and then I try to open that built library in an executable file, i got error but when i remove the "dlopen" function in the shared library and then i try to open that library in executable file, there is no any problem ?
c shared-libraries dlopen
c shared-libraries dlopen
asked Jan 3 at 20:24
user216085user216085
397
397
is xyz.dll available to the main process? What happens if you try to dlopen xyz.dll from main()? Without knowing all the details, my guess would be that xyz.dll is not locatable from the main process.
– Shawn
Jan 3 at 22:07
add a comment |
is xyz.dll available to the main process? What happens if you try to dlopen xyz.dll from main()? Without knowing all the details, my guess would be that xyz.dll is not locatable from the main process.
– Shawn
Jan 3 at 22:07
is xyz.dll available to the main process? What happens if you try to dlopen xyz.dll from main()? Without knowing all the details, my guess would be that xyz.dll is not locatable from the main process.
– Shawn
Jan 3 at 22:07
is xyz.dll available to the main process? What happens if you try to dlopen xyz.dll from main()? Without knowing all the details, my guess would be that xyz.dll is not locatable from the main process.
– Shawn
Jan 3 at 22:07
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54029297%2fc-dlopen-failed-when-use-dlopen-function-in-the-shared-library-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54029297%2fc-dlopen-failed-when-use-dlopen-function-in-the-shared-library-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
is xyz.dll available to the main process? What happens if you try to dlopen xyz.dll from main()? Without knowing all the details, my guess would be that xyz.dll is not locatable from the main process.
– Shawn
Jan 3 at 22:07