allow using linker -wrap flag for defined symbols as well

I’ve read that the linker “-wrap” flag, only works for undefined symbols. This causes it not to work properly for function calls within the same file. Is there a way to make the “-wrap” work on known symbols? or alternatively cause the compiler to mark specific/all symbols as undefined (although they are in the same file)? Source: gcc

undefined reference to `_doFormatMessage’ using i586-mingw32msvc-gcc

I am using:Linux kali 3.18.0-kali3-586 #1 Debian 3.18.6-1~kali2 (2015-03-02) i686 GNU/Linux I have executed this below command: i586-mingw32msvc-gcc 1197.c -lws2_32 -o 1197.exe get output: 1197.c:112:43: warning: multi-character character constant 1197.c: In function ‘ExplorerExecution’: 1197.c:112: warning: overflow in implicit constant conversion 1197.c:115:43: warning: multi-character character constant 1197.c:115: warning: overflow in implicit constant conversion 1197.c: In function ‘main’: 1197.c:173: warning: return type…
Read more

Unusual behavior of pow() in C during compilation

Program file name – armstrong3.c. #include <stdio.h> #include <math.h> int main(void) { int i, sum, num, rem,x; x=pow(2,5); printf(“%dn”, x); printf(“List of 3 digit armstrong numbers n”); for (i=100; i<=999; i++) { num=i; sum=0; while (num>0) { rem=num%10; sum=sum+pow(rem,3); num/=10; } if (i==sum) printf(“%dn”, i); } return 0; } This simple program finds 3 digit armstrong numbers. To calculate the…
Read more

Errors when cross compiling GMP

I have followed this How-to and g,h section of cross compiling tutorial for cross compiling GMP. This is the error message(last part) I get after running make. /usr/bin/ld: skipping incompatible /home/yogi/workbench/gcc-4.8.2/arm/lib/libmpfr.so when searching for -lmpfr /usr/bin/ld: skipping incompatible /home/yogi/workbench/gcc-4.8.2/arm/lib/libmpfr.a when searching for -lmpfr /usr/bin/ld: skipping incompatible /home/yogi/workbench/gcc-4.8.2/arm/lib/libmpfr.so when searching for -lmpfr /usr/bin/ld: skipping incompatible /home/yogi/workbench/gcc-4.8.2/arm/lib/libmpfr.a when searching for -lmpfr /usr/bin/ld:…
Read more

CMake save stripped debug information

It’s a usual practice to compile with debug symbols and then separate the binary using objcopy into the release executable and the file with debug information (then wrap that into separate packages or store on the symbol server). How to separate debug symbols properly in CMake? I’ve seen just some discussions and incomplete code samples. Platform is Linux and GCC….
Read more

Expected to see "initializer-string for array of chars is too long" warning

I expected to see “initializer-string for array of chars is too long” warning for both of the variables in the following program using gcc. Program: int main() { char str1[4]=”1234″; char str2[3]=”1234″; (void)str1; // Remove unused variable warning. (void)str2; // Remove unused variable warning. return 0; } However, I got a warning only for str2. Since char str1[4]=”1234″; is equivalent…
Read more

Cross-compile VLC 2.2.0 (2.2.2) for Windows on Ubuntu 14.04 LTS error

Trying to build VLC 2.2.0 for Windows x64 on Ubuntu 14.04.3 LTS using this instruction https://wiki.videolan.org/Win32Compile/ In fact it is such commands on clean system (vlc-2.2.0.tar.xz is downloaded to ~): sudo apt-get update sudo apt-get install lua5.2 libtool automake autoconf autopoint make gettext pkg-config qt4-dev-tools qt5-default wine-dev zip p7zip nsis bzip2 sudo apt-get install gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 mingw-w64-tools cd ~ tar…
Read more

Accessing static member variable using boost::shared_ptr

I’m trying to port a working C++ code from Windows/Visual C++ 2010 to Linux (Ubuntu 12.04) platform. The code is trying to access a static member variable using boost’s shared_ptr. When I port this code to Linux, I get “undefined reference to `Test::TYPE’”, even though it compiles and works fine on Windows. I’m using Ubuntu Linux 12.04, gcc version 4.6.4…
Read more

Errors when using GCC to compile C code provided in textbook

I’m a CS student about to start my second year. In preparation, I’m reading “An Introduction to C Programming for Java Programmers” by Mark Handley. In it I found this code, that I decided to try out for myself: #include <stdlib.h> main() { char *s1; char s2[80]; char *s3; s1 = “Hello”; s3 = malloc(80); printf(“Enter your first name:n”); fgets(s2,…
Read more

How do I change my makefile to avoid the undefined reference to a function in the maths library?

I’m trying to install PintOS on my local Ubuntu 14.04 machine. When I try to run make to compile the utilities. I get the following error. ankitkal@ankitkal-Inspiron-5521:~/os/pintos/src/utils$ ls backtrace Makefile pintos pintos.~1.55.~ pintos-mkdisk setitimer-helper.o squish-unix.c CVS Makefile~ pintos~ pintos-gdb setitimer-helper.c squish-pty.c ankitkal@ankitkal-Inspiron-5521:~/os/pintos/src/utils$ make gcc -lm setitimer-helper.o -o setitimer-helper setitimer-helper.o: In function `main’: setitimer-helper.c:(.text+0xbe): undefined reference to `floor’ collect2: error: ld…
Read more