C++ static libs
C++ static libs
Hi
Is there a way to use a C++ static Lib in PureBasic? I know how to create Userlibs with C static libs, but with C++ I have no success.
Thanks
Is there a way to use a C++ static Lib in PureBasic? I know how to create Userlibs with C static libs, but with C++ I have no success.
Thanks
- the.weavster
- Addict
- Posts: 1576
- Joined: Thu Jul 03, 2003 6:53 pm
- Location: England
Coding's nothing for two year olds...the.weavster wrote:if I have a *.lib file can I make it usable with PureBasic?

If it's a C++ library, you'll have to write a wrapper, if it's a C library, you can
either write a simple wrapper (functionnames have to start with "PB_"), use
the method mentioned here or wait for this feature to be implemented in
PureBasic.
Another solution can be to use the DLL-Importer (PB's Library SDK) but you'll
possibly run into problems if the library depends on other libraries.
Good programmers don't comment their code. It was hard to write, should be hard to read.
try adding windows libs to your desc file.
you could use any number of libs, includind msvcrt.
Code: Select all
;
; Langage used to code th library: ASM or C
C
;
; Number of windows DLL than the library need
1
crtmt2.lib
; Library type (Can be OBJ or LIB)
;
OBJ
;
.....................
.....................
I think he told you about the DLL Importer because it also works with .lib files, not sure though...pg wrote:I did not find the solution until now. Just to repeat again. I'm trying to link a c++ static lib, not dll. To use DLL is not a problem
I'm still trying to work out my C++ lib, without success for the moment

ExactlyPolo wrote:I think he told you about the DLL Importer because it also works with .lib files, not sure though...
Can you give some specific error messages (unresolved external symbols)?Polo wrote: I'm still trying to work out my C++ lib, without success for the moment
What's missing?
Good programmers don't comment their code. It was hard to write, should be hard to read.
Here it is :

POLINK: warning: Multiple '.data' sections found with different flags (0xc0000040 and 0x60000040).
POLINK: error: Unresolved external symbol '__imp_??0_Lockit@std@@QAE'.
POLINK: error: Unresolved external symbol '__imp_??1_Lockit@std@@QAE'.
POLINK: error: Unresolved external symbol '__imp__fstat'.
POLINK: error: Unresolved external symbol '__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBDIABV?$allocator@D@1@'.
POLINK: error: Unresolved external symbol '__imp_??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE'.
POLINK: error: Unresolved external symbol '__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV?$allocator@D@1@'.
POLINK: error: Unresolved external symbol '__imp_??Y?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@D'.
POLINK: error: Unresolved external symbol '__imp_?length@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@'.
POLINK: error: Unresolved external symbol '__imp_?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@'.
POLINK: error: Unresolved external symbol '__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBDABV?$allocator@D@1@'.
POLINK: error: Unresolved external symbol '__imp_??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@ABV01@'.
POLINK: error: Unresolved external symbol '__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@'.
POLINK: error: Unresolved external symbol '__imp_??Mstd@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@0'.
POLINK: error: Unresolved external symbol '__imp_??_F?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@'.
POLINK: error: Unresolved external symbol '??Hstd@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@ABV10@D@Z'.
POLINK: error: Unresolved external symbol '__imp_??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@D'.
POLINK: error: Unresolved external symbol '__imp_??A?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAADI'.
POLINK: error: Unresolved external symbol '__imp_?size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@'.
POLINK: error: Unresolved external symbol '__imp_?data@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@'.
POLINK: error: Unresolved external symbol '__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@IDABV?$allocator@D@1@'.
POLINK: error: Unresolved external symbol '__imp_?npos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@'.
POLINK: error: Unresolved external symbol '__imp_?erase@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@II'.
POLINK: error: Unresolved external symbol '__imp_?resize@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXI'.
POLINK: error: Unresolved external symbol '__imp_?append@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@PBDI'.
POLINK: error: Unresolved external symbol '__imp_?append@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@ID'.
POLINK: error: Unresolved external symbol '__imp_?append@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@PBD'.
POLINK: fatal error: 26 unresolved external(s).


Polo, did you do what jack described? Did you link msvcrt.lib?
Beside the common c-runtimes (msvcrt, crtmt, crtmt2 (mt=multithreaded))
"_fstat" is defined in fstat.obj. You could add this directly to your VC project.
I can only guess about the rest. Are you using VC >= 7.0 ?
Beside the common c-runtimes (msvcrt, crtmt, crtmt2 (mt=multithreaded))
"_fstat" is defined in fstat.obj. You could add this directly to your VC project.
I can only guess about the rest. Are you using VC >= 7.0 ?
Good programmers don't comment their code. It was hard to write, should be hard to read.