Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7944 Discussions

Problems with linking a library created in g++/MinGW

kami09
Beginner
1,197 Views
Hello,

I have got a question about linking with ICL. I hope anyone could point me out if it is possible to be done or not:

- I am working on Windows XP.
- I have created a library (dll) with g++ in MingGW.
- I would like to compile and link a program with ICL that uses that library. Is that possible?

I have tried to do it, however it seems that ICL does not recognize the classes included in that library.

Thank you very much in advance

Jaime
0 Kudos
13 Replies
JenniferJ
Moderator
1,197 Views
Quoting - kami09
I have tried to do it, however it seems that ICL does not recognize the classes included in that library.
Could you post the error msg?

Jennifer
0 Kudos
TimP
Honored Contributor III
1,197 Views
I suppose the C++ name-mangling schemes aren't compatible between g++ and ICL. ICL should match MSVC++. You could examine the symbol expectations in object files by dumpbin or nm. You should have compatibility with extern "C" linkage, but you would still expect run-time library conflicts between mingw and ICL.
0 Kudos
kami09
Beginner
1,197 Views
The error is really long but is the same error as if I had not added the .dll to the linker. It seems that the main program do not see the classes contained in the library.

Quoting - Jennifer Jiang (Intel)
Could you post the error msg?

Jennifer

0 Kudos
kami09
Beginner
1,197 Views
Quoting - tim18
I suppose the C++ name-mangling schemes aren't compatible between g++ and ICL. ICL should match MSVC++. You could examine the symbol expectations in object files by dumpbin or nm. You should have compatibility with extern "C" linkage, but you would still expect run-time library conflicts between mingw and ICL.

But, does it mean that I can use classes contained in the .dll, or the extern "C" compatibility only works for functions.
0 Kudos
aazue
New Contributor I
1,197 Views
Quoting - kami09
Quoting - tim18
I suppose the C++ name-mangling schemes aren't compatible between g++ and ICL. ICL should match MSVC++. You could examine the symbol expectations in object files by dumpbin or nm. You should have compatibility with extern "C" linkage, but you would still expect run-time library conflicts between mingw and ICL.

But, does it mean that I can use classes contained in the .dll, or the extern "C" compatibility only works for functions.

Hi
Probably require to use file def to inform directive "@.........."
also instruction compiler
-DDLLIMPORT=??? -L ....... (origin lib.a if used as converted process to dll)
About conflict ,normally no relation with Icc lib if correctly patched two side.
Normally can run.
Kind regards

0 Kudos
Alexander_W_Intel
1,197 Views

Hi,

old thread, but I want to clearify the answer.
You can't use the classes in the dll. The different mangling is often on purpose to prevent you from runtime errors. There are other ABI issues like return value handling, register handling, vtable, exception handling and so on. So, even if you manage to solve the mangling issue the application wont run as expected.

Alex

0 Kudos
aazue
New Contributor I
1,197 Views
Hi
I have doubt seriously that your clarification is true.
I have backend is not builded with Intel compiler works perfectly
when you call with an program origine builded intel compiler
if i remember exactly i have also already make with windows VC and ICC...
If impossible, I don't understand how could be
possible some DLL have not all same origin could sharing
sometimes all at system...
Maybe could be possible you have added recently an nail icc to lock..
download here an backend database PG
ftp://ftp.eenet.ee/pub/postgresql/projects/gborg/libpqpp/stable/libpq%2B%2B-4.0.tar.gz
make dll
start an instance engine database PG
build simple program with ICC and call backend with you see result...
Regards

0 Kudos
Alexander_W_Intel
1,197 Views
Hi,

thanks for getting back on that. I think I was imprecise and only gave the answer for the particular situation.
In fact there is absolutely no problem if you link a icc program against a libary build with MSVC and vice versa under windows. This is because icc is compatible with MSVC under windows.
The same is true under Linux for the icc and gcc, because under linux the icc is compatible to gcc.

What happens here to the thread starter is, that he used gcc under windows to build the dll and link it with icc. You can do even that, if you only use C functions. A very short statement can be found at: http://www.cygwin.com/faq/faq.programming.html#faq.programming.msvc-gcc-objects
If you use C++ clases this will probably fail. I think this should also fail linking with the MSVC tools.

Bustaf, are you now agree? If not I will try to build an example and going deeper in this issue.

Thanks,
Alex
0 Kudos
aazue
New Contributor I
1,197 Views
Hi Alex

You made me doubts , i know my memory Is old now...
maybe possible is I mixing....
but i think i have already use in the past.

exist for me an test more simple for verify
See about form :

http://www.scribd.com/doc/40725510/Build-PostgreSQL-C-Functions-on-Windows
also
http://www.postgresql.org/docs/9.0/static/xfunc-c.html

Require i verify with Mingw 32 (function (dll)MINGW AND VC origin added)....
Actual I have (**)DRAGON 64 with W7 64.. i think some lib incomplete to build this task.
Problem also i think to load added function C++ PG engine require backend C++ before...
(Engine PG have only by default C backend)

About your last question
even if I'm wrong ,share with you with your test extended or is new verification test in my side
is with the pleasure,not an challenge. just, must be not detrimental to your time...

To same subject could benefit to other users i add...
Recently I have help an user how to adding C function in PG ubuntu)
is wrote in French but could have interest also for testing with Icc compiler Linux.
http://www.developpez.net/forums/d1096974/bases-donnees/postgresql/procedures-stockees-c-postgresql-8-4-a/
between the end exchange you have the complete described, step by step of this process on Linux Ubuntu.



(**)http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Installer/tdm64-gcc-4.5.2.exe/download

Regards
0 Kudos
aazue
New Contributor I
1,197 Views
Hi Alex

I have find some links on the problem that you have exposed previously for it should explain more clearly
that is possible to make and not make.
But if an blocking property exist, for the part supposed working ,could be
also no always functional some sides,even if you cry !!!

http://www.mingw.org/wiki/MSVC_and_MinGW_DLLs
http://www.mingw.org/wiki/sampleDLL
http://www.transmissionzero.co.uk/computing/advanced-mingw-dll-topics/

Regards

0 Kudos
Alexander_W_Intel
1,197 Views

Hi Bustaf,

the last link is really interesting. There seems to be a possibility to use a dll containing C++ code with a different compiler ABI than that which are created the dll. I hope I will find a little bit of time tomorrow to check that. It is still on my todo list :-)

The other links are mainly telling you to use a C-style wrapper for this constellation.

Thanks!
Alex

0 Kudos
TimP
Honored Contributor III
1,197 Views
That first URL which Bustaf quoted addresses the question of how to get a Microsoft style import library for a .dll created by mingw (32-bit). I didn't see that it addressed the C++ name mangiling or run-time library differences.
0 Kudos
aazue
New Contributor I
1,197 Views
Hi
I have add the link is first only for could interest all users C || C++.
(also complement relation for adding C function Pg engine side Microsoft)..
Regards

0 Kudos
Reply