Compiling a 32 bit DLL project in x64

M

Manfred Wilner

I have a DLL that compiles fine in 32 bit environment but when I switch into
x64 and compile I am getting an error
MSVCRTD.lib(crtdll.obj) : error LNK2019: unresolved external symbol
__imp_Sleep referenced in function _CRT_INIT

The problem apparently is that my project doesn't reference the proper
library what is the comparable Winodws library in the x64 environment?

Is there a list I can look this up?

I am using VS2005 Pro Edition.
 
B

Ben Voigt [C++ MVP]

Manfred said:
I have a DLL that compiles fine in 32 bit environment but when I
switch into x64 and compile I am getting an error
MSVCRTD.lib(crtdll.obj) : error LNK2019: unresolved external symbol
__imp_Sleep referenced in function _CRT_INIT

The problem apparently is that my project doesn't reference the proper
library what is the comparable Winodws library in the x64 environment?

Is there a list I can look this up?

Same name (kernel.lib or user.lib) but in a different directory. Make sure
your LIB directory is set to match your target architecture.
 
R

Rong-Chun Zhang [MSFT]

Hello Manfred,

As Ben has pointed out that you need to link the x64 libraries, please try
to check the directories for Library files is set correctly for x64
platform. You can go to "Tools" -> "Options..." -> "Projects and Solutions"
-> "VC++ Directories", select x64 platform and make that the
$(VCInstallDir)lib\amd64 is included. More information, please check:
http://msdn.microsoft.com/en-us/library/t9az1d21.aspx.

You can also try to set the project settings to force your dll to link to
the x64 libraries.

If you have any additional concern or question, feel free to contact me.

Best regards,
Rongchun Zhang ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Manfred Wilner

Thank you Rong-Chun and Ben,

I tried your suggestions but I am not finding the right libraries from the
WDK that include functions like Sleep() or TerminateProcess() etc.

I have also now I a different problem.
I am working with Unidriver structures (POEMCUIPPARAM pOEMUIParam) and in
particular the OPTITEM structure
union {
LONG Sel;
LPTSTR pSel;
};

were I am assigning
pOEMUIParam->pOEMOptItems[ADV_TITLE_PAR].Sel =
(LONG_PTR)LoadIcon((HMODULE)pOEMUIParam->hModule,MAKEINTRESOURCE(IDI_ICON_CON));

and I am receiving the following warning
c:\winddk\6001.18001\src\print\munin\ttpui\oemui.cpp(233) : warning C4244:
'=' : conversion from 'LONG_PTR' to 'LONG', possible loss of data

The union is supposed to take either a LONG or a LPTSTR and it seems that it
only takes the LONG.
 
B

Ben Voigt [C++ MVP]

Manfred Wilner said:
Thank you Rong-Chun and Ben,

I tried your suggestions but I am not finding the right libraries from the
WDK that include functions like Sleep() or TerminateProcess() etc.

WDK?!? That changes everything. Earlier you said you were using VS2005.

Are you compiling user mode or kernel mode? Are you using the WDK build
script or trying to use Visual Studio to compile with WDK headers (a very
bad idea)?
 
M

Manfred Wilner

Sorry for the confusion I am doing two different things.
1. I have a WDK driver that I had compiled in x64 before and now have an
issue that I will take to the driver group but

2. I am using a helper DLL that is compiled with VS2005 and I tried the
suggestions but I am not finding the right libraries that are linked from the
WDK that include functions like Sleep() or TerminateProcess(),
GetPrinterData, etc.

All is in user mode.
The driver is compiled with the build script but the helper DLL with VS2005.
Should I convert the helper DLL into a build script build as well?
 
B

Ben Voigt [C++ MVP]

Manfred said:
Sorry for the confusion I am doing two different things.
1. I have a WDK driver that I had compiled in x64 before and now have
an issue that I will take to the driver group but

2. I am using a helper DLL that is compiled with VS2005 and I tried
the suggestions but I am not finding the right libraries that are
linked from the WDK that include functions like Sleep() or
TerminateProcess(), GetPrinterData, etc.

Sleep, TerminateProcess, GetPrinterData are not found in WDK libraries.
They are part of the Win32 API and you link with the Windows SDK libraries.
VS2005 ships with a version of these, or you can install the latest Windows
SDK.
All is in user mode.
The driver is compiled with the build script but the helper DLL with
VS2005. Should I convert the helper DLL into a build script build as
well?

If you need to use WDK header files (e.g. for IOCTL constants) then use the
WDK build script. Otherwise you can continue using VS2005 or use the
Windows SDK build environment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top