x64 DLLs

x64 DLLs

I have a simulator that uses DLLs that builds and runs just finefor the Win32 Visual Studio Compiler. But, the DLL project in Visual Studiowill not allow VS to switch the compilation system to x64. Is there something special that must be done to acomplish this?

8 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Steve Lionel (Intel)'s picture

When you say it "will not allow", what do you mean? Is it that x64 is not an option under the target platform? If so, it sounds as if you did not install the x64 support in Visual Studio.

2.1.1 Configure Visual Studio for 64-bit Applications
If you are using Microsoft Visual Studio 2005* or 2008 and will be developing 64-bit applications
(for the Intel 64 or IA-64 architectures) you may need to change the configuration of Visual
Studio to add 64-bit support.
If you are using Visual Studio 2005/2008 Standard Edition or Visual Studio 2008 Shell, no
configuration is needed to build Intel 64 architecture applications. For other editions:
1. From Control Panel > Add or Remove Programs, select Microsoft Visual Studio 2005
(or 2008) > Change/Remove. The Visual Studio Maintenance Mode window will appear.
Click Next.
2. Click Add or Remove Features
3. Under Select features to install, expand Language Tools > Visual C++
4. If the box X64 Compiler and Tools is not checked, check it, then click Update. If the
box is already checked, click Cancel.

Steve

Quoting - Steve Lionel (Intel)

When you say it "will not allow", what do you mean? Is it that x64 is not an option under the target platform? If so, it sounds as if you did not install the x64 support in Visual Studio.

The x64 support is installed. I have two projects in the solution. One is the simulator. The other is for the model I/O DLL. When I switch the environment to x64, the simulator resets itself just fine. It compiles and links. The I/O DLL will not allow me to designate x64.

In comparison:
1) Open: Tools>Options...>Intel Fortran>Compilers (for Win32 specifies 3 compilers) (for x64 specifies 10.0.026)
2) Open: Build>Configuration Manager...
With top-right selection box set to Win32
Simulator [Platform]=Win32
IO-DLL [Platform]=Win32
With top-right selection box set tox64
Simulator [Platform]=x64 andthe pull-down listhas Win32; x64; ; and
IO-DLL [Platform]=Win32 and the pull-down list has Win32; ; and
I cannot select x64 because it is not in the list. I cannot add x64 to the list using either or .

Also, what the the x64 version of Kernel32 named?

Steve Lionel (Intel)'s picture

Interesting. Would you please attach the .sln and .vfproj files from this solution? I don't need anything else. Is IO-DLL a Fortran project?

Steve

Quoting - Steve Lionel (Intel)
Interesting. Would you please attach the .sln and .vfproj files from this solution? I don't need anything else. Is IO-DLL a Fortran project?

Sorry, I cannot do that. Too much proprietary stuff in them.

Good News - I tried to change the x64 setting in the configuration manager again and it did allow me to set it this time. I don't know why it would not allow it before. Maybe starting from the menu rather than the right-clock over the project made a difference. Don't know! Maybe I was using it wrong.

What is the x64 equivelent name for Kernel32?

Les Neilson's picture

Quoting - mattsdad

Sorry, I cannot do that. Too much proprietary stuff in them.

Good News - I tried to change the x64 setting in the configuration manager again and it did allow me to set it this time. I don't know why it would not allow it before. Maybe starting from the menu rather than the right-clock over the project made a difference. Don't know! Maybe I was using it wrong.

What is the x64 equivelent name for Kernel32?

Yeah I have occasionally had right-click do something different to what I expected. I didn't note the details as I just went to the menus instead.

Kernel32 : just leave it as is, Windows sorts itself out for you automatically going to the appropriate 32/64 bit location.

Les

Quoting - Les Neilson
Kernel32 : just leave it as is, Windows sorts itself out for you automatically going to the appropriate 32/64 bit location.

Les

OK, I have tried that, but I still get a compler error. Here is my code:

FUNCTION get_func_dll(dll_handle, fn_name) RESULT(fn_pointer)
#ifdef _WIN32
USE Kernel32 ! Windows32 API routines
#define DOING_WINDOWS
#endif
#ifdef _x64
USE Kernel32 ! Windows64 API routines
#define DOING_WINDOWS
#endif
USE Dynamic_Load
IMPLICIT NONE
#ifdef _WIN32
INTEGER(KIND=4), INTENT(IN) :: dll_handle
#else
INTEGER(KIND=8), INTENT(IN) :: dll_handle
#endif

CHARACTER(LEN=*), INTENT(IN) :: fn_name

#ifdef _WIN32
INTEGER(KIND=4) :: fn_pointer
#else
INTEGER(KIND=8) :: fn_pointer
#endif

INTEGER :: len
CHARACTER(LEN=250) :: name

len = LEN_TRIM(fn_name)
name = TRIM(fn_name)//ACHAR(0)

#ifdef DOING_WINDOWS
fn_pointer = GetProcAddress (dll_handle, TRIM(name))
#else
fn_pointer = get_func_so (dll_handle, TRIM(name))
#endif

END FUNCTION get_func_dll

The error message is pointed at the line:
fn_pointer = GetProcAddress (dll_handle, TRIM(name))
It reads:
Error: There is no matching specific function for this generic function reference. [GETPROCADDRESS]

Does one of the pointers need to be *4 rather than *8 ?

Steve Lionel (Intel)'s picture

Please get rid of your #ifdefs. Use INTEGER(HANDLE) for the declarations that are address-sized integers. The problem is that WIN32 is defined for both 32 and 64-bit. If you really wanted to test for this you could use _M_X64 but using the constants from IFWINTY (pulled in when you use kernel32) is the better and easier to read approach.

Steve

Login to leave a comment.