Force the unused function to export to the shared library

printme() and getme() defined in top.cpp and top.h I used printme() function in test.cpp (test cpp file) in main function g++34 -c top.cpp -fPIC ar rcs libtop.a top.o g++34 -c test.cpp -fPIC g++34 -shared -o ltop.so -ltop -L. -fPIC getme is not getti

Why is sinf () so slow when compiling my code in Linux / ARMv7?

The same C code with the math sin() function runs much slower when I compile my program on ARMv7 compared to what I get on Windows. I'm compiling with -O2 -Wall -Wextra -mfpu=neon -mtune=cortex-a9 -march=armv7 -std=c++11 and my gcc is gcc (Ubuntu/Lin

how can I use the 64-bit online assembly in c?

int main(void) { unsigned long long a = 0x0ab0000000234432; unsigned long long b = 0x0000000000000001; unsigned long long c = 0x0000000032123001; unsigned long long r1; __asm__ __volatile__( "mov %1, %%eax \n\t" "xor %2, %%eax \n\t" &q

Link error with OpenSSL

This question already has an answer here: Can't link OpenSSL code 2 answers I have installed OpenSSL . I just want to run a program using OpenSSL. Here is my program, taken from here . #include <stdio.h> #include <stdlib.h> #include <string

Quad GCC 32 and 64 bits

I'm using GCC compiler on Linux. I want to use 64 bit compiler and build some of my files with -m32 option (32 bit compatibility). I found strange (for me) behavior of compiler. My code is simple: int main () { int test =(((0) & 0x00000000) << (

Apply explicit #include (direct) statements with GCC

I am wondering if it is possible to enforce direct #include requirements with GCC. Let say I have these files: abc.h: typedef struct { int useful; } str; file1.h: #include <abc.h> #ifndef GUARD #define GUARD #include <deh.h> typedef struct { i

Replacing library functions C, original call

I am a bit puzzled on how and why this code works as it does. I have not actually encountered this in any project I've worked on, and I have not even thought of doing it myself. override_getline.c: #include <stdio.h> #define OVERRIDE_GETLINE #ifdef

g ++: error: libgomp.spec: no such file or directory

I use g++ (GCC) 4.7.2. on Windows 7, 64-bit version. downloaded from http://nuwen.net/mingw.html I tried to use the "-fopenmp" flag and got the error: g++: error: libgomp.spec: No such file or directory I can't find the file anywhere on my syste

GCC transparent union

So I have a union defined like: typedef union { uint8_t *b1; uint16_t *b2; uint32_t *b3; uint64_t *b4; } buffer_u __attribute__((__transparent_union__)); And a functions defined like: int write_byte_to_buffer(buffer_u buf, uint16_t length, uint8_t va

g ++ compiles existing source files into another directory

I am trying to setup a build process using makefiles, for a C++ plugin that I am working on. I am curious to know if there is any way to make g++ compile source files found in another directory. My motivation for doing this is to avoid having to spec

Configure GCC for soft-fp with exceptions on ARM?

According to this page on the GCC Wiki: http://gcc.gnu.org/wiki/Software_floating_point the "soft-fp" soft float implementation gcc provides has optional support for exceptions and rounding modes. Is there any way to configure GCC (libgcc) when

namespace issues in C ++ 11?

Can somebody please explain the following: $ cat test.cpp #include <string> std::string div; $ g++ -c test.cpp $ g++ -std=c++11 -c test.cpp test.cpp:2:13: error: 'std::string div' redeclared as different kind of symbol In file included from /usr/inc

several atexit managers in different threads

I have a doubt regarding the use of atexit in a multithreaded application. Suppose I have the following scenario Thread A calls atexit(handler_a) Thread B calls atexit(handler_b) main() calls atexit(handler_main) Thread C calls atexit(handler_c) ....

Why is __PRETTY_FUNCTION__ called __PRETTY_FUNCTION__?

I see __PRETTY_FUNCTION__ used a lot in answers to questions on this site, and I understand the usefulness of this function, but why exactly is it called __PRETTY_FUNCTION__? It's not an ugly function, but it's not exactly pretty either.I think it is

Calling C code from a boot loader

I'm trying to write a bootloader. I would like to compile some C code so the bootloader can load it into memory and jump there. I have two questions: Is the calling convention the same as on x86? Namely, arguments on stack, left to right. How do I pr

easy_install lxml on mac does not work

After running: sudo easy_install lxml I get the following error: src/lxml/lxml.etree.c:165527: fatal error: error writing to -: Broken pipe compilation terminated. This looks like a c-compiler problem. gcc --version yields 4.2.1. I don't really know

What does D_XOPEN_SOURCE do?

I recently encountered some code that gcc would not compile without this arg. I checked the gcc man page, but did not find this specific option. I did find XOPEN_SOURCE, but there was little explanation of what it does. Can someone please elaborate?

Include header files using the command line option?

Is it possible to specify extra header files to include from the command line (using GCC 4 / C++)? Or is there any other way files can be included except with #include? Background: I'm trying to compile a large code base on my own PC. The code is usu

How does the gcc -fstack-check option work exactly?

My program crashed when I added the option -fstack-check and -fstack-protector. __stack_chk_fail is called in the back trace. So how could I know where the problem is ? What does -fstack-check really check ? The information about gcc seems too huge t

How to handle linker errors in the C ++ / GNU toolchain?

Given a C++/GNU toolchain, what's a good method or tool or strategy to puzzle out linker errors?With gcc toolchain, I use: nm: to find the symbols in object files ld: to find how a library links c++filt: to find the C++ name of a symbol from its mang

iostream.h, fstream.h can not be found

I have a 32 bit machine and I am running Ubuntu 9.10 on it. I have the latest gcc compiler. The problem that I am facing is that I have a library developed in 2002. The code is correct for sure but when I try to built it, it gives me errors like iost

The GCC dump preprocessor defines

Is there a way for gcc/g++ to dump its preprocessor defines from the command line? I mean things like __GNUC__, __STDC__, and so on.Yes, use -E -dM options instead of -c. Example (outputs them to stdout): gcc -dM -E - < /dev/null From the gcc manual:

How do I know if an integer C variable is signed?

As an exercise, I'd like to write a macro which tells me if an integer variable is signed. This is what I have so far and I get the results I expect if I try this on a char variable with gcc -fsigned-char or -funsigned-char. #define ISVARSIGNED(V) (V