Static Linking of Library (no DLL dist.)

Just starting out? Need help? Post your questions and find answers here.
coder14
Enthusiast
Enthusiast
Posts: 327
Joined: Tue Jun 21, 2011 10:39 am

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

Post 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.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

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

Post 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
Egypt my love
coder14
Enthusiast
Enthusiast
Posts: 327
Joined: Tue Jun 21, 2011 10:39 am

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

Post 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)?
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

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

Post 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
Egypt my love
coder14
Enthusiast
Enthusiast
Posts: 327
Joined: Tue Jun 21, 2011 10:39 am

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

Post 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:
User avatar
TI-994A
Addict
Addict
Posts: 2705
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

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

Post 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:
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
coder14
Enthusiast
Enthusiast
Posts: 327
Joined: Tue Jun 21, 2011 10:39 am

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

Post 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
User avatar
TI-994A
Addict
Addict
Posts: 2705
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

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

Post 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:
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Post Reply