• Advertisement
Sign in to follow this  

Jam help

This topic is 4688 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
A::A(const A &a)
{
operator=(A);
}

That should be
A::A(const A &a)
{
operator=(a);
}

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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...)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement