Is it possible to link in .lib files using winelib and winemaker? If possible, what switch do I give winemaker? My application when compiled under Windows linked in a .lib file and I would rather not modify the source code. I've tried using the -l switch, but this is obviously only for *nix libraries even when compiling with winelib. Or, other suggestions to resolve all the undefined reference errors?
Thanks in advance, Chris
On Wed, 7 Nov 2001, Chris Dawson wrote:
Is it possible to link in .lib files using winelib and winemaker? If possible, what switch do I give winemaker? My application when compiled under Windows linked in a .lib file and I would rather not modify the source code. I've tried using the -l switch, but this is obviously only for *nix libraries even when compiling with winelib. Or, other suggestions to resolve all the undefined reference errors?
Thanks in advance, Chris
I think you don't need to link the .lib files. let winemaker generate the .spec file and it will generate code to do what the .lib files do in windose. I think. I am not much on windose, but I like winemaker. Your app can just call the functions it wants, and winemaker generates code to take care of the LoadLibrary and GetProcAddress and stuff that the .lib does, I think.
Lawson ---oof---
Hmm, well, the problem is that winemaker/wine are not doing this for me, AFAIK.
1. When compiling the project, I get a whole bunch of "undefined reference to xxx_XXXX function" errors. These are symbols that the .lib defines, so I know that this library is not getting linked in properly.
2. When I try to run the program, I get "undefined symbol: xxx_XXXX" errors, so I assume that Wine isn't doing it's job either.
I guess the most important thing for me is that I get confirmation that .lib files can be either statically linked in using gcc, or if there is another existing mechanism for this. In MSVC I just add the .lib to the list of library files and make sure the path is there, and it works, so I don't understand much more about what I might need to do under Linux, especially with wine.
Thanks, Chris
-----Original Message----- From: lawson_whitney@juno.com [mailto:lawson_whitney@juno.com] Sent: Wednesday, November 07, 2001 6:07 PM To: cdawson@webiphany.com; lawson_whitney@juno.com Cc: wine-devel@winehq.com Subject: Re: linking in .lib files
On Wed, 7 Nov 2001, Chris Dawson wrote:
Is it possible to link in .lib files using winelib and winemaker? If possible, what switch do I give winemaker? My application when compiled under Windows linked in a .lib file and I would rather not modify the
source
code. I've tried using the -l switch, but this is obviously only for *nix libraries even when compiling with winelib. Or, other suggestions to resolve all the undefined reference errors?
Thanks in advance, Chris
I think you don't need to link the .lib files. let winemaker generate the .spec file and it will generate code to do what the .lib files do in windose. I think. I am not much on windose, but I like winemaker. Your app can just call the functions it wants, and winemaker generates code to take care of the LoadLibrary and GetProcAddress and stuff that the .lib does, I think.
Lawson ---oof---
You cannot use .lib files directly with Winelib. The reason is that winebuild does not support reading .lib files. Support for '.lib' files (or possibly even '.dll' files) could be added in but it is not there currently.
Exactly how you deal with that depends on what your situation: 1) if you have the sources of the library you want to link with, then the best solution is to compile it with Winelib too. 2) if you don't have the sources for this library (and it's not one of the standard Wine libraries), then you will have to write a stub library that you will use for just the purpose of linking your application.
In both cases you will need to create a '.spec' file containing a list of the functions (with parameters) exported by that library. See the following URL for a documentation of the exact format of .spec files:
http://wine.codeweavers.com/docs/winelib-user/spec-file.shtml
Case 1: The '.spec' files generated by Winemaker are mostly useful for compiling applications that just import libraries. When Winemaker generates the build environment for a library it will not declare the exported functions in the '.spec' file because it has no knowledge of which functions are exported. Winemaker could potentially be extended to generate a list of exported functions when the '.dll' is available by interfacing it with winedump. So if your library only exports a few functions, the easiest solution is to just declare them manually in the '.spec' file. Otherwise you should use winedump much as described in case 2, and then copy the .spec file over to where you compile your library.
Case 2: Generating a stub library: the best way to do so is to use winedump. For that I recommend that you read 'tools/winedump/README' and especially the section 'Generating stub DLLS'. Once you have linked your application with the stub library, it can run with just the native dll... unless we are talking about a C++ library. C++ libraries are troublesome because g++ does not use the same name mangling as Visual C++ (although maybe g++ 3.0 changed that). So you will need the stub library to do the bridging. But I am not sure whether winedump can handle this sort of bridging.
There is another roadblock that you may hit in both cases: winebuild does not support importing a variable from another library (because of ELF limitations). Importing functions is ok, but not variables. This means that if you are dealing with a C++ library you will need to link with it in the Unix sense. If we are talking about C code, then there are ways around it that require only relatively simple code changes. It is also another reason why you will never be able to use a native C++ library directly (because the virtual table pointers are handled as variables).
One last note: specmaker has been folded into winedump recently. So if you hear/read things about specmaker you know that you have to look for winedump.
On Wed, 7 Nov 2001, Chris Dawson wrote:
Hmm, well, the problem is that winemaker/wine are not doing this for me, AFAIK.
- When compiling the project, I get a whole bunch of "undefined reference
to xxx_XXXX function" errors. These are symbols that the .lib defines, so I know that this library is not getting linked in properly.
Maybe it is my mistake. I thought the .lib only took care of dynamic linking to dlls. If it does c++ name mangling or so, c++ has a cloven hoof and I don't touch it. But I am confident g++ mangles names in a way that is totally incompatible with MSVC.
- When I try to run the program, I get "undefined symbol: xxx_XXXX"
errors, so I assume that Wine isn't doing it's job either.
If you got "undefined reference" errors linking, you don't _have_ a program to run.
I guess the most important thing for me is that I get confirmation that .lib files can be either statically linked in using gcc, or if there is another existing mechanism for this. In MSVC I just add the .lib to the list of library files and make sure the path is there, and it works, so I don't understand much more about what I might need to do under Linux, especially with wine.
Thanks, Chris
AFAIK we don't have anything that eats .lib files. dll's are indigestible enough. If you have the source to the .lib's, you might try running that through winemaker too. If not, maybe the author of winemaker will be along presently to help out.
Lawson ---oof---
________________________________________________________________ GET INTERNET ACCESS FROM JUNO! Juno offers FREE or PREMIUM Internet access for less! Join Juno today! For your FREE software, visit: http://dl.www.juno.com/get/web/.