I am working recycling a project of my own than works. The new project is similar in 60% of the old one. Several classes files are used with out any change. Other ones have been created and proved. Note. I am using PNGwriter library with freetype options (in old and new projects) I only have *.c and *.h files extensions in my proyect. With the old proyect I used for compilation: $g ./prueba.cc -o prueba `freetype-config --cflags` -I/usr/local/include -L/usr/local/lib -lpng -lpngwriter -lz -lfreetype The same I am using to the new one until de "undefined reference to <function name> problem appears. I am trying with your ideas, but I can not solve the problem. I proved with $gcc -c *.cc `freetype-config --cflags` $gcc <list of *.o> -o prueba `freetype-config --cflags` -I/usr/local/include -L/usr/local/lib -lpng -lpngwriter -lz -lfreetype Compilation works, but linking no. The same error messagge from the direct command. I was looking solutions from google, google groups, I was commented several parts of the crucial files but anything works. I prove with the simple main.cc, foo.c and foo.h example and I realize the same problem is given so the problem is complex for me. Why the solution should be change the compilation command? Why if it works before? Is it possible than my compiler files were damaged? Why similar projects have different behavior? Thanks for your help. John Love-Jensen escribió: > Hi Ramirez, > >> What is the order criteria? > > The GCC tool chain driver processes items left to right. > > Object files (or source files which compile to object files) are always > taken in their entirety. > > Archive libraries only bring in the objects from within the archive that > satisfy missing symbols. > > If archive libfoo.a has undefined symbols that are satisfied in libbar.a, > then libbar.a needs to appear after libfoo.a. Regardless if they are > specified via -lfoo -lbar, or libfoo.a libbar.a or -lfoo libbar.a or > libfoo.a -libbar.a. > > Shared object libraries are brought in as SSO (static shared object) as > specified on the command line. An SSO may have its own dependencies. NOTE: > if you bring in a shared object library programmatically, that's called a > DSO (dynamic shared object). > > There are some situations where there is both a libfoo.a and libfoo.so. If > left to -lfoo to resolve, the one that is brought in is dependent on your > particular platform and if you overrode the platform bias. > > Note: I'm using "libfoo.a" and "libfoo.so", but you may have a platform > like the Amiga that uses "foo.a" and "foo.library", or Windows which uses > "foo.lib" and "foo.dll", or OS X which uses "libfoo.a" and "libfoo.dylib". > So your mileage may vary. > > The rule of thumb is: > specify all your .o files first (in any order) > specify all your .a and .so libraries in their dependency order > > And if you are running into a circular dependency between libfoo.a and > libbar.a, you'll have to do something utterly horrible like... > > g -o myapp one.o two.o three.o -lfoo -lbar -lfoo > > HTH, > --Eljay > > > Gengis Kanhg Toledo Ramirez escribió: > Thanks, it works. > > The simple example was only a sample from the real problem I have. > I have 10 .cc files and other amount of .h files, I realize that order > of files is important at the g command. In my OOP project I have some > files as my own libraries used in several others files, then it is not > clear for me the order to be followed. > > What is the order criteria? > Where can I get information about? > > Thanks you very much. > > > John Love-Jensen escribió: >> Hi Ramirez, >> >> Try this: >> >> g main.cc foo.cc -o prueba >> >> HTH, >> --Eljay >> >> >> > > The problem: > > $ more *.cc *.h > :::::::::::::: > foo.cc > :::::::::::::: > #include "foo.h" > > int foo() > { > return 42; > } > :::::::::::::: > main.cc > :::::::::::::: > #include "foo.h" > > int main() > { > return foo(); > } > :::::::::::::: > foo.h > :::::::::::::: > int foo(); > > $ g ./main.cc -o prueba > /home/<myname>/tmp/ccEOfejM.o(.text 0x11): In function `main': > : undefined reference to `foo()' > collect2: ld returned 1 exit status > ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com