Visual C++ lib to VB

Started by
14 comments, last by __JoshMan__ 22 years, 4 months ago
Hey Guys, I''m programming a 3D graphics engine in MSVC6. My plan is to compile it to a static library (".lib") file when it''s finished, and import it into any future apps in which I may want 3D graphics. Although this plan will work for any apps that I''m going to make, my little brother (a Visual Basic programmer) wants to use the engine in his apps. How would I go about converting a Visual C++ static library file into a visual basic True Type Library file? I know that this can be done by programming an ActiveX and importing it into a VB app, but I''d prefer simply converting my C library into a True Type Library. Thanx in advance, JoshMan
mov cl, [ MBASE + edi ]xor cl, FFhgetcadc al, clsetcsub ClockCycles, 7jae EMULOOPjmp FINISH
Advertisement
quote:Original post by __JoshMan__
...Visual C++ static library file into a visual basic True Type Library file?

Um, doesn''t True Type refer to fonts?

I don''t know about static libraries (due to considerations like name mangling), but you can write a dynamic link library and use it with any (serious) Windows development language - C, C++, VB...

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!
Quote:
"Um, doesn''t True Type refer to fonts?"

Well, let''s just rephrase my question -

".....to a Visual Basic compatible library?"
mov cl, [ MBASE + edi ]xor cl, FFhgetcadc al, clsetcsub ClockCycles, 7jae EMULOOPjmp FINISH
Well, let''s just repurpose my answer :

You can write a dynamic link library and use it with any (serious) Windows development language - C, C++, VB... I''ve never heard anyone mention doing it for static libraries, probably because of the increase in executable size.

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!
I don''t think it is possible to import a VC++ static library into VB. A library is essentially a precompiled file from which native code can be obtained in generating a final executable. VB doesn''t have this type of capability like C++. I think the DLL answer is the way to go.

-Kirk
In VB:

Declare Function MyFunc Lib "myengine.dll" (ByVal Arg1, Arg2, Arg3) As Long

Replace names as neccessary. Pain in the ass, but its the only way.

NOTE: the DLL must be properly registered, in the Windows\System directory, or int he App directory!

-----------------------------
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
properly registered = not good.
you dont need to register anything. just keep the engine.dll file in the apps directory since ppl dont want crud in their system directory which is for system components (not applications componets unless by microsoft which makes them system components anyway).

and do what promit says. also to add, creating a dynamic link library means you have to have non mangled names (face its using a static lib wont be helpful) use the NOMANGLE keyword before all exported functions. thsi will ensure vc++ will keep normal names.
(or extern "C" can be used which i think is what NOMANGLE actually is defined as) and yes you need the quotes around the C.
you could always write one of those "type libraries" for your DLL, and then include it in the "Project->References" thing in VB. that way, you won't have to declare all the functions in the VB code (as Promit told you to do).

i don't think this makes a difference, except that it requires less effort from your little brother, and more from you.

--- krez (krezisback@aol.com)

Edited by - krez on December 13, 2001 2:17:30 PM
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
I feel funnies today...

1- Visual Bassic is for secretaries.
2- Have your brother learn C++ and Visual Studio.
quote:Original post by ANSI2000
1- Visual Bassic is for secretaries.

No, it''s for managers who would rather get their apps running quickly than ponder why the dereference on that iterator is yielding a garbage value.

quote:2- Have your brother learn C++ and Visual Studio.

How do you learn "Visual Studio."

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!

This topic is closed to new replies.

Advertisement