Converting VC .Lib to MinGW .A?

Discussion in 'Game Development (Technical)' started by Sybixsus, Mar 4, 2006.

  1. Sybixsus

    Original Member

    Joined:
    Aug 2, 2004
    Messages:
    959
    Likes Received:
    0
    I've tried asking about this in a few places now - including the site of the developers of the library - with no success, so I hope you don't mind if I ask here too.

    I've a DLL which is supplied with a .lib. These were created in Visual Studio, but the developer swears he has compiled programs using it just fine in Borland and Dev C++, though he has so far not replied to my request for a functioning DevC++ project.

    I have two libs, one static and one dynamic. I don't care which I can get to work. I ran reimp from the MinGW tools on the dynamic lib, and created a .a but the linker still cannot find any of the functions. Specifically it's class members which have been exported from the DLL. So I ran reimp on the static .lib, and created a big folder full of .obj files. I put these back into an .a with ar ( also from the MinGW tools ) and that produced a quite different .a which also doesn't work.

    I've spoken to another of the developers of the library and he says there must be a way to convert the .lib though he has no experience personally with MinGW. Personally, I'm starting to have my doubts but since the developer says he's done it, it would be disingenuous of me not to take him at his word. Unfortunately he's obviously too busy to help me right now, and I can't afford to sit around idle waiting for a response as time is money to me ( and most of the people here, I imagine. )

    So if anyone has any suggestions, I'd love to hear them.
     
  2. ggambett

    Moderator Original Member Indie Author

    Joined:
    Jul 26, 2004
    Messages:
    1,982
    Likes Received:
    6
    I think you're out of luck. The problem is that different compilers mangle C++ identifiers differently, which is why you get unresolved externals. This usually doesn't happen with C libraries because of way simpler and more standard mangling rules. I think what reimp does is just try to convert names from one format to another but for some reason it's failing. I had this problem when trying to use the D3DX libraries with MinGW. Eventually I starded using the free VC++ command line tools so I worked around the problem.
     
  3. Chozabu

    Original Member

    Joined:
    Nov 30, 2005
    Messages:
    30
    Likes Received:
    0
    i tihnk mingw should be able to directly link to visual studio lib files(since 3.something?)
    though, i dont think it can link to borland libs

    what is the libary anyway? (if you dont mind me asking...)
     
  4. Sybixsus

    Original Member

    Joined:
    Aug 2, 2004
    Messages:
    959
    Likes Received:
    0
    I tried with the lib directly as well. Same thing.

    The lib/dll is TrueVision3D 6.5 ( beta. ) Unfortunately, it's not available publicly, only to customers who purchase a license, so I haven't been able to make it available to people who wanted to help.

    Just to be clear, although the 6.2 version is public, it is COM only, and will not work. 6.5 is completely different and supposedly should.
     
  5. Chozabu

    Original Member

    Joined:
    Nov 30, 2005
    Messages:
    30
    Likes Received:
    0
    Well, it seems truevision 6.5 uses directx ( :( ) which would mean its windows only... ( :mad: )
    so perhaps the free microsft compiler? http://msdn.microsoft.com/visualc/vctoolkit2003/ :D
    I really dont know anything much about it, but i think its easy to setup in codeblocks, if not alredy supported.
    Codeblocks can import dev-c++ projects, though this may not be a great solution, i hope it helps!
     
  6. Sybixsus

    Original Member

    Joined:
    Aug 2, 2004
    Messages:
    959
    Likes Received:
    0
    well I actually don't have a choice of compiler. I'm only using C++ to write a wrapper to use TV3D with my language of choice, which is BlitzMax. BlitzMax allows me to import chunks of C++ code but it uses MinGW to compile. So I need to find a way to convert the lib if it's possible, which the creators say it is. If it's not, then I'm going to have to press them to make a compatible lib.
     
  7. Larry Hastings

    Original Member

    Joined:
    Jul 27, 2004
    Messages:
    213
    Likes Received:
    0
    Don't use the .LIB then

    Use the BlitzMax equivalent of this:
    Code:
    HANDLE hTrueVision = LoadLibrary("truevision.dll");
    functionPointer x = GetProcAddress("entryPoint", hTrueVision);
    x();
     
  8. Sybixsus

    Original Member

    Joined:
    Aug 2, 2004
    Messages:
    959
    Likes Received:
    0
    Well the DLL doesn't export any functions, it exports classes. I'm not particularly familiar with C++ - just the basics really - so I don't know if it's possible to use GetProcAddress with classes. If it is, I guess it's something I could look into, but probably a bit beyond my current knowledge.
     
  9. Larry Hastings

    Original Member

    Joined:
    Jul 27, 2004
    Messages:
    213
    Likes Received:
    0
    It may be possible to use GetProcAddress() with classes, but it would be a major pain. It would be more convenient and more straightforward to write your own go-between library.
    Code:
    extern "C" __declspec(dllexport) DWORD tvPictureThingy(TV_PICTURE *picture, void *argument1)
    	{
    	return picture->thingy(argument1);
    	}
    
    You could definitely use GetProcAddress() with a library like that.
     
  10. sulaiman

    Original Member

    Joined:
    Aug 2, 2004
    Messages:
    20
    Likes Received:
    0
    I think Larry has a possible work-around. You can just rewrap the classes and export straight C functions using the free VC compiler. Then just import them into MingGW.
     
  11. Sybixsus

    Original Member

    Joined:
    Aug 2, 2004
    Messages:
    959
    Likes Received:
    0
    I've already written straight C functions to wrap the classes. That's how I'm writing the interface between BlitzMax and TV3D. My wrapper functions look exactly as you have them in your example, but since MinGW can't read the .lib, it can't find picturethingy->thingy() in the DLL.

    You mentioned exporting from VC++ to MinGW. How would I go about that? ( Sorry, if that's a dumb question, but I've never used one of the Microsoft compilers in my life. )
     
  12. Larry Hastings

    Original Member

    Joined:
    Jul 27, 2004
    Messages:
    213
    Likes Received:
    0
    You should be able to use LoadLibrary() and GetProcAddress() to call your functions directly. If you're saying that your wrapper functions have the C++ name mangling ("name decoration" according to Microsoft), you can turn that off by enclosing all your prototypes in extern "C" { ... }.
     
  13. Sybixsus

    Original Member

    Joined:
    Aug 2, 2004
    Messages:
    959
    Likes Received:
    0
    No, I'm saying that the C wrapper functions can't see the class members because the .lib doesn't link in GCC. BlitzMax can see my C functions just fine.
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer