Jam help

Started by
4 comments, last by Genjix 18 years, 12 months ago
im trying to get jam to compile and link this

#include "a.h"

int main()
{
	A::Foo();
}



#ifndef A_H
#define A_H

/***/
class A
{
    public:
	/***/
	A();
	/***/
	A(const A &a);
	/***/
	~A();

	/***/
	void operator=(const A &a);
	
	static void Foo();
    private:
};

#endif



#include "a.h"

#include <iostream>

A::A()
{
}
A::A(const A &a)
{
	operator=(A);
}
A::~A()
{
}

void A::operator=(const A &a)
{
}

void A::Foo()
{
	std::cout << "Foo()\n";
}



C++ = g++ ;
Main amir : main.cpp a.cpp ;
and the output

genjix@linux:~/media/tmp/src> jam
...found 14 target(s)...
...updating 1 target(s)...
Link amir
main.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
a.o(.text+0x56): In function `A::Foo()':
: undefined reference to `std::cout'
a.o(.text+0x5b): In function `A::Foo()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
a.o(.text+0x88): In function `__static_initialization_and_destruction_0(int,int)':
: undefined reference to `std::ios_base::Init::Init[in-charge]()'
a.o(.text+0xb2): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
a.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

cc  -o amir  main.o a.o

...failed Link amir ...
...failed updating 1 target(s)...
whereas

genjix@linux:~/media/tmp/src> g++ -c a.cpp
genjix@linux:~/media/tmp/src> g++ -c main.cpp
genjix@linux:~/media/tmp/src> g++ main.o a.o
genjix@linux:~/media/tmp/src> ./a.out
is fine. thanks.
Advertisement
A::A(const A &a)
{
operator=(A);
}

That should be
A::A(const A &a)
{
operator=(a);
}
It's trying to link using gcc instead of g++, so the c++ library isn't there.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
but it should be...
C++ = g++ ;Main amir : main.cpp hobo.cpp ;

doesn't the top line set the compiler to g++, yet I can clearly see it linking with cc O_O
Yes, it sets the compiler, but not the linker. The LINK variable that defines what program to use for linking defaults to $(CC). Set it to g++ and it should work. (I wonder, though, why g++ isn't the default compiler and linker in C++ mode...)

This topic is closed to new replies.

Advertisement