GNU gcc/ld – wrapping a call to symbol with caller and callee defined in the same object file

You have to weaken and globalize the symbol using objcopy. -W symbolname –weaken-symbol=symbolname Make symbol symbolname weak. This option may be given more than once. –globalize-symbol=symbolname Give symbol symbolname global scoping so that it is visible outside of the file in which it is defined. This option may be given more than once. This worked … Read more

Very strange linker behavior

The explanation to what’s happening is very simple: Your libgplot.a depends on libm.so, yet the order of -lm and -lgplot on the link line is wrong. The order of libraries on the link line does matter. In general, system libraries (-lpthread, -lm, -lrt, -ldl) should follow everything else on the link line. When you remove … Read more

Obtaining current GCC architecture

gcc -dumpmachine gives you the target triplet, e.g. x86_64-unknown-linux-gnu If gcc -v shows GCC was configured with a –with-arch option (or –with-arch-32 and/or –with-arch-64) then that’s what will be the default. Without a –with-arch option (and if there isn’t a custom specs file in use) then the arch used will be the default for the … Read more

make: *** [ ] Error 1 error [duplicate]

From GNU Make error appendix, as you see this is not a Make error but an error coming from gcc. ‘[foo] Error NN’ ‘[foo] signal description’ These errors are not really make errors at all. They mean that a program that make invoked as part of a recipe returned a non-0 error code (‘Error NN’), … Read more

Unable to specify the compiler with CMake

Never try to set the compiler in the CMakeLists.txt file. See the CMake FAQ about how to use a different compiler: https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-do-i-use-a-different-compiler (Note that you are attempting method #3 and the FAQ says “(avoid)”…) We recommend avoiding the “in the CMakeLists” technique because there are problems with it when a different compiler was used for … Read more

how to link static library into dynamic library in gcc

Static libraries have special rules when it comes to linking. An object from the static library will only be added to the binary if the object provides an unresolved symbol. On Linux, you can change that behavior with the –whole-archive linker option: g++ -Wl,–whole-archive some_static_lib.a -Wl,–no-whole-archive

Can anyone explain the gcc cross-compiler naming convention?

The naming comes down to this: arch-vendor-(os-)abi So for example: x86_64-w64-mingw32 = x86_64 architecture (=AMD64), w64 (=mingw-w64 as “vendor”), mingw32 (=win32 API as seen by GCC) i686-pc-msys = 32-bit (pc=generic name) msys binary i686-unknown-linux-gnu = 32-bit GNU/linux And your example specifically: arm-none-linux-gnueabi = ARM architecture, no vendor, linux OS, and the gnueabi ABI. The arm-eabi … Read more

How to determine maximum stack usage in embedded system with gcc?

GCC docs : -fstack-usage Makes the compiler output stack usage information for the program, on a per-function basis. The filename for the dump is made by appending .su to the auxname. auxname is generated from the name of the output file, if explicitly specified and it is not an executable, otherwise it is the basename … Read more

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