473,326 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Linker error - VS2005 thinks it's a function declaration?

Base base;
BaseWrap& baseWrap(reinterpret_cast<BaseWrap&>(base));
boost::python::object obj(boost::shared_ptr<BaseWrap>(&baseWrap)); //
Compile error

Results in this error:

1>PythonPassReference.obj : error LNK2019: unresolved external symbol
"class boost::python::api::object __cdecl obj(class
boost::shared_ptr<struct BaseWrap&)" (?obj@@YA?
AVobject@api@python@boost@@AAV?$shared_ptr@UBaseWr ap@@@4@@Z)
referenced in function _main

My first thought is somehow that looks like a function declaration
instead of creating an object on the stack and instantiating it. If I
remove the shared_ptr, the error goes away.

In case it helps, here's a few more details.

boost::python::object has the following constructor:

// explicit conversion from any C++ object to Python
template <class T>
explicit object(
T const& x
# if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
// use some SFINAE to un-confuse MSVC about its
// copy-initialization ambiguity claim.
, typename mpl::if_<is_proxy<T>,int&,int>::type* = 0
# endif
)
: object_base(object_base_initializer(x))
{
}

boost::shared_ptr<Thas the following constructor:

template<class Y>
explicit shared_ptr( Y * p ): px( p ), pn( p ) // Y must be
complete
{
boost::detail::sp_enable_shared_from_this( pn, p, p );
}

Any tips on how to solve this would be greatly appreciated. I'm
probably overlooking something obvious.

Thanks in advance,

Lawrence

Jul 17 '07 #1
1 2016
Lawrence Spector wrote:
Base base;
BaseWrap& baseWrap(reinterpret_cast<BaseWrap&>(base));
boost::python::object obj(boost::shared_ptr<BaseWrap>(&baseWrap)); //
Compile error

Results in this error:

1>PythonPassReference.obj : error LNK2019: unresolved external symbol
"class boost::python::api::object __cdecl obj(class
boost::shared_ptr<struct BaseWrap&)" (?obj@@YA?
AVobject@api@python@boost@@AAV?$shared_ptr@UBaseWr ap@@@4@@Z)
referenced in function _main

My first thought is somehow that looks like a function declaration
instead of creating an object on the stack and instantiating it. If I
remove the shared_ptr, the error goes away.
Any tips on how to solve this would be greatly appreciated. I'm
probably overlooking something obvious.
You are overlooking something, but it's not that obvious. Your 'obj'
declaration is similar to

double obj(int(&blah));

Care to parse it? A hint: the parentheses around &blah don't matter.

....

Give up? It's the same as

double obj(int &blah);

Look familiar? It's a function declaration!

How do you prevent this from being treated as a function declaration?
Put extra parentheses around the "argument":

double obj((int(&blah)));

In your case:

boost::python::object obj( (boost::shared_ptr<BaseWrap>(&baseWrap)) );

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 17 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: william xuuu | last post by:
Actually, I also got linker errors with template functions and template classes. And I avoided both of them successfully, by pouring foo.cpp into foo.h, according to the C++ FAQ. ...
12
by: Baloff | last post by:
Hello I have this linker error which makes me think that the definition file is not being seen by the linker, this code is taken from "Thinking in C++, 2nd Edition, Volume 1, Annotated Solutions...
2
by: AMT2K5 | last post by:
Hello. When I compile my program I recieve lots and lots of the following message which I am trying to decipher. "xxx was declared deprecated". What exactly does that mean?
3
by: Steve Baer | last post by:
I recently read your whitepaper under the "extremely long link times" post and have a question that I was hoping you could answer. My question is based on the following paragraph: Directives...
3
by: Chucker | last post by:
Hi Folks, I got a Wrapper Dll around a native C++ static library. In .NET 1.1 this worked fine. When moving to .NET 2.0 I get a couple of unresolved externals / linker errors: Error 16 error...
6
by: Sampei120 | last post by:
When I go to compile a project I see this error undefined reference to `_imp___ZN3irr12createDeviceENS_5video13E_DRIVER_TYPEERKNS_4core11dimension2dIiEEjbbbPNS_14IEventReceiverEPKw' someone...
4
by: PyongHopscotch | last post by:
Hi All, So I'm getting the generic linker error (unresolved external error) in VC 7.0 when I define a templatized function. Here's some code examples: template <class T> class...
1
by: ImamicPH | last post by:
Hi, My first post. How do you resolve linker errors? I have a simple header file that contains one function declaration. This function is used in another file (.cpp) in the definition of a...
3
by: prakash.mirji | last post by:
Hello, I am getting below mention linker error when I tried to link my class test.C I use below command to compile test.C /usr/bin/g++ -g -fpic -fvisibility=default -D_POSIX_SOURCE...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.