Hi!
I am trying to compile this simple code with the C compiler (i.e. pgcc) :
#include <windows.h>
int main(void) {
return 0;
}
But, I get these errors =>
PGC-W-0043-Redefinition of symbol, va_list (C:\PROGRA~1\PGI/win32/8.0-2/include\stdarg.h: 37)
PGC-W-0114-More than one type specified (C:\PROGRA~1\PGI/win32/8.0-2/include\WinNT9.h: 284)
PGC-W-0143-Useless typedef declaration (no declarators present) (C:\PROGRA~1\PGI/win32/8.0-2/include\WinNT9.h: 284)
PGC-W-0043-Redefinition of symbol, PFORMAT_STRING (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\rpcndr.h: 547)
PGC-W-0043-Redefinition of symbol, MIDL_STUB_MESSAGE (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\rpcndr.h: 777)
PGC-W-0043-Redefinition of symbol, PMIDL_STUB_MESSAGE (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\rpcndr.h: 777)
PGC-W-0043-Redefinition of symbol, MIDL_SYNTAX_INFO (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\rpcndr.h: 1124)
PGC-W-0043-Redefinition of symbol, PMIDL_SYNTAX_INFO (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\rpcndr.h: 1124)
PGC-W-0114-More than one type specified (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\wtypes.h: 380)
PGC-W-0143-Useless typedef declaration (no declarators present) (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\wtypes.h: 380)
PGC-W-0114-More than one type specified (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\wtypes.h: 382)
PGC-W-0143-Useless typedef declaration (no declarators present) (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\wtypes.h: 382)
PGC-W-0114-More than one type specified (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\wtypes.h: 384)
PGC-W-0143-Useless typedef declaration (no declarators present) (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\wtypes.h: 384)
PGC-W-0114-More than one type specified (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\wtypes.h: 386)
PGC-W-0143-Useless typedef declaration (no declarators present) (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\wtypes.h: 386)
PGC-W-0114-More than one type specified (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\wtypes.h: 686)
PGC-W-0143-Useless typedef declaration (no declarators present) (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\wtypes.h: 686)
PGC-W-0114-More than one type specified (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\wtypes.h: 691)
PGC-W-0143-Useless typedef declaration (no declarators present) (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\wtypes.h: 691)
PGC-W-0114-More than one type specified (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\wtypes.h: 1117)
PGC-W-0143-Useless typedef declaration (no declarators present) (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\wtypes.h: 1117)
PGC-W-0114-More than one type specified (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\winsmcrd.h: 31)
PGC-W-0143-Useless typedef declaration (no declarators present) (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\winsmcrd.h: 31)
PGC-W-0114-More than one type specified (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\winsmcrd.h: 33)
PGC-W-0143-Useless typedef declaration (no declarators present) (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\winsmcrd.h: 33)
PGC-W-0043-Redefinition of symbol, LPCVOID (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\winscard.h: 47)
PGC-W-0114-More than one type specified (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\objidl.h: 269)
PGC-W-0143-Useless typedef declaration (no declarators present) (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\objidl.h: 269)
PGC-W-0114-More than one type specified (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\objidl.h: 305)
PGC-W-0143-Useless typedef declaration (no declarators present) (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\objidl.h: 305)
PGC-W-0043-Redefinition of symbol, LPTYPELIB (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\oleauto.h: 916)
PGC-W-0114-More than one type specified (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\oleauto.h: 924)
PGC-W-0143-Useless typedef declaration (no declarators present) (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\oleauto.h: 924)
PGC-W-0114-More than one type specified (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\oleauto.h: 925)
PGC-W-0143-Useless typedef declaration (no declarators present) (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\oleauto.h: 925)
PGC-W-0043-Redefinition of symbol, LPTYPEINFO (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\oleauto.h: 937)
PGC-W-0043-Redefinition of symbol, LPTYPECOMP (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\oleauto.h: 944)
PGC-W-0043-Redefinition of symbol, LPCREATETYPELIB (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\oleauto.h: 951)
PGC-W-0043-Redefinition of symbol, LPCREATETYPEINFO (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\oleauto.h: 953)
PGC-W-0043-Redefinition of symbol, LPDISPATCH (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\oleauto.h: 1047)
PGC-W-0114-More than one type specified (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\commdlg.h: 698)
PGC-W-0143-Useless typedef declaration (no declarators present) (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\commdlg.h: 698)
PGC-W-0043-Redefinition of symbol, LPUINT (C:/Program Files/PGI/Microsoft Open Tools 9/PlatformSDK/include\imm.h: 28)
PGC/x86 Windows 8.0-2: compilation completed with warnings
Of course, there must be interference between “C:\Program Files\PGI\Microsoft Open Tools 9\include” and “C:\Program Files\PGI\win32\8.0-2\include”. . . How to fix that?
As I see, pgcc isnt connected with usual environment variables such as INCLUDE . . .
Im on Windows XP SP3 x32 bit . . .
Running pgcc on cmd.exe, not bash, but i get the same errors with bash w/e…
Thank you!
Cordially,
Yannick B.
Hi Yannick,
These are just warnings and can safely be ignored. To disable warning messages, add the “-w” flag to you compilation.
Hope this helps,
Mat
I would be partially satisfied of this answer if this was not a blocker . . .
However.
I cannot even compile such a code :
#include <windows.h>
int main(void) {
ShellExecute(NULL, "open", "cmd.exe", "/K "echo Hello world!"", "C:\\WINDOWS\\system32", SW_SHOWNORMAL);
return 0;
}
When I type this in cmd.exe
pgcc pgtest.c -w>text.txt 2>&1
The collected output of pgcc is :
How can I fix this?!
Thanks!!
Hi Yannick,
You need to link with the library that contains this symbol.
Doing a web search, I found that “ShellExecuteA” is contained in the “shell32.dll” library. To use this DLL, you need to link with it’s import library “shell32.lib”. Example:
PGI$ cat test.c
#include <windows.h>
int main(void) {
ShellExecute(NULL, "open", "cmd.exe", "/K \"echo Hello world!\"", "C:\\WINDOWS\\system32", SW_SHOWNORMAL);
return 0;
}
PGI$ pgcc test.c -w
PGC/x86-64 Windows 8.0-3: compilation completed with warnings
pgcc4cqKSWrpW2DIS.obj : error LNK2019: unresolved external symbol __imp_ShellExecuteA referenced in function main
test.exe : fatal error LNK1120: 1 unresolved externals
PGI$ pgcc test.c -w shell32.lib
test.c:
PGC/x86-64 Windows 8.0-3: compilation completed with warnings
PGI$ ls test.exe
test.exe
PGI$
Hope this helps,
Mat