Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
About to link InitialisationParams::Create()
04-02-2015, 02:59 AM (This post was last modified: 04-02-2015 06:17 AM by okgwf.)
Post: #1
About to link InitialisationParams::Create()
All other functions can be linked,but the function InitialisationParams::Create() is undefined.

I'm using the latest code of OhNet, and Compile with "make native_only=yes"
Used by dynamic libraries: libohNet.so.
O System: ubuntu 14.10 X64.
Who know why? Thanks!

My code:
#include <OhNet.h>
using namespace OpenHome;
using namespace OpenHome::Net;
.........
InitialisationParams* initParams = InitialisationParams::Create();
...........

The error message:
OhNetUpnp.o: In function `main':
OhNetUpnp.cppSad.text+0x13): undefined reference to `OpenHome::Net::InitialisationParams::Create()'
collect2: error: ld returned 1 exit status
Makefile:11: recipe for target 'OhNetUpnp' failed
make: *** [OhNetUpnp] Error 1
Find all posts by this user
04-02-2015, 09:05 AM
Post: #2
RE: About to link InitialisationParams::Create()
(04-02-2015 02:59 AM)okgwf Wrote:  All other functions can be linked,but the function InitialisationParams::Create() is undefined.

ohNet defaults to classes being hidden (private to ohNet). Using a shared library in a C++ app hasn't been very common; it sounds as if things have rotted slightly and InitialisationParams needs to have its visibility changed.

To fix your build can you either mark InitialisationParams as DllExportClass (see other examples in OhNet.h) and rebuild ohNet or change to linking it into your app's binary (link libohNetCore.a rather than libohNet.so)?

If you continue using ohNet as a shared library, please let us know about any other classes that also need to be visible to callers.
Find all posts by this user
04-02-2015, 09:48 AM (This post was last modified: 04-02-2015 09:53 AM by okgwf.)
Post: #3
RE: About to link InitialisationParams::Create()
(04-02-2015 09:05 AM)simonc Wrote:  
(04-02-2015 02:59 AM)okgwf Wrote:  All other functions can be linked,but the function InitialisationParams::Create() is undefined.

ohNet defaults to classes being hidden (private to ohNet). Using a shared library in a C++ app hasn't been very common; it sounds as if things have rotted slightly and InitialisationParams needs to have its visibility changed.

To fix your build can you either mark InitialisationParams as DllExportClass (see other examples in OhNet.h) and rebuild ohNet or change to linking it into your app's binary (link libohNetCore.a rather than libohNet.so)?

If you continue using ohNet as a shared library, please let us know about any other classes that also need to be visible to callers.

Thank you very much!
I tried to custom a static method named "MyCreate()" with the same function in this class,but it still have the same problem.
it looks as if the static method of the classes is not visiable to the caller.

You are right, It is not necessary to use ohNet as a shared library in a small c++ App.I've changed to use OhNet as a static library. Now,It is working well.
Thanks!
Find all posts by this user


Forum Jump: