Hi,
I want to dynamically load a DLL created by MSVC from a program compiled with MinGW. I see the FAQ page: http://www.mingw.org/wiki/MSVC_and_MinGW_DLLs which says how to to create a Windows .LIB file from DLL sources that links against a MinGW-compiled C file. This approach loads the DLL code automatically when the main program runs. But I want to load the DLL dynamically, depending on the execution of the program. Originally, I had compiled the DLL using MinGW, and loaded the DLL using dlopen(). Once loaded, the code used dlsym() to obtain function entry points. The MinGW code was linked against libdl.dll.a. Will that approach work with MSVC-compiled DLLs? Is the format of an MSVC DLL the same a MinGW library created with the -shared flag? -- Paul -- Paul Steckler National ICT Australia paul DOT steckler AT nicta.com.au The information in this e-mail may be confidential and subject to legal professional privilege and/or copyright. National ICT Australia Limited accepts no liability for any damage caused by this email or its attachments. ------------------------------------------------------------------------------ AppSumo Presents a FREE Video for the SourceForge Community by Eric Ries, the creator of the Lean Startup Methodology on "Lean Startup Secrets Revealed." This video shows you how to validate your ideas, optimize your ideas and identify your business strategy. http://p.sf.net/sfu/appsumosfdev2dev _______________________________________________ MinGW-users mailing list [hidden email] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users Also: mailto:[hidden email]?subject=unsubscribe |
On 7/15/2011 13:41, Paul Steckler wrote:
> Hi, > > I want to dynamically load a DLL created by MSVC from a program compiled > with MinGW. > > I see the FAQ page: > > http://www.mingw.org/wiki/MSVC_and_MinGW_DLLs > > which says how to to create a Windows .LIB file from DLL sources that links against > a MinGW-compiled C file. This approach loads the DLL code automatically when > the main program runs. > > But I want to load the DLL dynamically, depending on the execution of the program. > Originally, I had compiled the DLL using MinGW, and loaded the DLL using > dlopen(). Once loaded, the code used dlsym() to obtain function entry points. > The MinGW code was linked against libdl.dll.a. > > Will that approach work with MSVC-compiled DLLs? Is the format of an MSVC > DLL the same a MinGW library created with the -shared flag? > different C libraries. ------------------------------------------------------------------------------ AppSumo Presents a FREE Video for the SourceForge Community by Eric Ries, the creator of the Lean Startup Methodology on "Lean Startup Secrets Revealed." This video shows you how to validate your ideas, optimize your ideas and identify your business strategy. http://p.sf.net/sfu/appsumosfdev2dev _______________________________________________ MinGW-users mailing list [hidden email] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users Also: mailto:[hidden email]?subject=unsubscribe |
In reply to this post by Paul Steckler
On 7/15/2011 1:41 AM, Paul Steckler wrote:
> Will that approach work with MSVC-compiled DLLs? Is the format of an MSVC > DLL the same a MinGW library created with the -shared flag? DLL format is defined by OS and does not depend on compiler or language. As long as you have the correct function signature - you would be fine. ------------------------------------------------------------------------------ AppSumo Presents a FREE Video for the SourceForge Community by Eric Ries, the creator of the Lean Startup Methodology on "Lean Startup Secrets Revealed." This video shows you how to validate your ideas, optimize your ideas and identify your business strategy. http://p.sf.net/sfu/appsumosfdev2dev _______________________________________________ MinGW-users mailing list [hidden email] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users Also: mailto:[hidden email]?subject=unsubscribe |
On Fri, Jul 15, 2011 at 10:31 AM, George Brink <[hidden email]> wrote:
> On 7/15/2011 1:41 AM, Paul Steckler wrote: >> Will that approach work with MSVC-compiled DLLs? Is the format of an MSVC >> DLL the same a MinGW library created with the -shared flag? > DLL format is defined by OS and does not depend on compiler or language. > As long as you have the correct function signature - you would be fine. Really? What about c++ name mangling, and exception handling? ------------------------------------------------------------------------------ AppSumo Presents a FREE Video for the SourceForge Community by Eric Ries, the creator of the Lean Startup Methodology on "Lean Startup Secrets Revealed." This video shows you how to validate your ideas, optimize your ideas and identify your business strategy. http://p.sf.net/sfu/appsumosfdev2dev _______________________________________________ MinGW-users mailing list [hidden email] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users Also: mailto:[hidden email]?subject=unsubscribe |
On 7/17/2011 2:57 PM, NightStrike wrote:
> On Fri, Jul 15, 2011 at 10:31 AM, George Brink<[hidden email]> wrote: >> On 7/15/2011 1:41 AM, Paul Steckler wrote: >>> Will that approach work with MSVC-compiled DLLs? Is the format of an MSVC >>> DLL the same a MinGW library created with the -shared flag? >> DLL format is defined by OS and does not depend on compiler or language. >> As long as you have the correct function signature - you would be fine. > > Really? What about c++ name mangling, and exception handling? > Yes, really. Name mangling comes from function/variable types and I said "Correct function signature", didn't I? Exception handling is a completely different matter. It depends on which CRLs were used to compile DLL and EXE. And in general exceptions should be restricted to inside DLL-only and EXE-only. Same problem as with memory management, by the way. But those problems do not depend on how you link EXE with DLL, you would have them in both cases. ------------------------------------------------------------------------------ Storage Efficiency Calculator This modeling tool is based on patent-pending intellectual property that has been used successfully in hundreds of IBM storage optimization engage- ments, worldwide. Store less, Store more with what you own, Move data to the right place. Try It Now! http://www.accelacomm.com/jaw/sfnl/114/51427378/ _______________________________________________ MinGW-users mailing list [hidden email] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users Also: mailto:[hidden email]?subject=unsubscribe |
In reply to this post by Paul Steckler
There's really no magic to LoadLibrary and GetProcAddress. I'll
assume you don't want to do silly things like pass a FILE* from a fopen in mingw to this other library, cause the other will have no clue about it. posix I guess is dlopen and dlsym either one of which can be #defined to look like the other. On Thu, Jul 14, 2011 at 10:41 PM, Paul Steckler <[hidden email]> wrote: > Hi, > > I want to dynamically load a DLL created by MSVC from a program compiled > with MinGW. > > I see the FAQ page: > > http://www.mingw.org/wiki/MSVC_and_MinGW_DLLs > > which says how to to create a Windows .LIB file from DLL sources that links against > a MinGW-compiled C file. This approach loads the DLL code automatically when > the main program runs. > > But I want to load the DLL dynamically, depending on the execution of the program. > Originally, I had compiled the DLL using MinGW, and loaded the DLL using > dlopen(). Once loaded, the code used dlsym() to obtain function entry points. > The MinGW code was linked against libdl.dll.a. > > Will that approach work with MSVC-compiled DLLs? Is the format of an MSVC > DLL the same a MinGW library created with the -shared flag? > > -- Paul > -- > Paul Steckler > National ICT Australia > paul DOT steckler AT nicta.com.au > > The information in this e-mail may be confidential and subject to legal professional privilege and/or copyright. National ICT Australia Limited accepts no liability for any damage caused by this email or its attachments. > > ------------------------------------------------------------------------------ > AppSumo Presents a FREE Video for the SourceForge Community by Eric > Ries, the creator of the Lean Startup Methodology on "Lean Startup > Secrets Revealed." This video shows you how to validate your ideas, > optimize your ideas and identify your business strategy. > http://p.sf.net/sfu/appsumosfdev2dev > _______________________________________________ > MinGW-users mailing list > [hidden email] > > This list observes the Etiquette found at > http://www.mingw.org/Mailing_Lists. > We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. > > _______________________________________________ > You may change your MinGW Account Options or unsubscribe at: > https://lists.sourceforge.net/lists/listinfo/mingw-users > Also: mailto:[hidden email]?subject=unsubscribe > ------------------------------------------------------------------------------ Magic Quadrant for Content-Aware Data Loss Prevention Research study explores the data loss prevention market. Includes in-depth analysis on the changes within the DLP market, and the criteria used to evaluate the strengths and weaknesses of these DLP solutions. http://www.accelacomm.com/jaw/sfnl/114/51385063/ _______________________________________________ MinGW-users mailing list [hidden email] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users Also: mailto:[hidden email]?subject=unsubscribe |
In reply to this post by Paul Steckler
I wrote:
> But I want to load the DLL dynamically, depending on the execution of the program. > Originally, I had compiled the DLL using MinGW, and loaded the DLL using > dlopen(). Once loaded, the code used dlsym() to obtain function entry points. > The MinGW code was linked against libdl.dll.a. I went ahead and did the experiment -- and everything works! Our DLLs are wrappers around a commercial library. The code that loads the DLLs uses some header files provided for using that library. It would've been nice to compile the whole thing in MinGW. Unfortunately, the MinGW header files don't provide the datatype _locale_t, referenced in the commercial library's header files, and defined in the MSVC headers, and the MinGW libraries don't provide some locale-related functions offered in MSVC libraries. The solution was to copy some of the MSVC datatypes into the MinGW build, which allowed the client code to compile. That client code doesn't actually use any locale-related functions. The DLL code does use locale-related functions, so it needs to be built with MSVC and link with its libraries. -- Paul -- Paul Steckler National ICT Australia paul DOT steckler AT nicta.com.au The information in this e-mail may be confidential and subject to legal professional privilege and/or copyright. National ICT Australia Limited accepts no liability for any damage caused by this email or its attachments. ------------------------------------------------------------------------------ 10 Tips for Better Web Security Learn 10 ways to better secure your business today. Topics covered include: Web security, SSL, hacker attacks & Denial of Service (DoS), private keys, security Microsoft Exchange, secure Instant Messaging, and much more. http://www.accelacomm.com/jaw/sfnl/114/51426210/ _______________________________________________ MinGW-users mailing list [hidden email] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users Also: mailto:[hidden email]?subject=unsubscribe |
Free forum by Nabble | Edit this page |