Is there a tool that can convert a Visual Studio o

2019-07-17 02:11发布

I am building a C++ application on Windows using Interix and need to link in three object files to supply a third-party licensing module's functionality. The third party has supplied the object files as built by Visual Studio. Is there anyway to convert the files for use with GCC? For example, perhaps if I change the name mangling from Visual Studio style to GCC style that would be sufficient, or are there other differences between the two object file formats?

2条回答
狗以群分
2楼-- · 2019-07-17 02:13

In addition to the possible symbol differences between VC++ and GCC/G++, what's you are trying to do may be impossible due to Windows API issue.

Programs that built from Interix GCC can only work with Interix, and since Interix is a separated subsystem in parallel of the Windows subsystem (or say Win32 subsystem), you can't call any Windows API (ex. from kernel32.dll) from Interix programs.

If that licensing object file contain any Windows API calls, linking will not be possible.

查看更多
一纸荒年 Trace。
3楼-- · 2019-07-17 02:30

Windows does not have a standardized C++ ABI (Application Binary Interface). It does have a C ABI, though. This is the ABI used for instance by Kernel32.DLL, so all Windows programming environments understand it. Many can also produce such DLLs.

In this case, the C++ .obj files have to be linked by the Visual Studio linker. That linker is definitely capable of creating DLL files. You'll have to write extern "C" functions to wrap the licensing functionality. Add __declspec(dllexport) to indicate that those functions are exported from the DLL (on Windows, functions by default are private to a DLL).

In a header, declare those same functions as __declspec(dllimport). GCC understands that as well. Then link against the newly produced DLL, which will resolve the dllimport'ed symbols.

查看更多
登录 后发表回答