gcc

Why did this work with Visual C++, but not with gcc?

I've been working on a senior project for the last several months now, and a major sticking point in our team's development process has been dealing wtih rifts between Visual-C++ and gcc. (Yes, I know we all should have had the same development environment.) Things are about finished up at this point, but I ran into a moderate bug just t...

./configure with a specified version of g++

Hello, How to tell to a 'configure' file to compile with a specified version of g++ ? Thanks. ...

Linux cc compilation of library in directory within project?

My directory structure looks like the following: -xmllib -libxml++-1.0.a -main.cc ..and I issue the command: cc -lstdc++ -L./xmllib -llibxml++-1.0.a main.cc But then it tells me that it can't find the binary for the library...even though I issued the command from the root directory. /usr/bin/ld: cannot find -llibxml++-1.0.a ma...

gcc compilation without using system defined header locations

I am attempting to compile a c++ class using gcc. Due to the nature of the build, I need to invoke gcc from a non-standard location and include non-system defined headers, only to add a set from a different location. However, when I do this, I run into an issue where I cannot find some base symbols (suprise suprise). So i am basically ru...

Embedding binary blobs using gcc mingw

I am trying to embed binary blobs into an exe file. I am using mingw gcc. I make the object file like this: ld -r -b binary -o binary.o input.txt I then look objdump output to get the symbols: objdump -x binary.o And it gives symbols named: _binary_input_txt_start _binary_input_txt_end _binary_input_txt_size I then try and acce...

Weak-linking with static libraries

I have declared an external function with a GCC weak attribute in a .c file: extern int weakFunction( ) __attribute__ ((weak)); Compiled object file has weakFunction defined as a weak symbol. Output of nm: 1791: w weakFunction I am calling the weak defined function as follows: if (weakFunction != NULL) { weakFunction()...

C/GCC - Is it possible to sort arrays using preprocessor? [SOLVED]

I have a number of very long arrays. No run-time sort is possible. It is also time consuming to sort them manually. Moreover, new elements can be added in any order later, so I would like to sort them by value using C preprocessor or maybe there is any compilers flag (GCC)? For example: sometype S[] = { {somevals, "BOB", someotherva...

_USE_32BIT_TIME_T equivalent for gcc

on Visual studio I can force use of 32 bit time_t by declaring _USE_32BIT_TIME_T is there a similar equivalent for gcc? or is it always 32 bit or is it always 64 bit? ...

argument order in cygwin gcc 4.3 matters when linking with glib-2.0

I am trying to compile code that works on os x and linux using cygwin. However, I am finding that the argument order to gcc gives unanticipated results. For example, the following fails: gcc -std=gnu99 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lglib-2.0 -lintl -liconv -fgnu89-inline -fno-leading-underscore -o nb-learn.exe n...

Is there a way to strip all functions from an object file that I am not using?

I am trying to save space in my executable and I noticed that several functions are being added into my object files, even though I never call them (the code is from a library). Is there a way to tell gcc to remove these functions automatically or do I need to remove them manually? ...

Why gcc4 warn and how to avoid it

I have a function declared as: void event_add_card (EventAddr addr, EventType type, unsigned char card); and union typedef union EventData { float money; /**< money info */ unsigned char card; /**< new card */ } EventData; When i compile following code: EventData data = {}; event_add_card (0,0, d...

GCC/X86, Problems with relative jumps

I'm trying to do a relative jump in x86 assembly, however I can not get it to work. It seems that for some reason my jump keeps getting rewritten as an absolute jump or something. A simple example program for what I'm trying to do is this: .global main main: jmp 0x4 ret Since the jmp instruction is 4 bytes long and a relativ...

Should I use C++0x Features Now?

With the official release of VS 2010, is it safe for me to start using the partially-implemented C++0x feature set in my new code? The features that are of interest to me right now are both implemented by VC++ 2010 and recent versions of GCC. These are the only two that I have to support. In terms of the "safety" mentioned in the first...

write system call to file desciptor ZERO

int main ( ) { char C[] = "Hello World"; write(0,C,sizeof(C)); return 0; } In the above program, I am writing to File descriptor ZERO which I suppose by default is STDIN.. Then why I am I getting output at STDOUT? shadyabhi@shadyabhi-desktop:~$ ./a.out Hello Worldshadyabhi@shadyabhi-desktop:~$ ...

How do I link against Intel TBB on Mac OS X with GCC?

I can't for the life of me figure out how to compile and link against the Intel TBB library on my Mac. I've run the commercial installer and the tbbvars.sh script but I can't figure this out. I have a feeling it is something really obvious and it's just been a bit too long since I've done this kind of thing. tbb_test.cpp #include <tbb/...

Problem with GCC calling static templates functions in templated parent class.

I have some code that compiles and runs on MSVC++ but will not compile on GCC. I have made a test snippet that follows. My goal was to move the static method from BFSMask to BFSMaskSized. Can someone explain what is going on with the errors (esp. the weird 'operator<' error)? Thank you. In the case of both #defines are 0, then the c...

can a program written in C be faster than one written in OCaml and translated to C?

So I have some cool Image Processing algorithm. I have written it in OCaml. It performs well. I now I can compile it as C code with such command ocamlc -output-obj -o foo.c foo.ml (I have a situation where I am not alowed to use OCaml compiler to bild my programm for my arcetecture, I can use only specialy modified gcc. so I will compil...

how to link static library into dynamic library in gcc

Under gcc (g++), I have compiled a static .a (call it some_static_lib.a) library. I want to link (is that the right phrase?) this .a file into another dynamic library (call it libsomeDyn.so) that I'm building. Though the .so compiles, I don't see content of .a under .so using nm command: /usr/bin/g++ -fPIC -g -O2 -Wall -Werror -pipe ...

boost::dynamic_pointer_cast with const pointer not working ?

Hi, Let's say I have two classes, A and B, where B is a child class of A. I also have the following function: void foo(boost::shared_ptr<const A> a) { boost::shared_ptr<const B> b = boost::dynamic_pointer_cast<const B>(a); // Error ! } Compilation with gcc gives me the following errors: C:\Boost\include/boost/smart_ptr/shared_p...

GCC Linking time errors - No rule to make target

Hi Guys, I'm new to the world of Makefile writing. I have a C project which I want to build using GCC and I could write fairly a very good Makefile, which calls 3 other Makefiles, present in different directory structure of the project, recursively, who will then send the respective source files to the GCC compiler. The result of ...