g++

solaris elfedit: Is there something similar for linux ? (a shared library editor)?

Linux: It there a way to edit a compiled shared library ? specifically I am searching on how to add the DT_SYMBOLIC flag on an already compiled binary shared library? Here is why I am asking this: our application is composed of our own libraries (static libXXX.a) some 3rd party libs (binary-only shared libraries libYYY.so) Every...

g++ compilation error of another thing that works in msvs.

Heya, folks. I'm porting some code from a project largely developed in MSVS to use g++. I've found a lot of little differences, mostly things that MSVS allows but g++ does not. Usually it's something involving c++ standards, things that MSVS lets slide, but I'm having trouble seeing just what's wrong with one particular section. g++ is ...

C++ Seg fault on reference to stored base class pointer

Hi all. I'm getting some nasty segmentation faults through the g++ compiler on the following code. Any ideas on why this would happen and how to fix it would be great. #include <iostream> using namespace std; class Base { public: Base() {} virtual ~Base() {}; virtual int getNum(int) = 0; }; class Derived: public Base { public: ...

Vista-Eclipse (Galileo) CDT w/ MinGW and MinGW's GDB fails to output cerr output.

I installed Eclipse and I can get g++ to compile the code correctly; however, when I start the debugger none of the "cerr >>" outputs are ever displayed in the Eclipse console. I tried to run GDB manually and it, too, does not display the cerr output. Is anyone else experiencing this?? I am running the GDB 5.3-something that is available...

Convert a Static Library to a Shared Library (create libsome.so from libsome.a): where's my symbols?

the title of this question is an exact dupe, but the answers in that question don't help me. I have a bunch of object files packed in a static library: % g++ -std=c++98 -fpic -g -O1 -c -o foo.o foo.cpp % g++ -std=c++98 -fpic -g -O1 -c -o bar.o bar.cpp % ar -rc libsome.a foo.o bar.o I'd like to generate libsome.so from libsome.a inste...

Is the following valid C++ code?

If it is, what is it supposed to do? typedef struct Foo_struct{ Dog d; Cat* c; struct Foo_struct(Dog dog, Cat* cat){ this->d = dog; this->c = cat;} } Foo; (back story: porting a program written in Visual C++ (on Windows) to g++ (on MacOSX); no idea what this code is suppoesd to do). Thanks! ...

Link error in C++ by g++

Please take a look at the program below. Why am I getting an error? #include <stdlib.h> #include <string> #include <string.h> #include <iostream> using namespace std; class serverData { public: static int serverTemp; static int server; }; int main(int argc, char** argv) { string s = "sajad bahmani"; serverData::serve...

Problem using yaml-cpp on OS X

So I'm having trouble compiling my application which is using yaml-cpp I'm including "yaml.h" in my source files (just like the examples in the yaml-cpp wiki) but when I try compiling the application I get the following error: g++ -c -o entityresourcemanager.o entityresourcemanager.cpp entityresourcemanager.cpp:2:18: error: yaml.h: ...

How can I link an .o file using g++

Hi, I am trying to use g++ to compile a .cc file, and I need it to link a .o file. So I tried: $g++ -o client -I../ipc -L../messages.o client.cc /usr/bin/ld: error: ../messages.o: can not read directory: Not a directory And I have tried: $g++ -o client -I../ipc -l../messages.o client.cc /usr/bin/ld: error: cannot find -l../messages...

Can I printf g++'s architechture

I'd like to do something similar to this in g++: printf("Architecture: %s", M_ARCH); but I don't know how or if it's even possible? ...

Creating lib with g++ 4.0.1

I'm trying to create a lib with g++ 4.0.1, but it looks for _main (which deliberately isn't in the code). Must I put a _main in there or can I circumvent with some nifty switch? My current command line looks like: g++ -shared -o mylib.so myobj1.o myobj2.o ... On a sidenote I'm using g++ powerpc-apple-darwin9, but I'm guessing/hoping t...

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. ...

Detecting / avoiding g++ symbol collisions

Is there a way to detect and avoid if two shared libraries both expose the same global scope symbols? We recently ran into a situation where we had libA.so that exported the SuperCoolMethod() and libB.so that also exposed the SuperCoolMethod() which would clobber the previous copy of said method. This is on Linux using g++ 4.0 and late...

C++ Confused about Threads

Basicly this is what I have: Server:: Server (int port) { cout << "Initializing server.\n"; (...) pthread_t newthread; pthread_create(&newthread, NULL, &Server::_startListening, NULL); cout << "Exit\n"; pthread_exit(NULL); // <-- Question } void* Server::_startListening (void* param) { cout << "Start l...

File descriptor leak in nftw(FTW_CHDIR) ?

I am using the POSIX call nftw() for traversing a directory structure. The directory structure is flat - only 4 files and no subdirectories. However when I call nftw() a lot of times on this flat directory then I get an error message after a while: "too many open file handles". It turned out that this happens when the flag FTW_CHDIR ...

Working program gets an Illegal instruction fault on 'clean machine' ?

I have a program that works correctly on my development machine but produces an Illegal instruction fault when tested on a 'clean machine' where only the necessary files have been copied. The program consists of my shared library, built from C++ sources and a C wrapper sample program that demonstrates the libraries usage. On the develop...

Visual C++ setting to insert a newline at end of file

While compiling C++ code that is cross platform, g++ throws a compiler error if a .cpp or .h file does not have a newline at its end. Is there a visual studio setting that would do this automatically? ...

CMake not using appropriate output command line argument for compiler.

Hello, I'm working with CMake, and my program compiles fine with g++. However, I also wish to compiled it with bcc32 and cl. I am running into an issue -- I'm telling cmake to use those compilers by doing a command line somewhat like "cmake -DCMAKE_CXX_COMPILER=cl" or whatnot, and it picks up the compiler correctly (ie, in that case, t...

Why am I getting "undefined reference to `glibtop_init'" during linking?

I'm building a very small C/C++ project using eclipse and i'm getting the following during build: make all Building file: ../Metric.cpp Invoking: GCC C++ Compiler g++ -I/usr/include/glib-2.0 -I/usr/include/libgtop-2.0 -I/usr/lib/glib-2.0/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"Metric.d" -MT"Metric.d" -o"Metric.o" "../M...

Unexplained out_of_range in string::substr

I have been getting a really annoying error about an std::out_of_range when calling substr. The exact error is terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::substr I'm absolutely sure that tmp_request has a length greater then 1. No matter what I pass to substr1, 2, or bodyposit alwa...