Page 1 of 1

Some unresolved externals

Posted: Sun Nov 22, 2009 2:13 pm
by milan1612
I compiled a rather large C code to a static library using the latest Pelles C Compiler.
Trying to use it in Purebasic via Import : EndImport, I got some unresolved external symbols
that I've never heard before. Importing wsock32.lib helped a lot, but there are still
some unresolved. Here are the names:
'___tolowertab', '___stderr', '___ulldiv', '___ctypetab', '___assert',
'___chkstk', '___stoll', '_errno', '___touppertab', '___stoul'.
Does anyone know in which library they're contained? I already tried msvcrt.lib, to no success...

Re: Some unresolved externals

Posted: Sun Nov 22, 2009 2:26 pm
by srod
The following may or may not help :

http://forum.pellesc.de/index.php?topic=2255.0

Reference is made to ctype.h

Re: Some unresolved externals

Posted: Sun Nov 22, 2009 2:47 pm
by milan1612
As ctype.h isn't a library on it's own but a part of the standard C library, there's no specific file
to import. The std. C library resides in crt.lib from the Pelles C installation. I just tried to import
it, the code compiles but crashes immediately. I think this is because the CRT contains startup
initialisation code, which of course poses a problem here.

From what I understand, .lib files are just containers of many .obj files. So I "unzipped" the crt.lib
with 7zip and got a folder inside with the mentioned .obj files. Some of my "unresolved's" are present as
distinct files. Importing them inside my PB code removes the error, but not all unresolved symbols are resolved.

I don't consider this a solution, more or less some creepy hack that just solves a part
of the problem :lol: Any better ideas on importing the CRT without crashing my code?


EDIT: I'm such an idiot, POLIB.exe does exactly what I did with 7zip - only properly!
The /EXPLODE option gives me a lot of .obj files, and all unresolved symbols are present there :D

Re: Some unresolved externals

Posted: Sun Nov 22, 2009 3:20 pm
by milan1612
Ok, after extracting all object files from the crt.lib, I imported all needed files and slowly
but surely satisifed the linker :lol:. Some libraries depend on others, so it were quite few.
After that, I build a custom CRT .lib with POLIB which bundles all needed .objs and now I'm happy...

Thanks srod for the ctype hint, it led me straight to the CRT :)

Re: Some unresolved externals

Posted: Mon Nov 23, 2009 6:01 pm
by Fred
Any reason to not use VC2005 Express (just curious) ? That's the compiler we use for PB libs.

Re: Some unresolved externals

Posted: Mon Nov 23, 2009 8:53 pm
by milan1612
Well Fred, I've always had problems with VC 2005 concerning static lib linkage in PB programs (mostly runtime problems).
And as Pelles C uses the same linker as PB, it's probably a good idea to use it. I'd be glad though if you published a step
by step tutorial for the VC 2005 (or even better 2008?) on how to properly import static libraries created with it in PB.
:)