views:

181

answers:

2

Very sorry if this question has been asked numerous times, but I can not find a precise reference :( The problem is:

I have a DLL file along with corresponding LIB file compiled with VC++ 08. Now I want to dynamically link it with another application I am compiling using g++.

  1. Is it possible?
  2. What linker options will I have to give in g++?
A: 

If the library exports C++ classes or functions, then you probably can't, as the name-mangling between the two compilers is different. If it exports C functions, then you simply need to use the export library (the .LIB file) on the command line. For example, if it is called mylib.lib:

g++ afile.cpp another.cpp mylib.lib -o myexe

The DLL itself will have to be located in a suitable location, as it would be for a VC++ application.

anon
"The DLL will have to be located" - at runtime. When compiling `myexe`, it's not needed yet.
MSalters
I assumed he wants to run the program at some point :-)
anon
A: 

You asked a duplicate of this question. Also see this answer.

Employed Russian