digitalmars.D.learn - Undefined Windows function
- Kramer (47/47) Sep 17 2005 I'm trying to use a Windows function that I don't think is defined with ...
- Regan Heath (9/62) Sep 17 2005 The DMC libraries and include files do not seem to contain this function...
- John C (20/88) Sep 17 2005 The Win32 libraries distributed with D are very old, from 1995-1996, so
- Kramer (6/98) Sep 17 2005 Great. Thanks a lot for both responses. I will definitely be trying th...
- Kramer (6/98) Sep 17 2005 Great. Thanks a lot for both responses. I will definitely be trying th...
- Jarrett Billingsley (6/11) Sep 17 2005 The number after the @ is the number of bytes that are passed into the
- Kramer (15/107) Sep 17 2005 Well, I was able to create the library. Just wanted to post what I did ...
- J C Calvarese (9/43) Sep 17 2005 By the way, these aren't the only definition missing in DM's .lib files....
- J C Calvarese (6/57) Sep 17 2005 I think you explained the problem and solution very well, so I added you...
- John C (3/76) Sep 17 2005 Cool. Of course, I made a slight error. "IMPORTS" should be "EXPORTS".
- J C Calvarese (4/55) Sep 17 2005 Ah, that's right. I fixed it at the wiki. Thanks again.
I'm trying to use a Windows function that I don't think is defined with the DMD distribution. The code below seems to compile just fine, but I'm getting linker errors. I know that means the linker can't find the function in the object files, but I'm not sure how to proceed. I've given my best effort to provide the windows data structure and function definitions and am also linking to user32.lib which is what Microsoft says is the library that contains the function I'm looking for, but still to no avail. Any ideas would be greatly appreciated. ** I hope this code posts ok. The web interface doesn't always preserve spacing that great. :( This is what I compile with: dmd test.d user32.lib And this is the output: c:\dmd\bin\..\..\dm\bin\link.exe test,,,user32.lib+user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved test.obj(test) Error 42: Symbol Undefined _GetWindowInfo 8 --- errorlevel 1 Thanks in advance. -Kramer
Sep 17 2005
On Sat, 17 Sep 2005 09:05:40 +0000 (UTC), Kramer <Kramer_member pathlink.com> wrote:I'm trying to use a Windows function that I don't think is defined with the DMD distribution. The code below seems to compile just fine, but I'm getting linker errors. I know that means the linker can't find the function in the object files, but I'm not sure how to proceed. I've given my best effort to provide the windows data structure and function definitions and am also linking to user32.lib which is what Microsoft says is the library that contains the function I'm looking for, but still to no avail. Any ideas would be greatly appreciated. ** I hope this code posts ok. The web interface doesn't always preserve spacing that great. :( This is what I compile with: dmd test.d user32.lib And this is the output: c:\dmd\bin\..\..\dm\bin\link.exe test,,,user32.lib+user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved test.obj(test) Error 42: Symbol Undefined _GetWindowInfo 8 --- errorlevel 1 Thanks in advance.The DMC libraries and include files do not seem to contain this function. I suspect that is because it is reasonably new. (MSDN for MSVS6 does not have it, MSDN for VS.NET Beta 2 does). I am not sure how to solve it. I wonder if you can link with the MS libraries, you probably have to convert the library file format first. I would be interested to know the answer too. Regan
Sep 17 2005
"Regan Heath" <regan netwin.co.nz> wrote in message news:opsw8pdwk423k2f5 nrage.netwin.co.nz...On Sat, 17 Sep 2005 09:05:40 +0000 (UTC), Kramer <Kramer_member pathlink.com> wrote:The Win32 libraries distributed with D are very old, from 1995-1996, so anything introduced in Windows 98 and upwards won't be available. You can either call functions at runtime with GetProcAddress, or link them in at compile time. To do the latter, you need to create a new library file defining the function you wish to import, like so: 1) Create a new text file, called "user32ex.def", with the following content: LIBRARY user32 IMPORTS 2) Now list all the functions the linker says are undefined, eg _GetWindowInfo 8 = GetWindowInfo 3) Go to http://www.digitalmars.com/download/freecompiler.html and download the free "Basic Utilities" package, and unzip to c:\dm\bin or wherever your dm\bin directory is located. Then at the command line, cd to the directory you created the user32ex.def file (usually c:\dm\lib) and enter this: c:\dm\bin\implib user32ex.lib user32ex.def 4) Add user32ex.lib to your dmd command line when compiling John.I'm trying to use a Windows function that I don't think is defined with the DMD distribution. The code below seems to compile just fine, but I'm getting linker errors. I know that means the linker can't find the function in the object files, but I'm not sure how to proceed. I've given my best effort to provide the windows data structure and function definitions and am also linking to user32.lib which is what Microsoft says is the library that contains the function I'm looking for, but still to no avail. Any ideas would be greatly appreciated. ** I hope this code posts ok. The web interface doesn't always preserve spacing that great. :( This is what I compile with: dmd test.d user32.lib And this is the output: c:\dmd\bin\..\..\dm\bin\link.exe test,,,user32.lib+user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved test.obj(test) Error 42: Symbol Undefined _GetWindowInfo 8 --- errorlevel 1 Thanks in advance.The DMC libraries and include files do not seem to contain this function. I suspect that is because it is reasonably new. (MSDN for MSVS6 does not have it, MSDN for VS.NET Beta 2 does). I am not sure how to solve it. I wonder if you can link with the MS libraries, you probably have to convert the library file format first. I would be interested to know the answer too. Regan
Sep 17 2005
In article <dggt4s$19u$1 digitaldaemon.com>, John C says..."Regan Heath" <regan netwin.co.nz> wrote in message news:opsw8pdwk423k2f5 nrage.netwin.co.nz...Great. Thanks a lot for both responses. I will definitely be trying this. Out of curiosity though, what is the " 8" at the end of the function name. I don't know how to decipher the managled names. Thanks again. -KramerOn Sat, 17 Sep 2005 09:05:40 +0000 (UTC), Kramer <Kramer_member pathlink.com> wrote:The Win32 libraries distributed with D are very old, from 1995-1996, so anything introduced in Windows 98 and upwards won't be available. You can either call functions at runtime with GetProcAddress, or link them in at compile time. To do the latter, you need to create a new library file defining the function you wish to import, like so: 1) Create a new text file, called "user32ex.def", with the following content: LIBRARY user32 IMPORTS 2) Now list all the functions the linker says are undefined, eg _GetWindowInfo 8 = GetWindowInfo 3) Go to http://www.digitalmars.com/download/freecompiler.html and download the free "Basic Utilities" package, and unzip to c:\dm\bin or wherever your dm\bin directory is located. Then at the command line, cd to the directory you created the user32ex.def file (usually c:\dm\lib) and enter this: c:\dm\bin\implib user32ex.lib user32ex.def 4) Add user32ex.lib to your dmd command line when compiling John.I'm trying to use a Windows function that I don't think is defined with the DMD distribution. The code below seems to compile just fine, but I'm getting linker errors. I know that means the linker can't find the function in the object files, but I'm not sure how to proceed. I've given my best effort to provide the windows data structure and function definitions and am also linking to user32.lib which is what Microsoft says is the library that contains the function I'm looking for, but still to no avail. Any ideas would be greatly appreciated. ** I hope this code posts ok. The web interface doesn't always preserve spacing that great. :( This is what I compile with: dmd test.d user32.lib And this is the output: c:\dmd\bin\..\..\dm\bin\link.exe test,,,user32.lib+user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved test.obj(test) Error 42: Symbol Undefined _GetWindowInfo 8 --- errorlevel 1 Thanks in advance.The DMC libraries and include files do not seem to contain this function. I suspect that is because it is reasonably new. (MSDN for MSVS6 does not have it, MSDN for VS.NET Beta 2 does). I am not sure how to solve it. I wonder if you can link with the MS libraries, you probably have to convert the library file format first. I would be interested to know the answer too. Regan
Sep 17 2005
In article <dggt4s$19u$1 digitaldaemon.com>, John C says..."Regan Heath" <regan netwin.co.nz> wrote in message news:opsw8pdwk423k2f5 nrage.netwin.co.nz...Great. Thanks a lot for both responses. I will definitely be trying this. Out of curiosity though, what is the " 8" at the end of the function name. I don't know how to decipher the managled names. Thanks again. -KramerOn Sat, 17 Sep 2005 09:05:40 +0000 (UTC), Kramer <Kramer_member pathlink.com> wrote:The Win32 libraries distributed with D are very old, from 1995-1996, so anything introduced in Windows 98 and upwards won't be available. You can either call functions at runtime with GetProcAddress, or link them in at compile time. To do the latter, you need to create a new library file defining the function you wish to import, like so: 1) Create a new text file, called "user32ex.def", with the following content: LIBRARY user32 IMPORTS 2) Now list all the functions the linker says are undefined, eg _GetWindowInfo 8 = GetWindowInfo 3) Go to http://www.digitalmars.com/download/freecompiler.html and download the free "Basic Utilities" package, and unzip to c:\dm\bin or wherever your dm\bin directory is located. Then at the command line, cd to the directory you created the user32ex.def file (usually c:\dm\lib) and enter this: c:\dm\bin\implib user32ex.lib user32ex.def 4) Add user32ex.lib to your dmd command line when compiling John.I'm trying to use a Windows function that I don't think is defined with the DMD distribution. The code below seems to compile just fine, but I'm getting linker errors. I know that means the linker can't find the function in the object files, but I'm not sure how to proceed. I've given my best effort to provide the windows data structure and function definitions and am also linking to user32.lib which is what Microsoft says is the library that contains the function I'm looking for, but still to no avail. Any ideas would be greatly appreciated. ** I hope this code posts ok. The web interface doesn't always preserve spacing that great. :( This is what I compile with: dmd test.d user32.lib And this is the output: c:\dmd\bin\..\..\dm\bin\link.exe test,,,user32.lib+user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved test.obj(test) Error 42: Symbol Undefined _GetWindowInfo 8 --- errorlevel 1 Thanks in advance.The DMC libraries and include files do not seem to contain this function. I suspect that is because it is reasonably new. (MSDN for MSVS6 does not have it, MSDN for VS.NET Beta 2 does). I am not sure how to solve it. I wonder if you can link with the MS libraries, you probably have to convert the library file format first. I would be interested to know the answer too. Regan
Sep 17 2005
"Kramer" <Kramer_member pathlink.com> wrote in message news:dghiki$jf2$1 digitaldaemon.com...Great. Thanks a lot for both responses. I will definitely be trying this. Out of curiosity though, what is the " 8" at the end of the function name. I don't know how to decipher the managled names.The number after the is the number of bytes that are passed into the function as parameters. So a function that takes two int params (as this function does) will take 2 * 4 = 8 bytes. The _ at the beginning is also part of the mangling.
Sep 17 2005
In article <dggt4s$19u$1 digitaldaemon.com>, John C says..."Regan Heath" <regan netwin.co.nz> wrote in message news:opsw8pdwk423k2f5 nrage.netwin.co.nz...Well, I was able to create the library. Just wanted to post what I did (John thanks for the starting point; I used the user32_swt.def file from the DWT project as a working example). Here's my user32ex.def file: LIBRARY 'USER32.DLL' EXPORTS _GetWindowInfo 8 = GetWindowInfo _GetWindowModuleFileNameW 12 = GetWindowModuleFileNameW 12 And there here's the command line: c:\> implib user32ex.lib user32ex.def I'm trying to get the name of the program for whatever window has current focus. I hope this works! Thanks for the help! -KramerOn Sat, 17 Sep 2005 09:05:40 +0000 (UTC), Kramer <Kramer_member pathlink.com> wrote:The Win32 libraries distributed with D are very old, from 1995-1996, so anything introduced in Windows 98 and upwards won't be available. You can either call functions at runtime with GetProcAddress, or link them in at compile time. To do the latter, you need to create a new library file defining the function you wish to import, like so: 1) Create a new text file, called "user32ex.def", with the following content: LIBRARY user32 IMPORTS 2) Now list all the functions the linker says are undefined, eg _GetWindowInfo 8 = GetWindowInfo 3) Go to http://www.digitalmars.com/download/freecompiler.html and download the free "Basic Utilities" package, and unzip to c:\dm\bin or wherever your dm\bin directory is located. Then at the command line, cd to the directory you created the user32ex.def file (usually c:\dm\lib) and enter this: c:\dm\bin\implib user32ex.lib user32ex.def 4) Add user32ex.lib to your dmd command line when compiling John.I'm trying to use a Windows function that I don't think is defined with the DMD distribution. The code below seems to compile just fine, but I'm getting linker errors. I know that means the linker can't find the function in the object files, but I'm not sure how to proceed. I've given my best effort to provide the windows data structure and function definitions and am also linking to user32.lib which is what Microsoft says is the library that contains the function I'm looking for, but still to no avail. Any ideas would be greatly appreciated. ** I hope this code posts ok. The web interface doesn't always preserve spacing that great. :( This is what I compile with: dmd test.d user32.lib And this is the output: c:\dmd\bin\..\..\dm\bin\link.exe test,,,user32.lib+user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved test.obj(test) Error 42: Symbol Undefined _GetWindowInfo 8 --- errorlevel 1 Thanks in advance.The DMC libraries and include files do not seem to contain this function. I suspect that is because it is reasonably new. (MSDN for MSVS6 does not have it, MSDN for VS.NET Beta 2 does). I am not sure how to solve it. I wonder if you can link with the MS libraries, you probably have to convert the library file format first. I would be interested to know the answer too. Regan
Sep 17 2005
In article <dghq20$qp0$1 digitaldaemon.com>, Kramer says...In article <dggt4s$19u$1 digitaldaemon.com>, John C says....."Regan Heath" <regan netwin.co.nz> wrote in message news:opsw8pdwk423k2f5 nrage.netwin.co.nz...On Sat, 17 Sep 2005 09:05:40 +0000 (UTC), Kramer <Kramer_member pathlink.com> wrote:I'm trying to use a Windows function that I don't think is defined with the DMD distribution. The code below seems to compile just fine, but I'm getting linker errors. I know that means the linker can't find the function in the object files, but I'm not sure how to proceed. I've given my best effort to provide the windows data structure and function definitions and am also linking to user32.lib which is what Microsoft says is the library that contains the function I'm looking for, but still to no avail. Any ideas would be greatly appreciated.Well, I was able to create the library. Just wanted to post what I did (John thanks for the starting point; I used the user32_swt.def file from the DWT project as a working example). Here's my user32ex.def file: LIBRARY 'USER32.DLL' EXPORTS _GetWindowInfo 8 = GetWindowInfo _GetWindowModuleFileNameW 12 = GetWindowModuleFileNameW 12 And there here's the command line: c:\> implib user32ex.lib user32ex.def I'm trying to get the name of the program for whatever window has current focus. I hope this works! Thanks for the help! -KramerBy the way, these aren't the only definition missing in DM's .lib files. Some expanded .def files can be found here: http://svn.dsource.org/projects/bindings/trunk/def/ They include more definitions that the DM files do, so I use them instead of using the DM versions. They're kind of hacked together, so YMMV. Also, it seems there's not one for USER32.DLL yet, but I guess there should be. jcc7
Sep 17 2005
In article <dggt4s$19u$1 digitaldaemon.com>, John C says..."Regan Heath" <regan netwin.co.nz> wrote in message news:opsw8pdwk423k2f5 nrage.netwin.co.nz.....On Sat, 17 Sep 2005 09:05:40 +0000 (UTC), Kramer <Kramer_member pathlink.com> wrote:I'm trying to use a Windows function that I don't think is defined with the DMD distribution. The code below seems to compile just fine, but I'm getting linker errors. I know that means the linker can't find the function in the object files, but I'm not sure how to proceed. I've given my best effort to provide the windows data structure and function definitions and am also linking to user32.lib which is what Microsoft says is the library that contains the function I'm looking for, but still to no avail. Any ideas would be greatly appreciated.I think you explained the problem and solution very well, so I added your explanation to the wiki at the "error messages" page at: http://www.prowiki.org/wiki4d/wiki.cgi?ErrorMessages#Youneglectedtoprovidethelinkerwithaneededbinaryfile jcc7The Win32 libraries distributed with D are very old, from 1995-1996, so anything introduced in Windows 98 and upwards won't be available. You can either call functions at runtime with GetProcAddress, or link them in at compile time. To do the latter, you need to create a new library file defining the function you wish to import, like so: 1) Create a new text file, called "user32ex.def", with the following content: LIBRARY user32 IMPORTS 2) Now list all the functions the linker says are undefined, eg _GetWindowInfo 8 = GetWindowInfo 3) Go to http://www.digitalmars.com/download/freecompiler.html and download the free "Basic Utilities" package, and unzip to c:\dm\bin or wherever your dm\bin directory is located. Then at the command line, cd to the directory you created the user32ex.def file (usually c:\dm\lib) and enter this: c:\dm\bin\implib user32ex.lib user32ex.def 4) Add user32ex.lib to your dmd command line when compiling John.Error 42: Symbol Undefined _GetWindowInfo 8 --- errorlevel 1 Thanks in advance.The DMC libraries and include files do not seem to contain this function. I suspect that is because it is reasonably new. (MSDN for MSVS6 does not have it, MSDN for VS.NET Beta 2 does). I am not sure how to solve it. I wonder if you can link with the MS libraries, you probably have to convert the library file format first. I would be interested to know the answer too. Regan
Sep 17 2005
"J C Calvarese" <technocrat7 gmail.com> wrote in message news:dgi1da$10mn$1 digitaldaemon.com...In article <dggt4s$19u$1 digitaldaemon.com>, John C says...Cool. Of course, I made a slight error. "IMPORTS" should be "EXPORTS"."Regan Heath" <regan netwin.co.nz> wrote in message news:opsw8pdwk423k2f5 nrage.netwin.co.nz.....On Sat, 17 Sep 2005 09:05:40 +0000 (UTC), Kramer <Kramer_member pathlink.com> wrote:I'm trying to use a Windows function that I don't think is defined with the DMD distribution. The code below seems to compile just fine, but I'm getting linker errors. I know that means the linker can't find the function in the object files, but I'm not sure how to proceed. I've given my best effort to provide the windows data structure and function definitions and am also linking to user32.lib which is what Microsoft says is the library that contains the function I'm looking for, but still to no avail. Any ideas would be greatly appreciated.I think you explained the problem and solution very well, so I added your explanation to the wiki at the "error messages" page at: http://www.prowiki.org/wiki4d/wiki.cgi?ErrorMessages#Youneglectedtoprovidethelinkerwithaneededbinaryfile jcc7The Win32 libraries distributed with D are very old, from 1995-1996, so anything introduced in Windows 98 and upwards won't be available. You can either call functions at runtime with GetProcAddress, or link them in at compile time. To do the latter, you need to create a new library file defining the function you wish to import, like so: 1) Create a new text file, called "user32ex.def", with the following content: LIBRARY user32 IMPORTS 2) Now list all the functions the linker says are undefined, eg _GetWindowInfo 8 = GetWindowInfo 3) Go to http://www.digitalmars.com/download/freecompiler.html and download the free "Basic Utilities" package, and unzip to c:\dm\bin or wherever your dm\bin directory is located. Then at the command line, cd to the directory you created the user32ex.def file (usually c:\dm\lib) and enter this: c:\dm\bin\implib user32ex.lib user32ex.def 4) Add user32ex.lib to your dmd command line when compiling John.Error 42: Symbol Undefined _GetWindowInfo 8 --- errorlevel 1 Thanks in advance.The DMC libraries and include files do not seem to contain this function. I suspect that is because it is reasonably new. (MSDN for MSVS6 does not have it, MSDN for VS.NET Beta 2 does). I am not sure how to solve it. I wonder if you can link with the MS libraries, you probably have to convert the library file format first. I would be interested to know the answer too. Regan
Sep 17 2005
In article <dgi423$12v5$1 digitaldaemon.com>, John C says..."J C Calvarese" <technocrat7 gmail.com> wrote in message news:dgi1da$10mn$1 digitaldaemon.com.....In article <dggt4s$19u$1 digitaldaemon.com>, John C says..."Regan Heath" <regan netwin.co.nz> wrote in message news:opsw8pdwk423k2f5 nrage.netwin.co.nz.....On Sat, 17 Sep 2005 09:05:40 +0000 (UTC), Kramer <Kramer_member pathlink.com> wrote:I'm trying to use a Windows function that I don't think is defined with the DMD distribution. The code below seems to compile just fine, but I'm getting linker errors. I know that means the linker can't find the function in the object files, but I'm not sure how to proceed. I've given my best effort to provide the windows data structure and function definitions and am also linking to user32.lib which is what Microsoft says is the library that contains the function I'm looking for, but still to no avail. Any ideas would be greatly appreciated.Error 42: Symbol Undefined _GetWindowInfo 8 --- errorlevel 1Ah, that's right. I fixed it at the wiki. Thanks again. jcc7Cool. Of course, I made a slight error. "IMPORTS" should be "EXPORTS".IMPORTS 2) Now list all the functions the linker says are undefined, eg _GetWindowInfo 8 = GetWindowInfo 3) Go to http://www.digitalmars.com/download/freecompiler.html and download the free "Basic Utilities" package, and unzip to c:\dm\bin or wherever your dm\bin directory is located. Then at the command line, cd to the directory you created the user32ex.def file (usually c:\dm\lib) and enter this: c:\dm\bin\implib user32ex.lib user32ex.def 4) Add user32ex.lib to your dmd command line when compiling John.I think you explained the problem and solution very well, so I added your explanation to the wiki at the "error messages" page at: http://www.prowiki.org/wiki4d/wiki.cgi?ErrorMessages#Youneglectedtoprovidethelinkerwithaneededbinaryfile jcc7
Sep 17 2005