Linker error: “linker input file unused because linking not done”, undefined reference to a function in that file

I think you are confused about how the compiler puts things together. When you use -c flag, i.e. no linking is done, the input is C++ code, and the output is object code. The .o files thus don’t mix with -c, and compiler warns you about that. Symbols from object file are not moved to other object files like that. All object … Read more

Multiple definition of … linker error

Don’t define variables in headers. Put declarations in header and definitions in one of the .c files. In config.h In some .c file: If you put a definition of a global variable in a header file, then this definition will go to every .c file that includes this header, and you will get multiple definition … Read more

Using GNU Scientific Library (GSL) under Windows x64 with MinGW

When you build projects for MinGW, under MSYS, you should always specify a –prefix argument to ./configure; (the /usr/local default specifies an MSYS specific path, which is entirely unsuitable for MinGW application development). In your case, you should have configured GSL thus: or, better still, segregate the build files from the sources, (e.g. as a subdirectory of the GSL top source directory): … Read more

What is an undefined reference/unresolved external symbol error and how do I fix it?

Compiling a C++ program takes place in several steps, as specified by 2.2 (credits to Keith Thompson for the reference): The precedence among the syntax rules of translation is specified by the following phases [see footnote]. Physical source file characters are mapped, in an implementation-defined manner, to the basic source character set (introducing new-line characters for end-of-line indicators) … Read more

What is an undefined reference/unresolved external symbol error and how do I fix it?

Compiling a C++ program takes place in several steps, as specified by 2.2 (credits to Keith Thompson for the reference): The precedence among the syntax rules of translation is specified by the following phases [see footnote]. Physical source file characters are mapped, in an implementation-defined manner, to the basic source character set (introducing new-line characters for end-of-line indicators) … Read more