- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you want to build a Win-64 EXE, you should use, instead of
the command
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?
[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?
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is UserEnv.Lib composed of 64-bit objects? What is its pedigree?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you want to build a Win-64 EXE, you should use, instead of
the command
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?
[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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot!
The solution is link against
/c/Program\Files/Microsoft\SDKs/Windows/v6.0A/Lib/x64/UserEnv.Lib
The solution is link against
/c/Program\Files/Microsoft\SDKs/Windows/v6.0A/Lib/x64/UserEnv.Lib

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page