I have libraries which are build using VC++. I want to use the same libraries in a program and build in cygwin gcc compiler. Is this scenario will work?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since C++ doesn’t have a standardized ABI, and since Visual C++ and g++ in particular almost certainly have different ABIs, I don’t think you can do this. Your only real option is to restrict yourself to C, not C++.
Edit: If all of the libraries that you’re using are straight C (
extern "C", in C++ terms), then you ought to be able to share libraries between compilers. (Otherwise, your Cygwin and MinGW apps couldn’t call the Windows API.) You’ll need to be careful to match up calling conventions. For example, the Windows API uses__stdcallinstead of the standard C calling convention. You can tell GCC which calling convention to use with function attributes. Google, and your library’s header files, should have more information on what calling convention to use.