Why does the C++ linker require the library files during a build, even though...
I have a C++ executable and I'm dynamically linking against several libraries (Boost, Xerces-c and custom libs).I understand why I would require the .lib/.a files if I choose to statically link against...
View ArticleMix multiple objects files with gcc which have no main function
i try to mix files . For example , if i have file1.o and have file2.o , all of them don't have main function , then le1_file2.o is the result of those files . So i have used 2 things :Using of linker...
View ArticleUse compiled gcc to compile my code, but cannot found certain header files
I compiled gcc9 from source, and used default install prefix: ./configure --disable-mutilib make -j16 make install After that, I found the gcc version is updated: which gcc /usr/local/bin/gcc gcc...
View ArticleUndefined reference to main - collect2: ld returned 1 exit status
I'm trying to compile a program (called es3), but, when I write from terminal:gcc es3.c -o es3it appears this message:/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/crt1.o: In function `_start':...
View ArticleError: initializer element is not computable at load time
I have a function that takes a struct, and I'm trying to store its variables in array:int detect_prm(Param prm) { int prm_arr[] = {prm.field1, prm.field2, prm.field3}; return 0; } But with gcc -Wall...
View ArticleWhy would a C compiler not precompute static values?
I have some code that I was debugging and I noticed that the compiler (MIPS gcc-4.7.2) is not pre-calculating certain values that I would expect to just a static value in memory. Here's the crux of the...
View ArticlemacOS Clang C++17 filesystem header not found
I need to write a program using the (experimental) C++17 filesystem library but clang on my Mac (macOS 10.12.03) doesn't seem to have the filesystem header included.Since I'm required to use the C++17,...
View Articlehow to compile openssl with fvisibility=hidden flag for iOS
I need to compile the openssl code with -fvisibility=hidden to hide the large number of symbols and then use in Xcode. Using below GitHub link.. I'm able get the libssl.a and libcrypto.a but there is...
View ArticleWhich versions of GCC and clang support...
I'm using GCC 7.4.0 and clang 6.0.0 and they both seem to have an implementation of filesystem in <experimental/filesystem>.since the project that i'm working on requires std::filesystem, i want...
View ArticleHow does grep uses beginning and ending of lines
I want to read about one option in man page of gcc. So i did man gcc | grep -- '^-c'. The error was troff - cant break line, because I have terminal on the half on my screen. But I fixed that with...
View ArticleQt 5.1.1 compiler setup on Ubuntu
First of all, I should point out that I've never used linux before.I have a clean install of 64bit ubuntu, I downloaded Qt 5.1.1 for linux 64 bit from http://qt-project.org/downloads, ran the .run...
View Article"error: wrong helper.h inclusion" compilation error in Kernel module build
I am trying to add new C file newfile_test.c in a kernel module. The C file has a #include <linux/types.h> and no other include files present. Existing kernel module source code already has a...
View Articlegcc compiler optimization - influence on assembly
I am learning about gcc optimization. As far as I understand the compilers tries to improve/ reduce the code. That is noticeable when I execute different files with different optimization levels....
View Article++i and i++ in while loop in C
I am using a program to detect the boundary of each data type, which is like this:#include <stdio.h> #include <stdlib.h> int main() { /*first while loop using a++ dosesn't give us a right...
View Articlex86 spinlock using cmpxchg
I'm new to using gcc inline assembly, and was wondering if, on an x86 multi-core machine, a spinlock (without race conditions) could be implemented as (using AT&T syntax): spin_lock: mov 0 eax lock...
View ArticleHow to Link static or shared library to Kernel Module?
There is a function in aaa.c int myadd(int a, int b){ return a+b; } and aaa.c was built into a static library using gcc -c aaa.c -o aaa.o && ar -cr libaaa.a aaa.oand a shared library using gcc...
View Articleunknown type name '__uint64_t'
I have recovered old developments, (embedding proC) that do not compile anymore following a migration (oracle 11g to 12c).Note: The data has been anonymised.Old environment:Linux <NOMDELAMACHINE>...
View ArticleUsing defined(MACRO) inside the C if statement
I would like to write code in C something like this: if(defined(MACRO)) ... else ... but I could not find any way to do this in C, since the defined(MACRO) preprocessor operator works only inside...
View ArticleThe const conundrum in OpenSSL
In OpenSSL, some functions require the use of const but then down the road others require me to not use const for the same variable. An example is when I create a new BIGNUM I need to use const but...
View ArticleInlined ARM64 system call giving the wrong return value
This is my code.long doSystemCall(const char *path) { register long x0 asm("x0") = 0; register long x1 asm("x1") = (long) path; register long x2 asm("x2") = 0; register long x3 asm("x3") = 0; register...
View Article