How do I determine the fastest link order?

As an alternative, why not try compiling your libraries to shared libraries rather than static libraries? Where I work, one large projects link time was around 6 minutes, this was for only 5 libraries! My solution was (for a debug version), create .so files alphabetically (libA.so, libB.so etc) so each indivdual link wasn’t too long, … Read more

Can gcc use multiple cores when linking?

Try gold, which was developed by Ian Lance Taylor et al. from Google and released as part of GNU binutils package. From Wikipedia: The motivation for writing gold was to make a linker that is faster than the GNU linker, especially for large applications coded in C++ I must admit I haven’t tried it myself … Read more

Undefined reference to ‘vtable for xxx’

One or more of your .cpp files is not being linked in, or some non-inline functions in some class are not defined. In particular, takeaway::textualGame()‘s implementation can’t be found. Note that you’ve defined a textualGame() at toplevel, but this is distinct from a takeaway::textualGame() implementation – probably you just forgot the takeaway:: there. What the … Read more

Resolving circular dependencies by linking the same library twice?

The problem with g++ -o myApp -lfoo -lbar -lfoo is that there is no guarantee, that two passes over libfoo and one pass over libbar are enough. The approach with Wl,–start-group … -Wl,–end-group is better, because more robust. Consider the following scenario (all symbols are in different object-files): myApp needs symbol fooA defined in libfoo. … Read more

What’s the difference between gtest.lib and gtest_main.lib?

the only reasonable difference is that gtest_main.lib provides a default implementation of a test application entry point (i.e. main function): Citation from Getting started with Google C++ Testing Framework: “[…] maybe you think that writing all those main() functions is too much work? We agree with you completely and that’s why Google Test provides a … Read more

Is a statically linked executable faster than a dynamically linked executable?

Static linking produces a larger executable file than dynamic linking because it has to compile all of the library code directly into the executable. The benefit is a reduction in overhead from no longer having to call functions from a library, and anywhere from somewhat to noticeably faster load times. A dynamically linked executable will … Read more

library is linked but reference is undefined

when you are linking, the order of your libraries and source files makes a difference. for example for your case, g++ -I/usr/local/cuda/include -L/usr/lib/nvidia-current -lOpenCL opencl.cpp functions defined in the OpenCL library might not be loaded, since there nothing before them asking for a look-up. however if you use, g++ opencl.cpp -I/usr/local/cuda/include -L/usr/lib/nvidia-current -lOpenCL then any … Read more

Relation between object file and shared object file

Let’s say you have the following C source file, call it name.c #include <stdio.h> #include <stdlib.h> void print_name(const char * name) { printf(“My name is %s\n”, name); } When you compile it, with cc name.c you generate name.o. The .o contains the compiled code and data for all functions and variables defined in name.c, as … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)