Page 2 of 2

Re: Static Linking of Library (no DLL dist.)

Posted: Mon Sep 21, 2015 12:14 pm
by coder14
Danilo wrote:Could you try to make 'char* returnStr = "Hello PureBasic!";' static or global?
Thank you so much for your reply. I tried t but it still only works with the DEBUG statement.

I think I must clarify - I do get the return value correctly but the function does not run properly. It is a file processig routine that opens a few files to make modifications and then writes to a new file. When the function is called with the DEBUG statement it works perfectly. But when the function is called directly (without the DEBUG statement but the debugger is on) the file is not written correctly.

Plesase see my other post about this: http://www.purebasic.fr/english/viewtop ... 44#p472344

The DEBUG statement must be doing something different.

btw, do you know why VS2013 is shooting this error:

Code: Select all

unresolved external symbol '__imp__findfirst64i32'
unresolved external symbol '__imp__findnext64i32'
Thank you Danilo.

Re: Static Linking of Library (no DLL dist.)

Posted: Mon Sep 21, 2015 12:36 pm
by RASHAD
It could be a matter of timing
Some of your statements may need more time to function properly and that what Debugger do with it
See if you use Delay() between some statements will solve the problem

Good luck

Re: Static Linking of Library (no DLL dist.)

Posted: Mon Sep 21, 2015 12:54 pm
by coder14
RASHAD wrote:It could be a matter of timing
Some of your statements may need more time to function properly and that what Debugger do with it
See if you use Delay() between some statements will solve the problem

Good luck
Hi Rashad. I tried putting a delay before and after the function call but it didn work. I got an idea and tried using a console instead of debug and put an input request to hold the program. But it still did not work.

Thank you for your suggestion.

I think you are right about the more time. What causes the function to end or return before finishing the job (write file)?

Re: Static Linking of Library (no DLL dist.)

Posted: Mon Sep 21, 2015 1:03 pm
by RASHAD
Hi coder14

Option #1:
Compile the code to exe and see if it works

Option #2
Try to use Threads & Mutex

Good Luck

Re: Static Linking of Library (no DLL dist.)

Posted: Mon Sep 21, 2015 1:19 pm
by coder14
RASHAD wrote:Hi coder14

Option #1:
Compile the code to exe and see if it works

Option #2
Try to use Threads & Mutex

Good Luck
Yes. It works as DLL and EXE.

Option #2: :?:

Sorry. :oops:

Re: Static Linking of Library (no DLL dist.)

Posted: Mon Sep 21, 2015 5:50 pm
by TI-994A

Code: Select all

unresolved external symbol '__imp__findfirst64i32'
unresolved external symbol '__imp__findnext64i32'
Hi coder14. The errors above refer to the two mentioned functions. I'm not familiar with them, but can only assume that they are externally linked. Perchance, did you convert a dynamic-linked library or executable binary into an object library?

Since you're trying to statically link the library to your own binary, all dependencies must be included; and Visual Studio might require some extra settings to accomplish this. I'd read somewhere that there's such a setting, to include all external symbols when compiling object libraries; but I'm not sure though.

CodeBlocks may have these settings in the GCC compiler enabled by default, and that's why you're able to statically link to its object library. Still, just guessing.

As far as the proper execution of the function goes, try passing a dummy parameter to it instead of leaving it void; I don't know why, but it worked for me.

Hope it helps you in some way.   :wink:

Re: Static Linking of Library (no DLL dist.)

Posted: Tue Sep 22, 2015 5:02 am
by coder14
TI-994A wrote:As far as the proper execution of the function goes, try passing a dummy parameter to it instead of leaving it void; I don't know why, but it worked for me.
YES! You nailed it! It works perfectly compiled into EXE. Thank you TI994A!!

Image

It is an EXE and I converted it to a static library. But I still cannot figure oue the VS2013 issue. Good if I can solve it but this one works for now. My thanks to everyone who helped: ts-soft, infratec, chi Danilo, Rashad. :D

Re: Static Linking of Library (no DLL dist.)

Posted: Tue Sep 22, 2015 11:11 am
by TI-994A
coder14 wrote:It works perfectly compiled into EXE.
Glad it works for you as well.

Although I have no idea why. :lol: