How to use libraries compiled with MingW in MSVC?
2013-01-17 21:37
357 查看
http://stackoverflow.com/questions/2529770/how-to-use-libraries-compiled-with-mingw-in-msvc
http://blogs.msdn.com/b/vijay/archive/2009/10/02/what-is-name-decoration-or-name-mangling.aspx
Based on this error you put in a comment:
error LNK2019: unresolved external symbol "int __cdecl openssl_call(struct ssl_State *,int,int,int)" (?openssl_call@@YAHPAUssl_State@@HHH@Z) referenced in function _main MyAPP.obj all other 4 errors are same only with other functions names
Try putting
using extern "C" will
instruct the compiler that the functions are using C linkage, not C++, which will stop it from performing name
mangling on the functions. So it will look for the function openssl_call in the library rather than ?openssl_call@@YAHPAUssl_State@@HHH@. http://lists-archives.com/mingw-users/05372-linking-with-windows-vssapi-dll.html
http://blogs.msdn.com/b/vijay/archive/2009/10/02/what-is-name-decoration-or-name-mangling.aspx
Based on this error you put in a comment:
error LNK2019: unresolved external symbol "int __cdecl openssl_call(struct ssl_State *,int,int,int)" (?openssl_call@@YAHPAUssl_State@@HHH@Z) referenced in function _main MyAPP.obj all other 4 errors are same only with other functions names
Try putting
extern "C"around your include files for openssl. For example:
extern "C" { include "openssl.h" }
using extern "C" will
instruct the compiler that the functions are using C linkage, not C++, which will stop it from performing name
mangling on the functions. So it will look for the function openssl_call in the library rather than ?openssl_call@@YAHPAUssl_State@@HHH@. http://lists-archives.com/mingw-users/05372-linking-with-windows-vssapi-dll.html
Many years ago, I had to interface to a third-party dll for which I simply couldn't manage to build an import library that worked, despite much effort. So I fell back on what I guess is the most elementary, brute-force technique, and wrote a '.def' file by hand--and that worked. NAME 'WHATEVER' EXETYPE WINDOWS IMPORTS _WhateverNameYouWant =GOOFY_DLL.GoofyInternalName [Snip hundreds of other functions...but you want only one] That was the magic glue that let me call an msvc-built dll from an application built with a different proprietary compiler. Later, I rebuilt my application with gcc, creating a gcc import library this way: libGOOFY_DLL.a: $(some_directory)/GOOFY_DLL.dll GOOFY_DLL.def $(DLLTOOL) \ --dllname GOOFY_DLL.dll \ --input-def $(src_dir)/GOOFY_DLL.def \ --output-lib libGOOFY_DLL.a
相关文章推荐
- [Yii Framework] How to run cron job (or use command) in the server with yii framework
- How to use libcurl in C++ with std::string
- How To Use Ip Command In Linux with Examples
- How To Use Git Source Control with Xcode in iOS 7
- How to Use Linux Commands in Windows with Cygwin
- How to use GCC to build DLL by DEF file in MinGW?
- How to use a 32bit Oracle11_g client in 64 win system and not conflict with sqldeveloper 64 bit tool
- How to use isInEditMode() to see layout with custom View in the editor
- How To Use ADO.NET to Retrieve and Modify Records in an Excel Workbook With Visual Basic .NET(利用Ado.net导出到Excel)
- How To Use Git Source Control with Xcode in iOS 6
- How to create a DLL library in C and then use it with C#
- how to use a SQLite database in a standalone program with an HTML interface and VBScript as the programming language
- [原] XAF How to use Signle() function in PersistentAlias with Many-To-Many scenario
- (转贴)How to use JDBC and transactions in Tomcat with JOTM
- how to use the mathmatical constant "e" in conjunction with a vector
- How to use bitBucket with EGit in Eclipse,如何在Eclipse中使用bitbucket远程仓库
- How to use Comparator and Comparable in Java? With example
- How to create aligned partitions in Linux for use with NetApp LUNs, VMDKs, VHDs and other virtual di
- [CakePHP]How to use Session in conjunction with Memcache
- How to create a DLL library in C and then use it with C#