From: Nate Eldredge Newsgroups: comp.os.msdos.djgpp Subject: Re: creating libraries how? Date: 23 Jan 2000 13:42:15 -0800 Organization: InterWorld Communications Lines: 61 Message-ID: <83n1pwo47c.fsf@mercury.st.hmc.edu> References: <388B06EA DOT D02633F AT connection DOT com> NNTP-Posting-Host: mercury.st.hmc.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: nntp1.interworld.net 948663848 8144 134.173.45.219 (23 Jan 2000 21:44:08 GMT) X-Complaints-To: usenet AT nntp1 DOT interworld DOT net NNTP-Posting-Date: 23 Jan 2000 21:44:08 GMT User-Agent: Gnus/5.0802 (Gnus v5.8.2) Emacs/20.5 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com sam writes: > Ok, boys anyone that knows what I am doing? I don't. > > > I have the following source file TLFUNC.CC [snip] > > I have compiled it with: > d:\djgpp\applib\>gcc -c tlfunc.cc > > Now I create library with: > d:\djgpp\applib\>ar -rs libtl.a tlfunc.cc > > verify that the index is there by doing list: (with -t not -s > or -nm > > as the first page of info ar suggests.) > d:\djgpp\applib\>ar -t libtl.a > (get tlfunc.o) > So, I try to build the following file: (maintest.cc) [snip] > > With: > > 8:36:04.79 > D:\DJGPP\mytests>gpp maintest.cc -I..\applib -L..\applib\tl -o > maintest.exe You're confusing the options. The -L option gives a directory in which to search for libraries. The -l (lower case) option actually specifies a library. So what you want is: gpp maintest.cc -I..\applib -L..\applib -ltl -l maintest.exe > d:/djgpp/tmp\ccM794sS.o(.text+0x6b):maintest.cc: undefined reference to > `color_t > ext(int, int, int, int, char *)' > d:/djgpp/tmp\ccM794sS.o(.text+0xa2):maintest.cc: undefined reference to > `color_t > ext(int, int, int, int, char *)' > collect2: ld returned 1 exit status > > 8:36:32.25 > D:\DJGPP\mytests> > > GCC is the same think. > > BTW: which is the one that will pick language according to the extension > GCC | GPP. Both, really. The problem is that this only applies to the compilation phase, and not the linking. So using foo.c vs foo.cc will cause them to be compiled as the proper language, but it won't cause the C++ libraries to be linked. You always have to tell the compiler that by using `gpp'. -- Nate Eldredge neldredge AT hmc DOT edu