Linking problem using aclic

Hi,

I have a small but annoying problem. I have a small code that fits several spectra using at the same time, not so important what it does. But when I compile it having changed something root complains about a missing symbol. Quitting root, and reloading using the same command, and all is fine… See the small example below. Any ideas what is going on?

csnpor136:gf3cmdfiles joa$ root -l
root [0] .L ~/minaROOTklasser/plunger/FitMultipleSpectra.cxx+O
Info in TUnixSystem::ACLiC: creating shared library /Users/joa/minaROOTklasser/plunger/FitMultipleSpectra_cxx.so
dlopen error: dlopen(/Users/joa/minaROOTklasser/plunger/FitMultipleSpectra_cxx.so, 10): Symbol not found: _ZNSt8ios_baseaSERKS
Referenced from: /Users/joa/minaROOTklasser/plunger/FitMultipleSpectra_cxx.so
Expected in: flat namespace
in /Users/joa/minaROOTklasser/plunger/FitMultipleSpectra_cxx.so
Load Error: Failed to load Dynamic link library /Users/joa/minaROOTklasser/plunger/FitMultipleSpectra_cxx.so
Undefined symbols:
"_main", referenced from:
start in crt1.10.6.o
"std::ios_base::operator=(std::ios_base const&)", referenced from:
std::basic_ios<char, std::char_traits >::operator=(std::basic_ios<char, std::char_traits > const&)in FitMultipleSpectra_cxx_ACLiC_dict.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
root [1] .q
csnpor136:gf3cmdfiles joa$ root -l
root [0] .L ~/minaROOTklasser/plunger/FitMultipleSpectra.cxx+O
root [1]

I`m on

A-MacBook-Pro:~ joa$ uname -a
Darwin A-MacBook-Pro.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386

A-MacBook-Pro:~ joa$ root-config --version --config
5.31/01 --prefix=/usr/local/root-opt --with-x11-libdir=/opt/local/lib/ --with-xpm-libdir=/opt/local/lib/ --with-xft-libdir=/opt/local/lib/ --with-xext-libdir=/opt/local/lib/ --with-opengl-libdir=/opt/local/lib/ --enable-builtin-glew --enable-minuit2

A-MacBook-Pro:~ joa$ g++ --version
i686-apple-darwin10-g+±4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright © 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

cheers

Joa

Hi Joa,

I can not reproduce the problem. Do you also see the problem with v5.30? Currently 5.31 is going through some changes in the way we are linking the libraries (and have seen some rough edges). Do you also see the problem with today’s trunk (revision 40304)? Does it also fail if you compile in debug mode (.L ~/mi…Spectra.cxx++g)

Cheers,
Philippe.

Hi,

I’ve manged to write a master piece of code that reproduces the problem

#include
#include

std::ostream &bootstrap=std::cout;

void Setbootstrap(std::ostream &os)

{
bootstrap=os;
}

A lot of typing…

cheers

Joa

Hi,

It fails because it is illegal C++ (and ACLiC is a bit permissive and delay some issues to link time).:g++ ios2.cxx /usr/include/c++/4.2.1/bits/ios_base.h: In member function ‘std::basic_ios<char, std::char_traits<char> >& std::basic_ios<char, std::char_traits<char> >::operator=(const std::basic_ios<char, std::char_traits<char> >&)’: /usr/include/c++/4.2.1/bits/ios_base.h:782: error: ‘std::ios_base& std::ios_base::operator=(const std::ios_base&)’ is private /usr/include/c++/4.2.1/iosfwd:55: error: within this context /usr/include/c++/4.2.1/iosfwd: In member function ‘std::basic_ostream<char, std::char_traits<char> >& std::basic_ostream<char, std::char_traits<char> >::operator=(const std::basic_ostream<char, std::char_traits<char> >&)’: /usr/include/c++/4.2.1/iosfwd:64: note: synthesized method ‘std::basic_ios<char, std::char_traits<char> >& std::basic_ios<char, std::char_traits<char> >::operator=(const std::basic_ios<char, std::char_traits<char> >&)’ first required here ios2.cxx: In function ‘void Setbootstrap(std::ostream&)’: ios2.cxx:10: note: synthesized method ‘std::basic_ostream<char, std::char_traits<char> >& std::basic_ostream<char, std::char_traits<char> >::operator=(const std::basic_ostream<char, std::char_traits<char> >&)’ first required here

In C++ you can not change the assignment of a reference, so when the compiler sees:std::ostream &bootstrap=std::cout; .... bootstrap=os; It literally means the same as:std::cout = os;

Cheers,
Philippe.

Hi,

yes, of course it does :blush: I naivly thought that ACLiC would tell me I did something stupid
in the same way as gcc does…

and doing the right thing (?) in my code , i.e.

std::ostream *bootstrap;

void SetBootstap(std::ostream &os)

{
bootstrap=&os;
}

took care of the problem.

cheers

Joa

ps