Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

MinGW / Win64 / Intel C Compiler

basel
Beginner
983 Views

Hi,

I am trying to compile a C program using the Intel icl compiler under MINGW/64. The program uses the following code:

#include 
HANDLE process;
HANLDE token;
GetUserProfileDirectory(process, TOKEN_QUERY, &ptoken)

I am using the following compile command:

$ icl test.c -DMINGW32 -link /c/Program\\ Files/Microsoft\\ SDKs/Windows/v6.0A/Lib/UserEnv.Lib

or

$ icl test.c -DMINGW32 -link ./UserEnv.Lib

The errror message is always

LNK2019: unresolved external symbol __imp_GetUserNameA referenced in function main 
test.obj : error LNK2019: unresolved external symbol __imp_OpenProcessToken referenced in function main
test.obj : error LNK2019: unresolved external symbol

The code is working correctly under 32-bit and I am habving linking problems under 64-bit.

Thanks!

0 Kudos
1 Solution
mecej4
Honored Contributor III
983 Views
If you want to build a Win-64 EXE, you should use, instead of

[bash]$ icl test.c -DMINGW32 -link /c/Program Files/Microsoft SDKs/Windows/v6.0A/Lib/UserEnv.Lib 
[/bash]

the command

[bash]$ icl test.c -DMINGW32 -link /c/Program Files/Microsoft SDKs/Windows/v6.0A/Lib/x64/UserEnv.Lib 
[/bash]

I confess that I do not see what your objectives may be, since you are using a compiler and a library neither of which has anything to do with MINGW. Any mixing of MINGW and Microsoft/Intel C-header files and libraries is very likely to cause trouble. Furthermore, you defined the preprocessor symbol MINGW32 even for your 64-bit build. Why?

View solution in original post

0 Kudos
4 Replies
mecej4
Honored Contributor III
983 Views
Is UserEnv.Lib composed of 64-bit objects? What is its pedigree?
0 Kudos
basel
Beginner
983 Views
I copied the file UserENV.Lib from x64 file from the Microsoft SDK directory Windows\v6.0A\Lib

Here is the dumpbin output:

$ dumpbin -SYMBOLS ./UserEnv.Lib
Microsoft COFF/PE Dumper Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.


Dump of file ./UserEnv.Lib

File Type: LIBRARY

COFF SYMBOL TABLE
000 007BC627 ABS notype Static | @comp.id
001 00000000 SECT2 notype External | __IMPORT_DESCRIPTOR_USERENV
002 C0000040 SECT2 notype Section | .idata$2
003 00000000 SECT3 notype Static | .idata$6
004 C0000040 UNDEF notype Section | .idata$4
005 C0000040 UNDEF notype Section | .idata$5
006 00000000 UNDEF notype External | __NULL_IMPORT_DESCRIPTOR
007 00000000 UNDEF notype External | USERENV_NULL_THUNK_DATA

String Table Size = 0x52 bytes

COFF SYMBOL TABLE
000 007BC627 ABS notype Static | @comp.id
001 00000000 SECT2 notype External | __NULL_IMPORT_DESCRIPTOR

String Table Size = 0x1D bytes

COFF SYMBOL TABLE
000 007BC627 ABS notype Static | @comp.id
001 00000000 SECT2 notype External | USERENV_NULL_THUNK_DATA

String Table Size = 0x1D bytes

Summary

C6 .debug$S
14 .idata$2
14 .idata$3
4 .idata$4
4 .idata$5
C .idata$6
0 Kudos
mecej4
Honored Contributor III
984 Views
If you want to build a Win-64 EXE, you should use, instead of

[bash]$ icl test.c -DMINGW32 -link /c/Program Files/Microsoft SDKs/Windows/v6.0A/Lib/UserEnv.Lib 
[/bash]

the command

[bash]$ icl test.c -DMINGW32 -link /c/Program Files/Microsoft SDKs/Windows/v6.0A/Lib/x64/UserEnv.Lib 
[/bash]

I confess that I do not see what your objectives may be, since you are using a compiler and a library neither of which has anything to do with MINGW. Any mixing of MINGW and Microsoft/Intel C-header files and libraries is very likely to cause trouble. Furthermore, you defined the preprocessor symbol MINGW32 even for your 64-bit build. Why?
0 Kudos
basel
Beginner
983 Views
Thanks a lot!

The solution is link against

/c/Program\Files/Microsoft\SDKs/Windows/v6.0A/Lib/x64/UserEnv.Lib
0 Kudos
Reply