From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96075318306761.tru64-unix-managers.marc@archive.invalid> From: boris () gore ! afep ! cornell ! edu Date: Fri, 31 Mar 1995 20:31:00 +0000 To: tru64-unix-managers Subject: I'm doing something wrong with ar ... X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96075318306761 There seems to be a communication gap between me and the man pages, having to do with using ar and ld and making object module libraries. The result is that f2c doesn't work the way the directions say it should. The short version is this: main.c: #include extern void airnee(char *); extern void diddly(char *); extern void zponc(char *); main() { airnee("In function airnee now.\n"); diddly("In function diddly now.\n"); zponc("And now we are in function zponc\n"); } file1.c: #include void airnee(char *str) { printf(str); } file2.c: #include void diddly(char *str) { printf(str); } void zponc(char *str) { printf(str); } Now, assuming the above 3 files, if you do the following: gore> cc -o main main.c file1.c file2.c gore> main In function airnee now. In function diddly now. And now we are in function zponc gore> cc -c file1.c ; cc -c file2.c ; cc -o main main.c file1.o file2.o gore> main [same answer...good] gore> ar r libmy.a file1.o file2.o ; ranlib libmy.a ar: Warning: creating libmy.a s - creating symbol hash table. Wait... gore> cc -L. -lmy main.c ld: Unresolved: airnee diddly zponc [obviously isn't going to work] [and you get the same answer if you move libmy.a to the /usr/lib directory and don't screw around with the -L option] gore> cc -o main main.c libmy.a gore> main [works as expected] The process that the makefiles for f2c function libraries go through is in analogy to this. Net result is that if the name of the .o file is not exactly the same as the name of the function contained, or if one file contains more than one function, the linker can't find it if the library file is specified as a library, but it can find it if it is fed in along with the source files. So what did I screw up?