[pkg-boost-devel] Bug#383991: Linking error with libboost-dev (ublas::vector<>)

Gustavo HC Silva ghcsilva at ufl.edu
Mon Aug 21 10:05:01 UTC 2006


Package: libboost-dev

Version: 1.33.1-4

The compiler accuses a multiple definition error during linking. 

multiple definition of `_ZN5boost7numeric5ublas21scalar_divides_assignIT_T0_E8computedE'

Here is a simple example using 3 files: CommonClass.h, CommonClass.cpp
 main.cpp

//******* CommonClass.h **********
#ifndef COMMONCLASS_H_
#define COMMONCLASS_H_

#include <boost/numeric/ublas/vector.hpp>

typedef boost::numeric::ublas::vector<double> boost_vector;

class CommonClass
{
public:
	CommonClass();
	virtual ~CommonClass();
};

#endif /*COMMONCLASS_H_*/


//******* CommonClass.cpp **********
#include "CommonClass.h"

CommonClass::CommonClass()
{
}

CommonClass::~CommonClass()
{
} 

//******* main.cpp **********
#include <iostream>

#include "CommonClass.h"

using namespace std;

int main(void) {
	cout << "Hello World!" << endl;
	return 0;	
}

The Linker output: 

**** Incremental build of configuration Debug for project test_boost ****

make -k all 
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -omain.o ../main.cpp
Finished building: ../main.cpp
 
Building target: test_boost
Invoking: GCC C++ Linker
g++ -otest_boost ./CommonClass.o ./main.o
./main.o:(.data+0x0): multiple definition of `_ZN5boost7numeric5ublas21scalar_divides_assignIT_T0_E8computedE'
./CommonClass.o:(.data+0x0): first defined here
collect2: ld returned 1 exit status
make: *** [test_boost] Error 1
make: Target `all' not remade because of errors.
Build complete for project test_boost

Using the stable version of the boost libraries I got no errors.

I'm running debian testing with the eclipse IDE, GCC 4.1.1-5 

Please let me know what other type of info would be helpful.

 





More information about the pkg-boost-devel mailing list