mailbox44 | 2 Jan 01:57
Favicon

Undefined Reference (newbie)


I think my problem is a simple linking problem.   I have looked through the
archives and tried a few things to no avail.

I am trying to compile the simple thread example from the boost site (see
end of message).

I am using 64 bit Redhat linux on a dual core opteron box.  

g++ -v 

Reading specs from /usr/lib/gcc/x86_64-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk
--host=x86_64-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)

I believe the boost libraries come pre-installed on linux, but just in case
I followed all the directions online and installed the libraries (I just
used whatever defaults the installed runs).

I compile the program below with:

g++ test.cpp    (I renamed the sample program test)

and get these errors:

(Continue reading)

pete | 2 Jan 02:57

Re: Undefined Reference (newbie)

On Mon, Jan 01, 2007 at 06:57:23PM -0600, mailbox44 <at> swissmail.org wrote:
> I think my problem is a simple linking problem.   I have looked through the
> archives and tried a few things to no avail.

Try linking with -lboost_threads AND -lpthread

I can force the same errors you get, and then fix it by doing this:
> g++ test.cpp -I/usr/local/include -L/usr/local/lib -lboost_thread -lpthread

Of course, the -I and -L are specific to my boost location.

I bet this will do in your situation:
> g++ test.cpp -lboost_thread -lpthread

I had no problem on my Linxu box, but FreeBSD was complaining about the
same issues and that fixed it for me with the code you sent.

Good luck,

Pete
mailbox44 | 2 Jan 03:26
Favicon

Undefined Reference (newbie) solved & followup question

From my previous post.  I was linking the wrong file.  The correct linkage (or at least one that compiled)

 

g++ test.cpp -lboost_thread-gcc-mt-d-1_33_1

 

 

A few more questions…

 

There is also a libboost_thread-gcc-mt-d-1_33_1.so file.  What is the –d represent??

 

Why does the linker not know to use the given library?  Based on other sources I put the path

 

/usr/local/lib

 

in my /etc/ld.so.conf  file and then ran /sbin/ldconfig

 

What do I need to do so that I do not have to include all the boost libraries in the compile line?

 

Thanks much.

 

Steve

 

_______________________________________________
Boost-users mailing list
Boost-users <at> lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Rene Rivera | 2 Jan 05:32
Picon
Gravatar

Re: Undefined Reference (newbie) solved & followup question

mailbox44 <at> swissmail.org wrote:
> A few more questions.
> 
> There is also a libboost_thread-gcc-mt-d-1_33_1.so file.  What is the -d
> represent??

http://boost.org/more/getting_started.html#Results

> Why does the linker not know to use the given library? 

That's a question for the GCC and/or binutils group.

> What do I need to do so that I do not have to include all the boost
> libraries in the compile line?

Ask the GCC and binutils (and probably many other Unix vendors and tool 
writers) to implement autolinking.

--

-- 
-- Grafik - Don't Assume Anything
-- Redshift Software, Inc. - http://redshift-software.com
-- rrivera/acm.org - grafik/redshift-software.com
-- 102708583/icq - grafikrobot/aim - grafikrobot/yahoo
pete | 2 Jan 05:42

Re: Undefined Reference (newbie) solved & followup question

On Mon, Jan 01, 2007 at 10:32:35PM -0600, Rene Rivera wrote:
> > What do I need to do so that I do not have to include all the boost
> > libraries in the compile line?

Actually, autoconf/automake can do much of that for you in many cases.

This is a good place to get a handle on the tools.
http://sources.redhat.com/autobook/autobook/autobook_toc.html

Then you can check out the boost macros.
http://autoconf-archive.cryp.to/macros-by-category.html#BOOST

Set them up in your configure.ac, and do something in your Makefile.am
like this(in this case I needed boost_program_options and
boost_date_time):

progname_CPPFLAGS = @BOOST_CPPFLAGS@
progname_LDFLAGS = @BOOST_LDFLAGS@
progname_LDADD = @PTHREAD_CFLAGS@ @BOOST_PROGRAM_OPTIONS_LIB@ @BOOST_DATE_TIME_LIB@

You'll then use configure to generate much of what you're looking for on
most modern systems.

There's a bit of a learning curve to it, but using autoconf has saved me
a LOT of time over the past few years.

Pete
Rene Rivera | 2 Jan 06:01
Picon
Gravatar

Re: Undefined Reference (newbie) solved & followup question

pete <at> mu.org wrote:
> On Mon, Jan 01, 2007 at 10:32:35PM -0600, Rene Rivera wrote:
>>> What do I need to do so that I do not have to include all the boost
>>> libraries in the compile line?
> 
> 
> Actually, autoconf/automake can do much of that for you in many cases.

Yes, with considerable extra pain. Boost.Build can do the same with 
considerably less pain... But that's not what the OP asked about ;-)

--

-- 
-- Grafik - Don't Assume Anything
-- Redshift Software, Inc. - http://redshift-software.com
-- rrivera/acm.org - grafik/redshift-software.com
-- 102708583/icq - grafikrobot/aim - grafikrobot/yahoo
pete | 2 Jan 06:13

Re: Undefined Reference (newbie) solved & followup question

On Mon, Jan 01, 2007 at 11:01:20PM -0600, Rene Rivera wrote:
> pete <at> mu.org wrote:
> > On Mon, Jan 01, 2007 at 10:32:35PM -0600, Rene Rivera wrote:
> >>> What do I need to do so that I do not have to include all the boost
> >>> libraries in the compile line?
> > 
> > 
> > Actually, autoconf/automake can do much of that for you in many cases.
> 
> Yes, with considerable extra pain. Boost.Build can do the same with 
> considerably less pain... But that's not what the OP asked about ;-)

It's only extra pain to learn it, but in the end, it's quite useful.  It
also helps in a load of other apps that use autoconf.  I'm sure
boost.build is great, but autoconf is so prevalent, I started with that.

I'm just trying to be helpful.  Those kinds of problems he's having used
to be a part of my life until I started using autoconf.  Those issues
went away 99%, and it helps a great deal in the opensource experience to
know it.  autoconf/automake/etc... are incredibly powerful and
ubiquitous.  

There are a lot of good ways to deal with that, but "waiting" for
someone else to fix it, doesn't really solve the problem in helpful
many.  So, instead of passing the buck, I was trying to let him know
what has helped me.

That's my 2 cents,

Pete
Marc Viala | 2 Jan 10:06

Re: [Boost.Multi-Index] ICE w/ VC7.1

Hello Joaquin and happy New Year,

Sorry for my late reply but our mail server was down in the night of 31th; this is not a joke. 

I've just changed the code snippet with your recommendation but without success: I've got the same ICE with
VC7.1. 

Just to clarify my report: I've also compiled some code snippets from the MultiIndex documentation and get
the same ICE. My compiler version corresponds to the VC7.1 with the service pack #1.

Best regards,

Marc Viala
> -----Message d'origine-----
> De : boost-users-bounces <at> lists.boost.org [mailto:boost-users-bounces <at> lists.boost.org] De
> la part de "JOAQUIN LOPEZ MU?Z"
> Envoyé : dimanche 31 décembre 2006 01:08
> À : boost-users <at> lists.boost.org
> Objet : Re: [Boost-users] [Boost.Multi-Index] ICE w/ VC7.1
> 
> Hello Marc,
> 
> ----- Mensaje original -----
> De: Marc Viala <mviala <at> acticm.com>
> Fecha: Viernes, Diciembre 29, 2006 7:25 pm
> Asunto: [Boost-users] [Boost.Multi-Index] ICE w/ VC7.1
> Para: boost-users <at> lists.boost.org
> 
> > I'm just trying to use Boost.MultiIndex in a large project but I'm
> not
> > being able to compile this library with VC 7.1.6030: I've got an
> > ICE in file "apply_wrap.hpp" of Boost.MPL. I've tried to change the
> > headers order but without success.
> >
> > My environment is:
> > -        Windows XP
> > -        Boost 1.33.1
> > -        VC 7.1.6030
> >
> > To demonstrate this ICE, you will find hereafter a code snippet.
> >
> > Thanks in advance.
> >
> > Marc Viala
> [...]
> >  typedef composite_key<
> >      Item
> >    , ordered_non_unique<member<Item,int,&Item::_i> >
> >    , ordered_non_unique<member<Item,int,&Item::_j> >
> >    > ckey_ij ;
> 
> I think the problem lies here: you must provide composite_key<>
> with *key extractors*, not index specifiers. Please try
> rewriting ckey_ij like this:
> 
>   typedef composite_key<
>       Item
>     , member<Item,int,&Item::_i>
>     , member<Item,int,&Item::_j>
>     > ckey_ij ;
> 
> Problem solved? I'm sorry I can't try the snippet you
> provide myself, so please report back. Thanks for using
> Boost.MultiIndex!
> 
> Joaquín M López Muñoz
> Telefónica, Investigación y Desarrollo
> _______________________________________________
> Boost-users mailing list
> Boost-users <at> lists.boost.org
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
Andrew Marlow | 2 Jan 10:07
Favicon

fatal error LNK1561: entry point must be defined building boost libs with win32 port of pthread

I am trying to build boost using the win32 port of pthreads.
The command I use is:

bjam -STOOLS=vc-7_1 -sPTW32_DIR="where-i-put-win32-pthreads"
-sPTW32_LIB="pthreadVC.lib" stage

The error I get is:

LINK : warning LNK4001: no object files specified; libraries used 
LINK : warning LNK4068: /MACHINE not specified; defaulting to X86 
LINK : fatal error LNK1561: entry point must be defined

Would be nice of Mico$oft said ***which*** entrypoint is missing. 
Without that little snippet of information I can only guess....

The log shows the linker command line used:

    CALL "C:\Program Files\Microsoft Visual Studio .NET
2003\VC7\bin\VCVARS32.BAT" >nul
     "C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\bin\link" 
/nologo /INCREMENTAL:NO 
/LIBPATH:e:\work\overnight\win_extern\lib" 
/DEBUG /DLL /subsystem:console  
/out:"..\..\..\bin\boost\libs\regex\build\boost_regex.dll\vc-7_1\debug\t
hreading-multi\
boost_regex-vc71-mt-gd-1_33_1.dll" 
/IMPLIB:"..\..\..\bin\boost\libs\regex\build\boost_regex.dll\vc-7_1\debu
g\threading-multi\
boost_regex-vc71-mt-gd-1_33_1.lib"    
@"..\..\..\bin\boost\libs\regex\build\boost_regex.dll\vc-7_1\debug\threa
ding-multi\
boost_regex-vc71-mt-gd-1_33_1.CMD"

The CMD file just contains a list of the object files.

Any ideas please? I am tearing my hair out here.
A quick google reveals that a few other people across the world also
have this
problem, but not many. Those people posted their question to various
forums
and unfortunately got no reply :-(

Regards,

Andrew Marlow
----
There is an emerald here the size of a plover's egg!
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

******************************************************************************"
The data and information (collectively called Information) herein is the sole property of ICAP.  The
Information is confidential, may be legally privileged and is intended solely for the use of the
individual or entity to whom it is addressed.  Unauthorised disclosure, copying or distribution of the
Information is strictly prohibited and the recipient of the Information shall not redistribute the
Information in any form to a third party.  If you received this Information in error please tell us by reply
(or telephone the sender) and delete all copies on your system.

References in this Information to ICAP are references to ICAP plc, a company incorporated in England with
registered number 3611426 whose registered office is 2 Broadgate, London, EC2M 7UR and where the context
requires, includes its subsidiary and associated undertakings.  As applicable, certain companies
within the ICAP group are authorised and regulated by the Financial Services Authority.  Any investment
research sent from ICAP will provide an impartial and objective assessment of the securities, companies
or other matters that are the subject of their research and our Conflicts of Interest Management Policy
regarding investment research can be viewed by requesting a copy from your usual contact at ICAP.  Please
visit www.icap.com for further regulatory information including details regarding the European
eCommerce Directive.

*******************************************************************************"
We have taken precautions to minimise the risk of transmitting software viruses, but we advise you to carry
out your own virus checks on any attachment to this message. We cannot accept liability for any loss or
damage caused by software viruses. "
*******************************************************************************                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     

JOAQUIN LOPEZ MU?Z | 2 Jan 12:41
Picon
Gravatar

Re: [Boost.Multi-Index] ICE w/ VC7.1

----- Mensaje original -----
De: Marc Viala <mviala <at> acticm.com>
Fecha: Martes, Enero 2, 2007 10:07 am
Asunto: Re: [Boost-users] [Boost.Multi-Index] ICE w/ VC7.1
Para: boost-users <at> lists.boost.org

> Hello Joaquin and happy New Year,
> 
> Sorry for my late reply but our mail server was down in the night 
> of 31th; this is not a joke. 
> 
> I've just changed the code snippet with your recommendation but 
> without success: I've got the same ICE with VC7.1. 
> 
> Just to clarify my report: I've also compiled some code snippets 
> from the MultiIndex documentation and get the same ICE. My 
> compiler version corresponds to the VC7.1 with the service pack #1.

Umm, this is weirder. Do you mean you have tried to compile some
of the programs under boost/libs/multi_index/example? Could you
please try to compile some of the .cpps on the test folder,
for instance boost/libs/multi_index/test/test_basic.cpp? Same ICE?

B.MI has always worked satisfactorily with MSVC 7.1, so I'm 
wondering if it's the SP#1 that's making the difference. Current
regression tests for the upcoming v1.34 of Boost are not showing
any problem with B.MI and MSVC 7.1, but I don't know whether
they have SP#1 or not. Do you know if installing the service
pack makes the predefined macro _MSC_FULL_VER to bump? This
macro is 13106030 in the regression testing environment, see
http://tinyurl.com/y84ngx . Also, do you have access to a
compiler installation not having the SP that you can try
your snippet on?

Sorry to bring more questions than answers here. I you can
come up with some info about the issues I mention above I
think we'll be able to isolate the problem.

> Best regards,
> 
> Marc Viala

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo

Gmane