g++

problem w/ linking static function g++

Hi- I am trying to build a small program and I have my own library libfoo. I have a camera class that is calling a static function from my Vector3 class (i.e. crossProduct). My camera class and Vector3 class compile ok and are built into libfoo. However when I am linking like so: g++ -g -O2 -o test1 main.o -lfoo I get this: libfo...

C++ Constructor and Destructor

I'm getting some errors when compiling my program. They relate to the constructor and destructor of my class Instruction. Errors are: /tmp/ccSWO7VW.o: In function `Instruction::Instruction(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int)': ale.c:(.text+0x241): undefined reference to `vtable for Instruction' ...

<list> retreving items problem with iterator

I have a list of type Instruction*. Instruction is a class that I made. This class has a function called execute(). I create a list of Instruction* list<Instruction*> instList; I create an Instruction* Instruction* instPtr; instPtr = new Instruction("test",10); If I call instPtr.execute(); the function will be executed correct...

[ linux, g++, linking]: library is in ldconf cache and Links Manually, but not by default

Hi all, This appears similar to an earlier post: http://stackoverflow.com/questions/335928/linux-gcc-linking-ld-cannot-find-a-library-that-exists But to the best of my knowledge, it's not exactly the same situation. The following command works: $g++ -I../../include/ -lboost_program_options-mt rips-zigzag.cpp However this doesn't: $...

[C++] Validity of int * array = new int [size]();

int * array = new int [size](); The operator () allow to set all values of array to 0 (all bits to 0). it's called value-initialization. Since which version of g++ is it valid ? What about other compilers ? Where can i find it in standard ? Thank you for your future anwsers. ...

G++ Compilers for MonoDevelop

How do you setup a G++ compiler for MonoDevelop? On both OS X and Windows Vista the default install complains about "Compiler Not Found: g++". Is MonoDevelop not a good cross platform IDE for C++ development (since it is a C#/Java IDE). Thanks SO! ...

friend function declared inside befriended class, GCC does not compile

Hello, I've got following code: File: Foo.h class Foo { friend void Bar(); }; File: Foo.cpp void Bar() {}; File Test.cpp #include "Foo.h" int main(void) { Bar(); return 0; } VS2008 compiles this without any error or warning. G++ 4.3.4 reports: test.cpp: In function ‘int main()’: test.cpp:8: error: ‘Bar’ was not d...

g++ error: ‘stricmp’ was not declared in this scope (but OK for 'strcmp')

I am trying to compile the following very very simple piece of source code: #include <cstring> // #include <string.h> // using namespace std; class Helper { public: int cStringsAreEqual(const char *s1, const char *s2) { return stricmp(s1, s2); } }; ... but I am getting the following error message: g++ error: ‘stri...

Is there a g++ equivalent to Visual Studio's __declspec(novtable)?

Is there a g++ equivalent to Visual Studio's __declspec(novtable) argument? Basically, in a pure virtual base class the __declspec(novtable) argument can be used to suppress the creation of a vtable for the base class as well as vtable initialization/deinitialization code in the contstructor/destructor respectively. E.g., class __decl...

Pbl xcode C++ typedef struct toto toto

Hi everyone, I am working on a C++ project on macOS X 10.6.2 with xcode. I tried to compile my code on windows and do not have any problem, I guess Linux is working but I don't have one with me right now. My problem is xcode do not accept this kind of instruction : struct direction { double x; double y; double z; double t; }; typede...

How to link to VS2008 generated .libs from g++

I am trying to build a dll using mingw g++ under cygwin. I have .h files that refer to objects exported by a .dll that was build using MS Visual Studio 2008. I link to the .lib generated with that .dll. When I run g++ I get lots of errors like this /cygdrive/c/dev/blox/ulfx/ulfx/JavaInterface.cpp:206: undefined reference to `__imp___Z...

Getting multiple definition error

Hey, I'm trying to compile some c++ files. I'm getting the following types of errors at the linking phase (the compiling is working) - Main.o: In function operator<<(std::basic_ostream<char, std::char_traits<char> >&, Set const&)': /usr/include/c++/4.3/new:105: multiple definition of operator<<(std::basic_ostream< char, std::char_tr...

G++ -I option for compiling program

Hi experts, Here is a little problem that cannot be resolved by me such a Linux program newbie. Now I have a main.cpp program which need to be compiled, there is a #include "Down.h" in the front of file. Actually, this header file exist in the other directory, which locates at ../../../include directory. Besides, some other head...

Static initialization and destruction of a static library's globals not happening with g++

Hi! Until some time ago, I thought a .a static library was just a collection of .o object files, just archiving them and not making them handled differently. But linking with a .o object and linking with a .a static library containing this .o object are apparently not the same. And I don't understand why... Let's consider the following ...

C++ GNU Linker Errors

I'm trying to complie my program on Windows via Cygwin with the compilation command: g++ ping.cpp -I./include -L./lib -lchartdir50 I'm using an API called ChartDirector which draws charts for me. I've never linked libraries this way before (usually I do it through Visual Studio) so i'm a little new to this. I've got a really large lis...

c++ templated friend class

Hello all, I'm trying to write an implementation of a 2-3-4 tree in c++. I'm it's been a while since I've used templates, and I'm getting some errors. Here's my extremely basic code framework: node.h: #ifndef TTFNODE_H #define TTFNODE_H template <class T> class TreeNode { private: Tre...

Linking with .so files (webkit)

Hi, I'm trying to create a program that uses some of the code from WebKit/GTK+. Specifically, I want to load a string, use WebKit's parser to construct a DOM tree and then iterate over that tree. I'm trying to use a class called HTMLDocument. WebKit/GTK+ doesn't expose this as part of its API and I'm running into some trouble linking ...

gcc/g++ option to place all object files into separate directory

I am wondering why gcc/g++ doesn't have an option to place the generated object files into a specified directory. For example: mkdir builddir mkdir builddir/objdir cd srcdir gcc -c file1.c file2.c file3.c **--outdir=**../builddir/objdir I know that it's possible to achive this with separate -o options given to the compiler, e.g.: g...

gcc/g++: error when compiling large file

Hi, I have a auto-generated C++ source file, around 40 MB in size. It largely consists of push_back commands for some vectors and string constants that shall be pushed. When I try to compile this file, g++ exits and says that it couldn't reserve enough virtual memory (around 3 GB). Googling this problem, I found that using the command ...

g++ produces big binaries despite small project

Probably this is a common question. In fact I think I asked it years ago... but I can't remember the answer. The problem is: I have a project that is composed of 6 source files. All of them no more than 200 lines of code. It uses many STL containers, stdlib.h and iostream. Now the executable is around 800kb in size.... I guess I shouldn...