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

Windows specific forum
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

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

Post 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.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

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

Post by ts-soft »

You have to import the "InstTK.lib" or OpenLibrary "InstTK.dll" :wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

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

Post 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.
ozzie
Enthusiast
Enthusiast
Posts: 443
Joined: Sun Apr 06, 2008 12:54 pm
Location: Brisbane, Qld, Australia
Contact:

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

Post by ozzie »

Thanks - I tripped over the same issue with importing. Was very glad to find the answer on the Forum. :D
Niffo
Enthusiast
Enthusiast
Posts: 504
Joined: Tue Jan 31, 2006 9:43 am
Location: France

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

Post 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.
Niffo
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

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

Post by jack »

I jus tried it on my Mac and it work OK
Post Reply