g++

Linker warnings/errors after Snow Leopard Upgrade

Hi, I have 3rd party libraries for my mac applications which used to link nicely to my application with the previous version of Mac OS X. I have upgraded to Snow Leopard and now g++ linker complains: ld: warning: in /Users/paul/Projects/3rdPath/NHUI/Lib/mac32/libNHUI.a, file is not of required architecture The link also fails to loc...

How do I map a segfault instruction pointer address from /var/log/messages to an address/function in my .map file?

(My environment is 64-bit Ubuntu, my application is C++ compiled and linked with g++.) When an application does something like divide by zero or run a asm("int $3") left in the code, one of the following gets logged via syslog to /var/log/kern.log and /var/log/messages: Sep 10 18:06:47 VM kernel: [117194.123452] a.out[20288] trap divid...

Partial specialization of a class template in derived class affects base class

I have a metafunction: struct METAFUNCION { template<class T> struct apply { typedef T type; }; }; Then I define a helper: template<class T1, class T2> struct HELPER { }; And then I have second metafunction which derives from the METAFUNCTION above and defines partial specialization of apply struct: struct METAFUNCION2...

Change compilation flags in Qt under Mac OS X?

I installed Qt for Mac, and am compiling my Qt project after adding in the .Pro file CONFIG(release, debug|release):QMAKE_CXXFLAGS += -O3 -fomit-frame-pointer to optimize for speed. However, I always see that the command where g++ is ran, includes -Os, which optimizes for size. I would like to remove it. I tried several approaches, ...

Why "Follow symbol under cursor" does not work in QT Creator for Mac OS X?

Hi I'm using QT Creator under Mac osx, but "Follow symbol under cursor" option, to allow me to jump for class and methods' definitions, does not really work... it only works for local symbols. neither does "Switch between method declaration/definition" any ideas? thanks much for any thought Lior ...

Disable all gcc warnings

I'm working on a project that will read compiler error messages of a particular variety and do useful things with them. The sample codebase I'm testing this on (a random open-source application), and hence rebuilding frequently, contains a few bits that generate warnings, which are of no interest to me. How do I disable all warnings fro...

g++ problem: exception not caught

The situation is that I have a dynamic library written in C++ that is wrapped for Python by another dynamic library, also written in C++ (generated by SIP to be specific). The first dynamic library defines a function do_raise, which throws an exception RaiserError, a subclass of std::exception. The second dynamic library, in wrapping do_...

On what conditions will a C++ program continue if the main thread is done?

I am debugging an issue, where there is a thread which continues to run after the main thread has exited. It is stuck in a loop where it is waiting for another thread to change a variable. I am trying to understand in what situations a process will continue running after the main thread has exited. I am using 32 bit linux g++ pthreads...

Question about storing array in a std::vector in C++

I am unclear about the following. First, this code compiles fine: #include <vector> typedef struct{ int x1,x2,x3,x4; } ints; typedef std::vector<ints> vec; int main(){ vec v; ints a = {0,1,2,3}; v.push_back(a); } The following code is near identical: #include <vector> typedef std::vector<int[4]> vec; int main(){ vec v; i...

how can I link against libpython.a such that later the runtime linker can find all the simbols in libpython.a?

In a sequel question to this question, my corporate environment lacks the libpython2.6.so shared object but has the libpython2.6.a file. Is there a way that I can compile in libpython2.6.a while retaining the symbols in libpython2.6.a such that dynamic libraries can find these symbols at runtime? My current compile with the static libr...

Having trouble building c++ project in Eclipse CDT in OS X for a silly reason

I'm trying to build a very simple c++ program in eclipse and I'm getting a very silly error: **** Internal Builder is used for build **** g++ -O0 -g3 -Wall -c -fmessage-length=0 -oMyFirst.o ../MyFirst.cpp g++ -oLinkedLists MyFirst.o ld: unknown option: -oLinkedLists collect2: ld returned 1 exit status Build error occurre...

Undefined reference to 'yylex()'

I'm trying to use flex and bison to create a simple scripting language. Right now, I'm just trying to get a calculator working. I can't get it to compile, though. When I run this makefile: OBJECTS = hug.tab.o hug.yy.o PROGRAM = hug.exe CPP = g++ LEX = flex YACC = bison .PHONY: all clean all: $(OBJECTS) $(CPP) $^ -o $(PROGRAM) clean...

Benchmarks of code generated by different g++ versions

I work on a runtime system for an application domain that is very performance sensitive. We go to a lot of effort to maintain backward compatibility with older compiler versions, including avoiding more recently-implemented language constructs, and synthesizing them for the older versions. However, I'm concerned that this effort does a ...

C++ override/overload problem

I'm facing a problem in C++ : #include <iostream> class A { protected: void some_func(const unsigned int& param1) { std::cout << "A::some_func(" << param1 << ")" << std::endl; } public: virtual ~A() {} virtual void some_func(const unsigned int& param1, const char*) { some_func(param1); } }; class B : public A { p...

How to solve ambiguous function overload due to default constructor in parameter

Let's say I have this class: class Foo { public: void member(std::string s); void member(int64_t &n); }; Now I want to do some thing like int64_t value = 5; Foo f; f.member(value); The problem is that the compiler (at least GCC) gets confused & believes I'm trying to call member with a string using the char* constructor: in...

Undefined symbol _main when trying to build shared library g++ / mac

I am trying to build libdecodeqr on a mac. My c++ building and linking history is all on windows, so it's an exciting journey of discovery. I have finally got to the point where I want to create the linked library. The command I am running is: g++ -shared -o libdecodeqr.so.0.9.3 bitstream.o codedata.o container.o ecidecoder.o formati...

'variable name' cannot appear in a constant expression c++

Anyone have any clue what this error might actually mean? I'm tripping on a bit of code that can't seem to get around it. I've tried it with just h*2 instead of hprime, and just w*2 instead of wprime. Every time I get the same compiler (g++ compiler) error of : grid.cpp: In constructor ‘Grid::Grid(int, int)’: grid.cpp:34: error: ‘hpri...

Visualizing gcc error messages

Hi all do you guys know of any programs which can be used to visualize error messages from gcc. I am imagining something which will allow interactively to collapse all those long template typenames, color code different parts of the error message and what not. ...

What are these GCC/G++ parameters?

Hello, everyone. I've been using the UVa Online Judge to solve some programming challenges, and, when submitting my solutions, I'm told the judge will compile my code using the following parameters to GCC/G++ that I don't know: -lm -lcrypt -pipe -DONLINE_JUDGE. What do they do? Thank you very much in advance! ...

gcc error-messages crippled (code-page or encoding-problem)

Hello, I use debian and g++. When compiling i get error-messages like these: In static member function ΓÇÿstatic void* v4::_mb_blocs::operator new(size_t)ΓÇÖ: Can i tell gcc to do its output in utf-8 or something ? ...