g++

Strange Access Denied warning when running the simplest C++ program.

I am just starting to learn C++ (coming from a Java background) and I have come across something that I can't explain. I am working through the C++ Primer book and doing the exercises. Every time I get to a new exercise I create a new .cpp file and set it up with the main method (and any includes I think I will need) e.g.: #include <l...

Why doesn't g++ pay attention to __attribute__((pure)) for virtual functions?

According to the GCC documentation, __attribute__((pure)) tells the compiler that a function has no side-effects, and so it can be subject to common subexpression elimination. This attribute appears to work for non-virtual functions, but not for virtual functions. For example, consider the following code: extern void f( int ); class ...

Can I reconstruct C++ source code from debug binaries?

I have a C++ application compiled in debug (using MinGW and Qt) but I've lost some major changes because someone in my team forgot to commit his changes in the source control manager and overwrote the source code with other changes. When I run the program in debug (in Qt Creator) I can set a break point in main and then see the source c...

error when compiling c++ code with g++

i get error of this type: "in function ... multiple definition of ..." "... first defined here" "warning: size of symbol ... changed from to in " *the code is compiled with the flags: -ansi -Wall -pedantic-errors -Werror *STL is used is there any explanation for that? thank you in advance ...

Instantiating C++ template functions

Hi, I am facing a few problems with "undefined reference to " errors. I may not be able to post the code, but the declarations and the way I am calling the functions are as follows: Declarations: template <typename T> int pitch_detect(deque<T>& x, int offset, int len); template <typename T> int is_voiced( deque<T>& x, int offset, i...

Build a Cross Compiler

I'm trying to compile a c++ file and generate an asm or s file to be disassembled and run in PSIM. Whenever I try to do this I get errors. I am attempting to compile to mipsI-linux. I think I've determined that my cross compiler that was given to me is not working correctly for some reason. Can anyone give me some help building a new cro...

Makefile for compiling a number of .cpp and .h into a lib

I am running Windows 7 with gcc/g++ under Cygwin. What would be the Makefile format (and extension, I think it's .mk?) for compiling a set of .cpp (C++ source) and .h (header) files into a static library (.dll). Say I have a variable set of files: file1.cpp file1.h file2.cpp file2.h file3.cpp file3.h .... What would be the makefile...

kdevelop 3.5: configure: error: C++ compiler cannot create executables

Hello, I try to compile an application with kdevelop 3.5.4 on Ubuntu 10.04, but it fails with the following errors: checking whether make sets $(MAKE)... yes checking for g++... g++ checking whether the C++ compiler works... no configure: error: in `/home/nts/wktools4': configure: error: C++ compiler cannot create executables See `conf...

Error in my first assembly program (GCC Inline Assembly)

Hi, After a lot of internet research I implemented a small assembler routine in my C++ program to get the CPU's L1 cache size using cpuid. int CPUID_getL1CacheSize() { int l1CacheSize = -1; asm ( "mov $5, %%eax\n\t" // EAX=80000005h: L1 Cache and TLB Identifiers "cpuid\n\t" "mov %%eax, %0" // eax i...

Compiling mp4v2 on Mac OS X

Hi Anybody can help me with compiling mp4v2 on Mac OS X? I've tried configuring and compiling as per the instructions but I got a lot of errors originating from the C++ headers. The configure command was ./configure --enable-ub followed by plain make at the Terminal. From the looks of the error messages, it seems that a number of hea...

g++ template problem

Hello everybody. I'm porting my c++ windows code (msvc & intel) to Linux (g++). The code uses lots of templates (I like metaprogramming ;-). But I can't compile this code: template <class TA> struct A { template <class TAB> struct B; }; template <class TC> struct C {}; template <class TD> struct D { template <class TTD> clas...

Migrating to Xcode and now having lots of "is not member of std" and some other header problems

Hi! I am migrating to OS X and now trying to use Xcode. There is a project that was compiling and running normally on a g++ linux distro, now on mac it is returning a thousand of errors. I guess that the linux std files, somehow included others files needed and now they are not this connected in the std of Mac OS X. How can I know what ...

cannot find -lmysqlclient collect2: ld returned 1 exit status

Invoking: Cygwin C++ Linker g++ -nostartfiles -L"E:\cygwin\lib\mysql\lib" -lmysqlclient -lz -shared -o"final.so" ./src/one.o ./src/two.o ./src/three.o ./src/four.o ./src/five.o /usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lmysqlclient collect2: ld returned 1 exit status ...

Problem With Setting Compiler Flags

I'm trying to configure my cross compiler (mipseb-linux-g++) to generate binaries with the MIPSI ISA. There is a flag for this "-mips1". I have this flag in my make file and for some reason g++ is still generating MIPSII instructions (which I assume is default?). Am I doing anything wrong? Here's my process flow: write c++ program ...

How to call Matlab form C++ code?

I am trying to call Matlab functions form C++ code. With Matlab it comes an example of such code at /extern/examples/eng_mat/engdemo.cpp, however I found no way to build that source code. Here is the makefile I use: CFLAGS = -Wall -O3 INCLUDES = -I/opt/Matlab-2009a/extern/include LIBRARIES = -Wl,-R/opt/Matlab-2009a/bin/glnx86 -L/opt...

Using Autotools for a new shared library

What I want to do is to create a new shared library called libxxx that links against another shared library called libzzz, this shared library has an independent "pkg-config"-like tool, let's say it's called "zzz-config" which gives the cflags needed by the compilation phase when using the libzzz. What I want to do is: Create configure...

compiling a C++ program with gcc

Question: Not able to compile a C++ program with gcc compiler. **oyscs1 /ms/user/a/agrajagr/test/macros 51$ cat info.C** #include<iostream> using std::cout; using std::endl; int main() { #ifdef __cplusplus cout << "C++ compiler in use and version is " << __cplusplus << endl; #endif cout <<"Version is " << __STDC_VERSION__ << endl; cout ...

Template subclass pointer problem

In a moment of madness, I decided to write a quadtree C++ template class. I've run into some weird compiler error that I don't understand with regard to subclasses and pointers to templates. I've found some hacky work arounds, but I wondered if anyone could shed some light on why my code wouldn't compile... I'm on Linux, building with...

Is there any way I can make g++ only emit warnings pertaining to my files?

I like to compile my code with -Wall, and sometimes even -pedantic. It's partly a style thing, and partly the fact that it does occasionally emit very, very useful warnings (such as using = rather than ==). However, the writers of some of my headers are clearly not such sticklers. Compiling with either of the two warning levels yields ...

how to get compile warning

I'm quite surprised when I compile the following code without any warning using g++ 4.1.2 with -Wall -Wextra -Wconversion enabled. I want g++ to show me every warning to avoid potential harm. I have to stick to g++ 4.1.2. #include <stdint.h> #include <string> using namespace std; int main() { uint8_t u1=1; uint64_t u64=1000; ...