Can't compile a simple c++ example

View: New views
6 Messages — Rating Filter:   Alert me  

Can't compile a simple c++ example

by aneves :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I'm having trouble compiling a simple example of a c++ program for player/stage. I'm new in linux and I don't work so well with g++.

When I compile like this:
$ g++ -o ex1 -I/usr/include/player-2.0 ex1.cc

I get this errors:

/tmp/cc3YXRdN.o: In function `main':
ex1.cc:(.text+0x107): undefined reference to `PlayerCc::PlayerClient::PlayerClient(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int, int)'
ex1.cc:(.text+0x162): undefined reference to `PlayerCc::Position2dProxy::Position2dProxy(PlayerCc::PlayerClient*, unsigned int)'
ex1.cc:(.text+0x177): undefined reference to `PlayerCc::PlayerClient::~PlayerClient()'
ex1.cc:(.text+0x1bb): undefined reference to `PlayerCc::LaserProxy::LaserProxy(PlayerCc::PlayerClient*, unsigned int)'
ex1.cc:(.text+0x1d2): undefined reference to `PlayerCc::Position2dProxy::SetMotorEnable(bool)'
ex1.cc:(.text+0x1e1): undefined reference to `PlayerCc::Position2dProxy::RequestGeom()'
ex1.cc:(.text+0x1ed): undefined reference to `PlayerCc::LaserProxy::RequestGeom()'
ex1.cc:(.text+0x1fc): undefined reference to `PlayerCc::PlayerClient::Read()'
ex1.cc:(.text+0x263): undefined reference to `PlayerCc::LaserProxy::~LaserProxy()'
ex1.cc:(.text+0x27c): undefined reference to `PlayerCc::Position2dProxy::~Position2dProxy()'
ex1.cc:(.text+0x295): undefined reference to `PlayerCc::PlayerClient::~PlayerClient()'
/tmp/cc3YXRdN.o: In function `PlayerCc::Position2dProxy::SetSpeed(double, double)':
ex1.cc:(.text._ZN8PlayerCc15Position2dProxy8SetSpeedEdd[PlayerCc::Position2dProxy::SetSpeed(double, double)]+0x39): undefined reference to `PlayerCc::Position2dProxy::SetSpeed(double, double, double)'
collect2: ld returned 1 exit status

Am I doing something wrong?  The program is an example taked from a tutorial.

Thanks,

André Neves

Re: Can't compile a simple c++ example

by Michael Bienia-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 2009-11-01 10:48:18 -0800, aneves wrote:

> Hello,
>
> I'm having trouble compiling a simple example of a c++ program for
> player/stage. I'm new in linux and I don't work so well with g++.
>
> When I compile like this:
> $ g++ -o ex1 -I/usr/include/player-2.0 ex1.cc
>
> Am I doing something wrong?  The program is an example taked from a
> tutorial.

You have missed to add the libs gcc should link to your example.

Try: g++ -o ex1 -I/usr/include/player-2.0 -lplayerc++ ex1.cc

(Don't know if it's enough or other libs are missing too).

Michael

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Playerstage-users mailing list
Playerstage-users@...
https://lists.sourceforge.net/lists/listinfo/playerstage-users

Re: Can't compile a simple c++ example

by Rich Mattes-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It's a lot easier to use pkg-config for dependancies.  Try something like:
 
$ g++ -o ex1 `pkg-config --cflags --libs playerc++` ex1.cc
 
If you run the pkg-config command between the `` on its own, it'll output all of the include paths and libraries you'll need.

On Sun, Nov 1, 2009 at 2:19 PM, Michael Bienia <michael@...> wrote:
On 2009-11-01 10:48:18 -0800, aneves wrote:
> Hello,
>
> I'm having trouble compiling a simple example of a c++ program for
> player/stage. I'm new in linux and I don't work so well with g++.
>
> When I compile like this:
> $ g++ -o ex1 -I/usr/include/player-2.0 ex1.cc
>
> Am I doing something wrong?  The program is an example taked from a
> tutorial.

You have missed to add the libs gcc should link to your example.

Try: g++ -o ex1 -I/usr/include/player-2.0 -lplayerc++ ex1.cc

(Don't know if it's enough or other libs are missing too).

Michael

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Playerstage-users mailing list
Playerstage-users@...
https://lists.sourceforge.net/lists/listinfo/playerstage-users


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Playerstage-users mailing list
Playerstage-users@...
https://lists.sourceforge.net/lists/listinfo/playerstage-users

Re: Can't compile a simple c++ example

by arik_chen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, all
I feel painful when I first try to write a player client, so I wrote a generic Makefile (see the attachment) for a client
a starter may find it useful.
what you need to do is adjust the first few line of Makefile, which is the executable file name, lib path, include path.
wish it help.

best wishes
Arik

Rich Mattes-2 wrote:
It's a lot easier to use pkg-config for dependancies.  Try something like:

$ g++ -o ex1 `pkg-config --cflags --libs playerc++` ex1.cc

If you run the pkg-config command between the `` on its own, it'll output
all of the include paths and libraries you'll need.

On Sun, Nov 1, 2009 at 2:19 PM, Michael Bienia <michael@bienia.de> wrote:

> On 2009-11-01 10:48:18 -0800, aneves wrote:
> > Hello,
> >
> > I'm having trouble compiling a simple example of a c++ program for
> > player/stage. I'm new in linux and I don't work so well with g++.
> >
> > When I compile like this:
> > $ g++ -o ex1 -I/usr/include/player-2.0 ex1.cc
> >
> > Am I doing something wrong?  The program is an example taked from a
> > tutorial.
>
> You have missed to add the libs gcc should link to your example.
>
> Try: g++ -o ex1 -I/usr/include/player-2.0 -lplayerc++ ex1.cc
>
> (Don't know if it's enough or other libs are missing too).
>
> Michael
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Playerstage-users mailing list
> Playerstage-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/playerstage-users
>

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Playerstage-users mailing list
Playerstage-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-users
MakefileMakefile

Re: Can't compile a simple c++ example

by aneves :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!
 Michael, the 'pkg-config' solution doesn't  work on my pc. It says th files can't be found.. thank you anyway.

 Thanks a lot, Arik, your makefile solved my problem and probability my sanity:)

arik_chen wrote:
Hi, all
I feel painful when I first try to write a player client, so I wrote a generic Makefile (see the attachment) for a client
a starter may find it useful.
what you need to do is adjust the first few line of Makefile, which is the executable file name, lib path, include path.
wish it help.

best wishes
Arik

Rich Mattes-2 wrote:
It's a lot easier to use pkg-config for dependancies.  Try something like:

$ g++ -o ex1 `pkg-config --cflags --libs playerc++` ex1.cc

If you run the pkg-config command between the `` on its own, it'll output
all of the include paths and libraries you'll need.

On Sun, Nov 1, 2009 at 2:19 PM, Michael Bienia <michael@bienia.de> wrote:

> On 2009-11-01 10:48:18 -0800, aneves wrote:
> > Hello,
> >
> > I'm having trouble compiling a simple example of a c++ program for
> > player/stage. I'm new in linux and I don't work so well with g++.
> >
> > When I compile like this:
> > $ g++ -o ex1 -I/usr/include/player-2.0 ex1.cc
> >
> > Am I doing something wrong?  The program is an example taked from a
> > tutorial.
>
> You have missed to add the libs gcc should link to your example.
>
> Try: g++ -o ex1 -I/usr/include/player-2.0 -lplayerc++ ex1.cc
>
> (Don't know if it's enough or other libs are missing too).
>
> Michael
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Playerstage-users mailing list
> Playerstage-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/playerstage-users
>

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Playerstage-users mailing list
Playerstage-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-users
MakefileMakefile

New Player Stage book

by amw :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear All,

Just a quick mail to plug my book which is published this month. It
covers use of the libplayerc++ library and shows how to create and use
Stage worlds. Here is the link on Amazon,

http://www.amazon.co.uk/Programming-Mobile-Robots-Aria-Player/dp/1848828632/ref=sr_1_1?ie=UTF8&s=books&qid=1257184333&sr=8-1


regards,

Dr. Amanda Whitbrook
Research Fellow
Intelligent Modelling & Analysis (IMA) Research Group
School of Computer Science
University of Nottingham
Jubilee Campus
Wollaton Road
Nottingham
NG8 1BB


This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Playerstage-users mailing list
Playerstage-users@...
https://lists.sourceforge.net/lists/listinfo/playerstage-users