winewrap: support linking to .so libraries
Dimitrie O. Paun
dpaun at rogers.com
Sat Jan 4 09:47:54 CST 2003
Guidance in this matter would be highly appreciated.
Problem:
We have to worry about 3 types of libraries:
.dll, .a, and .so. MinGW programs use both
.dll, and .a libs. Sometimes, they specify
-lstdc++ or similar on the command line, which
map to a .so file in Unix.
Algorithm:
For every -l lib, I do:
- search the lib path first for a lib<lib>.def file.
If found, I assume we're linking with a .dll, and
I pass the -l to winebuild
- if not, I search the lib path (plus ., /usr/lib,
and /usr/local/lib) for a lib<lib>.a file.
If found, I just pass it as a file to winebuild,
so that it's search for symbols like any other
.o file
- if I can't file the .def or .a file, I pass the -l
along to the linker, leaving it to it to deal with
the problem.
Question:
Any ideas for improvement? Present algo works well for
the apps I tested with, but I can see how it can go
wrong. What do you guys think?
ChangeLog
Pass -l's that are not .dll's or .a's to the linker.
Index: tools/winewrap.c
===================================================================
RCS file: /var/cvs/wine/tools/winewrap.c,v
retrieving revision 1.9
diff -u -r1.9 winewrap.c
--- tools/winewrap.c 3 Jan 2003 22:31:45 -0000 1.9
+++ tools/winewrap.c 4 Jan 2003 15:27:58 -0000
@@ -235,8 +235,8 @@
;
static char *output_name;
-static char **lib_files, **dll_files, **lib_paths, **obj_files;
-static int nb_lib_files, nb_dll_files, nb_lib_paths, nb_obj_files;
+static char **arh_files, **dll_files, **lib_files, **lib_paths, **obj_files;
+static int nb_arh_files, nb_dll_files, nb_lib_files, nb_lib_paths, nb_obj_files;
static int verbose = 0;
static int keep_generated = 0;
@@ -401,6 +401,8 @@
lib_paths[nb_lib_paths++] = strdup(path);
dll_files = realloc( dll_files, (nb_dll_files+1) * sizeof(*dll_files) );
dll_files[nb_dll_files++] = strmake("-L%s", path);
+ lib_files = realloc( lib_files, (nb_lib_files+1) * sizeof(*lib_files) );
+ lib_files[nb_lib_files++] = strmake("-L%s", path);
}
void add_lib_file(const char* library)
@@ -414,10 +416,14 @@
}
else if ((lib = find_lib(library)))
{
+ arh_files = realloc( arh_files, (nb_arh_files+1) * sizeof(*arh_files) );
+ arh_files[nb_arh_files++] = lib;
+ }
+ else
+ {
lib_files = realloc( lib_files, (nb_lib_files+1) * sizeof(*lib_files) );
lib_files[nb_lib_files++] = lib;
}
- else error("Can not find library %s", library);
}
int main(int argc, char **argv)
@@ -529,7 +535,7 @@
wrap_o_name = strmake("%s.o", wrp_temp_name);
/* build winebuild's argument list */
- spec_args = malloc( (nb_lib_files + nb_dll_files + nb_obj_files + 20) * sizeof (char *) );
+ spec_args = malloc( (nb_arh_files + nb_dll_files + nb_obj_files + 20) * sizeof (char *) );
j = 0;
spec_args[j++] = BINDIR "/winebuild";
spec_args[j++] = "-o";
@@ -551,8 +557,8 @@
spec_args[j++] = dll_files[i];
for (i = 0; i < nb_obj_files; i++)
spec_args[j++] = obj_files[i];
- for (i = 0; i < nb_lib_files; i++)
- spec_args[j++] = lib_files[i];
+ for (i = 0; i < nb_arh_files; i++)
+ spec_args[j++] = arh_files[i];
spec_args[j] = 0;
/* build gcc's argument list */
@@ -567,20 +573,22 @@
comp_args[j] = 0;
/* build ld's argument list */
- link_args = malloc( (nb_lib_files + nb_obj_files + 20) * sizeof (char *) );
+ link_args = malloc( (nb_arh_files + nb_obj_files + nb_lib_files + 20) * sizeof (char *) );
j = 0;
link_args[j++] = cpp ? "g++" : "gcc";
link_args[j++] = "-shared";
link_args[j++] = "-Wl,-Bsymbolic,-z,defs";
link_args[j++] = "-lwine";
link_args[j++] = "-lm";
+ for (i = 0; i < nb_lib_files; i++)
+ link_args[j++] = lib_files[i];
link_args[j++] = "-o";
link_args[j++] = strmake("%s.%s.so", base_file, create_wrapper ? "dll" : "exe");
link_args[j++] = spec_o_name;
for (i = 0; i < nb_obj_files; i++)
if (!is_resource(obj_files[i])) link_args[j++] = obj_files[i];
- for (i = 0; i < nb_lib_files; i++)
- link_args[j++] = lib_files[i];
+ for (i = 0; i < nb_arh_files; i++)
+ link_args[j++] = arh_files[i];
link_args[j] = 0;
/* build wrapper compile argument list */
--
Dimi.
More information about the wine-patches
mailing list