g++

Compiler turning a string& into a basic_string<>&

Hello I'm coming back to C++ after long years spent on other technologies and i'm stuck on some weird behavior when calling some methods taking std::string as parameters : An example of call : LocalNodeConfiguration *LocalNodeConfiguration::ReadFromFile(std::string & path) { // ... throw configuration_file_error(string("Configuration ...

Error trying to use rand from std library cstdlib with g++

I was trying to use the random function in Ubuntu compiling with g++ on a larger program and for some reason rand just gave weird compile errors. For testing purposes I made the simplest program I could and it still gives errors. Program: #include <iostream> using std::cout; using std::endl; #include <cstdlib> int main() { cout ...

std::basic_string full specialization (g++ conflict)

I am trying to define a full specialization of std::basic_string< char, char_traits<char>, allocator<char> > which is typedef'd (in g++) by the <string> header. The problem is, if I include <string> first, g++ sees the typedef as an instantiation of basic_string and gives me errors. If I do my specialization first then I have no issues...

Autoconf/Automake "configure.ac:2: option `−Wall' not recognized"

Hello I'm trying to start with autoconf / automake for a new project. To get started, I'm reading "Using GNU Autotools" and trying to build the Hello-World-Tutorial. The required files from page 96 (real Page=105 because it's a LaTeX-Presentation) configure.ac, Makefile.am and src/Makefile.am look exactly as stated in the document. Af...

'Scanner' does not name a type error in g++

Hi. I'm trying to compile code in g++ and I get the following errors: In file included from scanner.hpp:8, from scanner.cpp:5: parser.hpp:14: error: ‘Scanner’ does not name a type parser.hpp:15: error: ‘Token’ does not name a type Here's my g++ command: g++ parser.cpp scanner.cpp -Wall Here's parser.hpp: #ifndef PA...

g++ not linking header files properly

I am using cygwin libraries to run C and C++ programs on Windows. gcc runs fine, but with g++, I get a long list of errors. I think these erros are because of linking problems with C libraries. Can you suggest what I need to do to fix this? beginning error lines: In file included from testgpp.cpp:1: /cygdrive/c/cygwin/bin/../lib/gc...

How to keep g++ from taking header file from /usr/include?

I am building using zlib.h which I have a local copy to v1.2.5, but in /usr/include/zlib.h there is v1.2.1.2. If I omit adding -I/my/path/to/zlib to my make I get error from using old version which doesn't have Z_FIXED: g++ -g -Werror -Wredundant-decls -D_FILE_OFFSET_BITS=64 -c -o ARCH.linux_26_i86/debug/sysParam.o sysParam.cpp sysPara...

Opt-out of copy constructor

This might be a silly question, but... I've been writing a number of classes that utilize non-copyable members. These classes are never initialized via the copy constructor in my source. When I try to compile without supplying my own copy-constructor, g++ throws out many errors about how it can't build a default copy constructor, due ...

What does '#if _LFS64_LARGEFILE-0' mean to CPP?

What does '#if _LFS64_LARGEFILE-0' mean to the C Preprocessor for g++? Is that a minus zero or is that part of the symbol? If it is minus zero, how does that affect whether the #if is triggered? ...

g++: how to specify preference of library path?

I'm compiling a c++ program using g++ and ld. I have a .so library I want to be used during linking. However, a library of the same name exists in /usr/local/lib, and ld is choosing that library over the one I'm directly specifying. How can I fix this? For the examples below, my library file is /my/dir/libfoo.so.0. Things I've tried tha...

write() in sys/uio.h returns -1

I'm using Ubuntu Server 9.10 AMD Phenom 2 cpu g++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1 trying to run the application pftp-shit v 1.11, which runs successfully until the remote file list is going to be saved (into .pftp//pftpfxp--). The following code in tcp.cc is executed successfully: int outfile_fd = open(name, O_CREAT | O_TRUNC | O_RDWR |...

C++: Switching from MSVC to G++: Global Variables

I recently switched to Linux and wanted to compile my Visual Studio 2010 C++ source code, which uses only the STL, on G++. My Linux machine currently isn't available but I can try to tell you what is going on, first: As I try to compile my project, all global variables I use in main and which perfectly work on MSVC result in myGlobalV...

kill unsigned / signed comparison error

In general, I want warnings of unsigned vs signed. However, in this particular case, I want it suppressed; std::vector<Blah> blahs; for(int i = 0; i < blahs.size(); ++i) { ... I want to kill this comparison. Thanks! (using g++) ...

boost asio ssl stream socket compilation issue

Using boost 1.4.2 asio in a c++ app and getting linux compiler warnings i don't grok. still here? The app i'm working on needs a "socket" that might be an ssl socket or a regular tcp socket so we hide specifics behind a template "socket" class that takes either an ssl socket class or tcp socket class as template parameter - below is the...

Differences between gcc3 and gcc4 regarding uninitialized variables

We have a body of C++ code which is being ported from a RHEL4-based distro to RHEL-5-based. It used to compile with g++ 3.4.3, and now compiles with g++ 4.1.2. It turns out that there are local POD variables that are being used uninitialized, which is causing failures under the new environment -- not surprising, since C++ rules say that ...

Creating C++ objects

I noticed that there are two ways to create C++ objects: BTree *btree = new BTree; and BTree btree; From what I can tell, the only difference is in how class objects are accessed (. vs. -> operator), and when the first way is used, private integers get initialized to 0. Which way is better, and what's the difference? How do you k...

MinGW and "declaration does not declare anything"

I'm working on converting a Linux project of mine to compile on Windows using MinGW. It compiles and runs just fine on Linux, but when I attempt to compile it with MinGW it bombs out with the following error message: camera.h:11: error: declaration does not declare anything camera.h:12: error: declaration does not declare anything I'm...

Which is G++ 4.4.1 default allocator?

I was wondering which is the default memory allocator in G++ 4.4.1, on Ubuntu 9.1. I am interested in comparing different C++ allocators in a multithreaded environment. And where can I get more information about the default memory allocator? EDIT: I refer to new and delete operators. The only linking is to rt and pthread Regards ...

Compiling in g++ for gprof

I do not understand the documentation for gprof regarding how to compile your program for profiling with gprof. In g++, is it required to compile with the -g option (debugging information) in a addition to the -pg option or not. In each case I get different results, and I would like to see where the bottlenecks in my application are in r...

Compile for CentOS on Ubuntu

Can I install an older version of gcc/g++ (4.1.3) on the latest Ubuntu (which comes with 4.4.3) and use it to compile a .so which should run on CentOS? The binary compiled with the Ubuntu version of gcc fails to load on CentOS because of missing imports (GLIB_2_11, ...). I need C++ (including exceptions), so I can't just statically link ...