Qbasicnews.com

Full Version: making a lib in c++
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Lets say i have a C++ program with some functions and I compile it into a .obj, but I want to make a lib out of it? i searched google but got crap. can anyone help me with this? thanks.
What compiler are you using? (And this should perhaps be in General Programming, no?)
Well... it IS after all, help in qb. But I am using QB45, but I just stumbled over an ASM file that kinda showed me how to do this, but I still need more... eg how do I pass arguments! I wish I could find that one tutorial I found on this...
Ah, you want to use a C++ library from QB?

You didn't specify what C++ compiler you're using, but I'll assume that you actually mean a C compiler (or a C++ compiler set to use regular C names instead of C++ mangling) - if not, you'll have to have some fun with assembly language. Also, I'll assume you have access to the C source code and can rebuild the library. Make sure the procedures are all UPPERCASE names because of the way QB does case-insensitive linking. Then declare the functions in QB as such:
Code:
/* C code */
int ADDNUMS(int a, int b) { return a + b };


''' QB code
DECLARE FUNCTION ADDNUM CDECL (BYVAL a AS INTEGER, BYVAL b AS INTEGER) AS INTEGER

And there you have it. Make sure you link with the C lib on the LINK command line (add it to the libraries section). You can use the LIB command to make a library out of .OBJs.
ok, thanks, i will try that
C++ is object oriented, Qbasic is not. That could cause you some headaches. Use C or ASM.