Re: Help With Nim Static Libs on Windows

2016-12-24 Thread Tristano
Thanks Araq. In the end I guessed it was related to stdin/out because I grepped 
"fileno" into GCC's header files and it came up in the context of filesystem 
related constants.

Mhhh ... so I might be getting away with a simple Fibonacci function, but get a 
crash with more complex stuff! I've read many posts of people having problems 
importing static libs into PureBASIC under Windows, and that using DLL is 
always simpler. But in this case I was trying to experiment with static libs.

I've seen on PureBASIC forums that often errors similar to the ones I got were 
related to a missing system DLL (like some specific version of MS Visual Studio 
redistributables, ecc.) and was solved by importing the required DLLs along 
with the static libs

I guess that I'll eventually get a grip on this, with more practice and insight 
into the nebulous world of all these trans-compiler operations --- I mean: 
s many options just for GCC compiler alone! it's east to get lost in this 
configuration/compatibility jungle.

;)


Re: Help With Nim Static Libs on Windows

2016-12-24 Thread Araq
Pelles C is not supported by Nim and it seems to lack `fileno` which Nim's 
stdlib depends on, might be called `_fileno` in Pelles C. I'm not sure what 
`/EXPORT:fileno` does so if you get random crashes, don't complain. :)

I would stick to DLLs for interop with PureBasic.


Re: Help With Nim Static Libs on Windows

2016-12-24 Thread Tristano
SOLVEEED!

I've solved it by telling PureBASIC compiler to pass this option to polink:


/EXPORT:fileno


I haven't yet understood what was going on. But I do understand that his option 
exports the "fileno" symbol, which was the only one left in the error reports.

Can anyone help understand why this symbol was missing, what it refers to?

Shouldn't Nim have taken care of it? Or does Nim give for granted that some C 
code importing the header files will handle it?

It seems such a small issue, yet it kept me turning in circles for quite a long 
time...


Re: Help With Nim Static Libs on Windows

2016-12-24 Thread Tristano
Hi @Krux02,

No, I didnt. PureBASIC only uses "polink" and "porc" and "polib" from the 
Pelles C -- and they seem to be from different version releases also. PureBASIC 
has its own compiler + a FASM compiler. Unfortunately the documentation doesn't 
provide much help (actually: none) when it comes to these deatails. But it says 
it should handle any C library alright -- but then, again, PureBASIC is 
cross-platform but has a single documentation, so it might be referring 
actually to Linux or Mac.

But I'll try to look into Pelles C documentation, hoping it might help.

Would you have any idea what this 'fileno' unresolved symbol might refer to? 
The other two went away when I disable debugger support in the final lib, so 
maybe this symbol could also be resolved by either including and extra 
(required) lib, or by an extra compiler option of sorts...

B.R.


Re: Help With Nim Static Libs on Windows

2016-12-24 Thread Krux02
Ok, I have never used Pelles C nor PureBasic (I did some BlitzBASIC 10 years 
ago if that counts). So my answer is just guessing around. Since PureBasic 
seems to be integrated with the pelles C compiler, did you try to also compile 
the nim intermediate code with that compiler to a static library? I could 
imagine that it might help.