Page 1 of 1

DLL, Import = "invalid machine type" for one exe only

Posted: Mon Oct 24, 2011 5:00 pm
by jassing
I have a project that consists of a few exe's and one dll.
All the exe's use the dll.
All exe's build fine, except one.
When I build it; I'm told that the dll has an invalid machine type.

Image

Just "Import mydll.dll/endimport" will trigger the error. Including one or 20 definitions in the import block doesn't matter -- always gets the "Invalid machine type".

I have rebooted, moved the project (one post said it was a rights issue), created another admin user (I am admin on my machine) -- still happens.

Is there any way to figure out why this one exe doesn't like the dll?
The dll works fine: I have this code (to easily switch back and forth):

Code: Select all

CompilerIf #False
Import "InstTK.dll"
	GetMSSQLServers(nIndex = -1)
EndImport
CompilerElse
	Prototype ptGetMSSQLServers(nIndex=-1)
	hDLL = OpenLibrary(#PB_Any,"Insttk.dll")
	Global GetMSSQLServers.ptGetMSSQLServers = GetFunction(hDLL,"GetMSSQLServers")
CompilerEndIf
So I can use the dll w/o issue. (the exe runs fine & works as expected)
Even if I comment out the call to the dll function, and include no functions, ie:

Code: Select all

Import "InstTK.dll"
EndImport
Will generate the error. Other exe's that include the import build fine.

Re: DLL, Import = "invalid machine type" for one exe only

Posted: Mon Oct 24, 2011 5:23 pm
by ts-soft
You have to import the "InstTK.lib" or OpenLibrary "InstTK.dll" :wink:

Re: DLL, Import = "invalid machine type" for one exe only

Posted: Mon Oct 24, 2011 7:10 pm
by jassing
ts-soft wrote:You have to import the "InstTK.lib" or OpenLibrary "InstTK.dll" :wink:
HAHAHAHHAHA!! Thanks.
I started having problems about 5am; I should have said "get some rest" -- for hte life of me, I couldn't see that I was using .dll...
Sometimes I wonder how I get out of bed. thanks.

Re: DLL, Import = "invalid machine type" for one exe only

Posted: Wed Nov 09, 2011 4:26 am
by ozzie
Thanks - I tripped over the same issue with importing. Was very glad to find the answer on the Forum. :D

Re: DLL, Import = "invalid machine type" for one exe only

Posted: Thu Sep 19, 2013 9:37 am
by Niffo
And how to do the same for MacOS ? PB for MacOS generates ".so" files when compiling as "Shared DynLib". But importing this file with "Import" causes a linker error.

Re: DLL, Import = "invalid machine type" for one exe only

Posted: Fri Sep 20, 2013 12:01 am
by jack
I jus tried it on my Mac and it work OK