Compiling Issues Using 'libstage'

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Compiling Issues Using 'libstage'

Michael Koval
I have successfully downloaded Stage 3.1 from the Player/Stage SVN, compiled it on Ubuntu (Jaunty), and gotten a dynamically-linked Stage controller to work (e.g. loading /usr/local/lib/controller.so from a world file with the 'ctrl "controller"" statement) using the "-fPIC `pkg-config --cflags stage` `pkg-config --libs stage`" GCC flags.

Unfortunately, I am unable to successfully compile my own program that directly uses libstage on the same system. The linker has problem locating stage.hh (/usr/local/lib/Stage-3.1/stage.hh) and will happily compile a file as follows:

#include <iostream>
#include <Stage-3.1/stage.hh>
int main(int argc, char* argv[]) {
        std::cout << "Hello, world!" << std::endl;
        return 0;
}

If, however, I attempt to use any of the functions defined in the "stage.hh" header, I receive an "undefined reference" linking error For example:

#include <Stage-3.1/stage.hh>
int main(int argc, char* argv[]) {
        Stg::Init(&argc, &argv);
        return 0;
}

Compiling this code results in the following error: "undefined reference to `Stg::Init(int*, char***)'". I am currently compiling with the flags "-Wall -c `pkg-config --cflags stage` `pkg-config --libs stage`". Interestingly, the example "libstage" controller program included in the Stage source (/examples/libstage/stest.cc) seems to compile fine in the process of compiling and installing Stage.

Any help or advice would be greatly appreciated.

- Michael Koval
Reply | Threaded
Open this post in threaded view
|

Re: Compiling Issues Using 'libstage'

alualu
Got the same problem. After I'vve installed libstage (make install), I tried to compile stest.cc from examples/libstage with:
g++ -lstage -L/usr/local/lib/Stage-4.1 -L/usr/local/lib -I/usr/local/include/Stage-4.1 stest.cc

... got several "undefined reference" errors.
Reply | Threaded
Open this post in threaded view
|

Re: Compiling Issues Using 'libstage'

Rich Mattes-2
On 05/24/2013 12:50 PM, alualu wrote:
> Got the same problem. After I'vve installed libstage (make install), I tried
> to compile stest.cc from examples/libstage with:
> g++ -lstage -L/usr/local/lib/Stage-4.1 -L/usr/local/lib
> -I/usr/local/include/Stage-4.1 stest.cc
>
> ... got several "undefined reference" errors.
>
>
>
...what were they?  It's hard to tell what is wrong without the full
error message output; please see [1] for general guidance on asking
questions on the mailing list.

Rich

[1] http://playerstage.sourceforge.net/wiki/Getting_help

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Playerstage-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/playerstage-users
Reply | Threaded
Open this post in threaded view
|

Re: Compiling Issues Using 'libstage'

alualu
I get undefined reference to everything from libstage.so, linker can't see it apparently:

/tmp/cceQ72Cn.o: In function `main':
stest.cc:(.text+0x67): undefined reference to `Stg::Init(int*, char***)'
stest.cc:(.text+0x8b): undefined reference to `Stg::WorldGui::WorldGui(int, int, char const*)'
stest.cc:(.text+0xcc): undefined reference to `Stg::WorldGui::Load(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
stest.cc:(.text+0x111): undefined reference to `Stg::World::Run()'
stest.cc:(.text+0x12e): undefined reference to `Stg::WorldGui::~WorldGui()'
stest.cc:(.text+0x180): undefined reference to `Stg::WorldGui::~WorldGui()'
/tmp/cceQ72Cn.o: In function `Logic::connect(Stg::World*)':
stest.cc:(.text._ZN5Logic7connectEPN3Stg5WorldE[Logic::connect(Stg::World*)]+0x8a): undefined reference to `Stg::World::GetModel(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
stest.cc:(.text._ZN5Logic7connectEPN3Stg5WorldE[Logic::connect(Stg::World*)]+0xed): undefined reference to `Stg::Model::Subscribe()'
stest.cc:(.text._ZN5Logic7connectEPN3Stg5WorldE[Logic::connect(Stg::World*)]+0x131): undefined reference to `Stg::Model::GetChild(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
stest.cc:(.text._ZN5Logic7connectEPN3Stg5WorldE[Logic::connect(Stg::World*)]+0x1a1): undefined reference to `Stg::Model::Subscribe()'
stest.cc:(.text._ZN5Logic7connectEPN3Stg5WorldE[Logic::connect(Stg::World*)]+0x1e0): undefined reference to `Stg::World::AddUpdateCallback(int (*)(Stg::World*, void*), void*)'
/tmp/cceQ72Cn.o: In function `Logic::Tick(Stg::World*)':
stest.cc:(.text._ZN5Logic4TickEPN3Stg5WorldE[Logic::Tick(Stg::World*)]+0x306): undefined reference to `Stg::ModelPosition::SetSpeed(double, double, double)'
collect2: ld returned 1 exit status


Though compilation succeeds using cmake and make:

cmake_minimum_required(VERSION 2.6)

find_library(LIB_STAGE stage PATHS /usr/local/lib/)
include_directories(/usr/local/include/Stage-4.1/)
add_executable(stest stest.cc)
target_link_libraries(stest ${LIB_STAGE})