|
From: Carl S. <stu...@gm...> - 2015-02-07 18:29:43
|
New to in-depth use of MinGW. But it's clearly the right thing!
According to MSDN GetComputerNameExA is in kernel32.dll ,
yet the following program compiles but does not link with my MinGW
installation. Adding -lkernel32 doesn't help. Details below. Any
suggestions how I can get linkage?
========
#include <windows.h>
#include <stdio.h>
int main() {
char buf[1024];
DWORD sz = 1024;
//GetComputerNameA( buf, &sz);
GetComputerNameExA( 1, buf, &sz);
printf( "\"%s\"\n", buf);
}
========
msys $ gcc -o gethostname gethostname.c
C:\temp\ccmcT7xy.o:gethostname.c:(.text+0x31):
undefined reference to `GetComputerNameExA'
collect2.exe: error: ld returned 1 exit status
msys $ gcc --version
gcc.exe (GCC) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
msys $ uname -a
MINGW32_NT-6.1 CARL 1.0.17(0.48/3/2) 2011-04-24 23:39 i686 Msys
========
|