/* the library name is the same as the argument of the '-l' option */ LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname) { #ifdef TCC_TARGET_PE const char *libs[] = { "%s/%s.def", "%s/lib%s.def", "%s/%s.dll", "%s/lib%s.dll", "%s/lib%s.a", "%s/%s.c", NULL }; const char **pp = s->static_link ? libs + 4 : libs; const char *filename; #else const char *libs[] = { "%s/lib%s.so", "%s/lib%s.a", NULL }; const char **pp = s->static_link ? libs + 1 : libs; #endif while (*pp) { if (0 == tcc_add_library_internal(s, *pp, libraryname, 0, s->library_paths, s->nb_library_paths)) { #ifdef TCC_TARGET_PE /* extra search for c file together with def file if there is no dll */ if (pp < libs + 2) { filename = tcc_strdup(s->target_deps[s->nb_target_deps - 1]); strcpy(tcc_fileextension(filename), ".dll"); if (tcc_open(s, filename) < 0) { strcpy(tcc_fileextension(filename), ".c"); tcc_add_file_internal(s, filename, 0); } else tcc_close(); } #endif return 0; } ++pp; } return -1; }