May 15, 2024, 02:00:49 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Ani-Mates questions

Started by Ionic Wind Support Team, November 30, 2008, 08:37:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ionic Wind Support Team

Ionic Wind Support Team

Ionic Wind Support Team

Quote
Hootie,
I really appreciate your work on this tutorial. Thank you for your efforts.
I have finished the 3rd tutorial and have an error compiling it as below:

-------------------------------------------------------------------------------------
Compiling...
amMain
amShutdownStack

Linking...
Emergence Linker v1.11 Copyright ÂÃ,© 2006 Ionic Wind Software
Error: Bad library C:\Program Files\EBDev\libs\crtdll.lib: Symbol __imp_free in dictionary, but not in specified module

Error(s) in linking C:\Animates\bin\Animates_Client.exe
--------------------------------------------------------------------------------------

I have crtdll in EBDev\libs\ folder, date is 11/12/2003.
Do you know what this error indicates??
Any help is appreciated.

Sincerely,
JerryC

Jerry,
Sapero's Windows include file includes a different crtdll.lib than the one I ship with emergence BASIC, they are mutually exclusive.  The one I include is specifically designed to use an underscore for each function name, and to use external linking instead of import linking.

What happens if you use Sapero's C definitions they will not be correct for the C import library included with Emergence BASIC.  I've been meaning to discuss that with him, just haven't had the time.

Anyway in Sapero's files you'll find:

declare cdecl import, free(.....

Whereas the Emergence crtdll.lib is designed to use:

declare cdecl extern _free(....

So Jerry, you are getting that error because you probably haven't installed Sapero's include files and libraries.

Paul.
Ionic Wind Support Team

Allan

I have just downloaded Saperos EBasic headers 16th Nov 2008.

I get the same error as above when compiling.

Allan

Hootie

Hmmm, I don't really know.  My crtdll.lib is the same date as as Jerry's yet mine compiles fine.  Maybe Sapero can shed some light on this. Sorry, I'm not much help with this.

Ionic Wind Support Team

Sapero's installer includes a library called _crtdll.lib, which is the one I was referring to.

Paul.
Ionic Wind Support Team

Ionic Wind Support Team

Of course you could avoid the conflict by using NEW and DELETE instead of malloc and free.
Ionic Wind Support Team

Allan

Using NEW and DELETE compiles OK for me.

Allan

Hootie

Quote from: Paul Turley on November 30, 2008, 10:28:09 PM
Of course you could avoid the conflict by using NEW and DELETE instead of malloc and free.


Yes, that is possible so use NEW/DELETE if the malloc/free code doesn't work for you.  Although, in an upcoming tutorial we will see that NEW/DELETE is slower than malloc/free but Ani-Mates uses a custom memory allocator which is quite a bit faster than either of those so it makes little difference for the few things that use the generic allocators.

I hope everyone is enjoying the tutorials and that they are clear enough for people to follow along.

sapero

You could open the command prompt, go to ebasic bin directory and execute this command to create the _crtdll.lib:
C:\Program Files\EBDev\bin>libtool %windir%\system32\crtdll.dll ..\libs\_crtdll.lib
Note: do not use ebasic tools menu to create crtdll.lib.

About the memory speed: NEW is calling GlobalAlloc, malloc is calling HeapAlloc which is much faster (the returned memory has better access time). If you need more/full speed, use virtual memory allocator - VirtualAlloc.

jerryclement

 ???
Sapero,
I followed your instructions to make _crtdll.lib and it put a copy in the /libs folder okay. But I still get the error message "bad crtdll.lib". Is there something I need to change in the source .eba file?

Thank you for your help.

JerryC
Jerry - Newbie from TN

Guilect

December 01, 2008, 10:04:20 AM #10 Last Edit: December 01, 2008, 11:36:43 AM by Guilect
QuoteYou could open the command prompt, go to ebasic bin directory and execute this command to create the _crtdll.lib:
Code:

C:\Program Files\EBDev\bin>libtool %windir%\system32\crtdll.dll ..\libs\_crtdll.lib

Note: do not use ebasic tools menu to create crtdll.lib.

I kinda thought that that is what the tool menu item was doing.
What's the difference?

[EDIT]  I did not notice the underscore at the begining of the lib name my first read through.
I thought using the command line to make a lib was acting differently from calling it from the menu.
All set now.  thank you.

sapero

You need to link with it in order to call malloc declared as import:$use "_crtdll.lib"
If you include windowssdk, this library is automatically linked with your code, so this will compile without problems:
$include "windowssdk.inc"
malloc(0)


Bad library error you get if the library is damaged, or has unsupported format like coff import library (eg kernel32.lib from Microsoft libraries). Do you use external linker? Maybe you overwrited the crtdll.lib (check file time or md5: 628CFD343CDABDDB1AA32166FC4509E6).

QuoteWhat's the difference
the command from tools menu will overwrite crtdll.lib
the command typed in command prompt will create new _crtdll.lib without overwriting the crtdll.lib. You should not change the crtdll.lib library, read Paul answer above.

jerryclement

 ;D
Thanks Sapero, I did the following and it compiles without error!!

-----------------------------------------------------------------------------------------
You need to link with it in order to call malloc declared as import:
Code:

$use "_crtdll.lib"
----------------------------------------------------------------------------------------

Thank you very much.
Thank you also Paul for the direction.

Now I'm waiting for Hootie's Tutorial 4 to learn more!!

JerryC
Jerry - Newbie from TN

Allan

QuoteI hope everyone is enjoying the tutorials and that they are clear enough for people to follow along.

Hootie, Like the Tutorials. They are clear and precise, as well as neat and easy to read and apply.

Thanks for sharing your work.

Allan

pistol350

I'm learning much from this tuto.
I like it too and i'm looking forward to seeing the next step.
Thank you for devoting your time to sharing your knowledge with us.
Regards,

Peter B.

Hootie

Glad you guys like the tutorials.  Unfortunately, they are going to be slower in coming for a while because I lost about a month of development time due to a recent illness.  I need to write more code to catch up to where i hoped to be by now.

Haim

Great stuff!
Keep them coming. I learn a lot from the tutorials.

Thank you very much for this!

Haim

Allan

Hi Hootie

the QueryPerformanceFrequency is an API I have not used before so I looked it up in the SDK.

They say a bit about some machines may not have this feature.

I tried using the following to get a return value as mentioned in SDK but the Windows has a problem with it and wants to send a message to MS.

INT retval = 0
retval = QueryPerformanceFrequency(&countspersecond)

Is this an incorrect way to get the return value of the Function?

Allan

sapero

December 05, 2008, 06:38:11 PM #18 Last Edit: December 05, 2008, 06:41:12 PM by sapero
This is correct, if you ensure also the type of countspersecond variable is int64 (should be aligned in memory to QWORD, 8-byte align).

If QueryPerformanceFrequency fails, first try to add a integer variable before countspersecond:
int temporaryAlign ' here
int64 countspersecond

Hootie

December 05, 2008, 07:42:31 PM #19 Last Edit: December 05, 2008, 07:50:35 PM by Hootie
Did Sapero's suggestion fix your problem Allan?

Things that work fine on my system may not work on other systems.  Unfortunately, I don't have a vast range of hardware to try things on so any help in working out bugs is greatly appreciated!

Also, I will reiterate again that I am not the world's best programmer.  If anyone has suggestions for changes and improvements to the code I post, I am all ears!    ;D

Allan

NO - did not work and still comes up with notice to inform MS of the problem

Here is the SUB as I have it in prog.  I have used direct DECLARE at head of prog.


Quote'=================================================================================
' Includes
'=================================================================================
'$INCLUDE "windowssdk.inc"
'$INCLUDE "malloc.inc"
'$INCLUDE "memory.inc"

DECLARE CDECL EXTERN _calloc(count as int, size as int),pointer
DECLARE CDECL EXTERN _free(mem as pointer),INT
DECLARE CDECL EXTERN _memcmp(buf1 as pointer, buf2 as pointer, count as int),INT
DECLARE IMPORT,QueryPerformanceFrequency(pFrequency as INT64),INT
DECLARE IMPORT,QueryPerformanceCounter(pPerformanceCount as INT64),INT

$INCLUDE ".\log\amLog.inc"
$INCLUDE ".\main\amShutdownStack.inc"



GLOBAL SUB amProfileInit(INT profilecount)
INT retval = 0
INT temporaryAlign ' here
INT64 countspersecond = 0

    amLogMessage("***** Profile System Initializing *****")

' gets the length of the UDT - ProfileSection
ProfileSectionSize = LEN(ProfileSection)

    ' Create an array to keep track of the sections being profiled
' EBasic has ALLOCMEM which does same as calloc ? (A)
    ProfileArray = _calloc(ProfileSectionSize * (profilecount + 1), 1)

    IF ProfileArray = NULL
amLogError("amProfileInit failed on ProfileArray create!")
ENDIF

    EmptySlot = _calloc(ProfileSectionSize, 1)

    IF EmptySlot = NULL
amLogError("amProfileInit failed on EmptySlot create!")
ENDIF

TotalProfiles = profilecount

retval = QueryPerformanceFrequency(&countspersecond)
SecondsPerCount = 1.0 / countspersecond
amShutdownRegister(&amProfileShutdown)

ENDSUB



Maybe I have missed something here. But prog runs ok without the Return retval bein used??

Allan

Allan

I have three computers of different ages that I use.

Here attached are the profile printouts for each machine.

They are not always exactly the same and the profile can vary quite often in the INTEL computer where the MALLOC is sometimes the fastest. I tried rebooting the machine to check it more thoroughly and it still varied but the Custom Memory you made is fastest each time, but not by much.

But on each machine the NEW DELETE is slowest.

Allan

Ionic Wind Support Team

Apples and oranges actually.

NEW always initializes the contents of allocated memory to 0, like C calloc does.  So it will be slower than malloc which gives you a memory block with random contents.

NEW calls the Windows API GlobalAlloc.

Paul.

Ionic Wind Support Team

sapero

Allan, both QueryPerformance functions require a pointer to int64, not data by value DECLARE IMPORT,QueryPerformanceFrequency(pFrequency as pointer),INT
DECLARE IMPORT,QueryPerformanceCounter(pPerformanceCount as pointer),INT

Allan

Sapero,

Yes that does the job.  I should read ALL the SDK info.  >:(

I just took the declares from the ApiViewer2004 and did not think of checking them.

Thanks.

Paul - what does the ALLOCMEM function in EBasic use - is it calloc?

Allan