How to compile .cpp file

Nathanael D. Noblet nathanael at gnat.ca
Sat Aug 27 12:14:00 PDT 2011


On 08/27/2011 05:54 AM, 宋喜佳 wrote:
> Hi friends,
>    I have wrte a simple application with c++, but now I do not know how
> to compile it. when I use gcc, a error comes out. Just like:
> 
> [linux-devkit]:~/myTest_host/audio-player>  arm-none-linux-gnueabi-gcc
> -Wall $(pkg-config --cflags --libs gstreamer-0.10) audio-player.cpp
> audio-player.h -lz
> audio-player.h:6: error: expected '=', ',', ';', 'asm' or
> '__attribute__' before 'AudioPlayer'
> [linux-devkit]:~/myTest_host/audio-player>
> 
> when I change to g++ ,another error occurred, just like:
> 
> [linux-devkit]:~/myTest_host/audio-player>  arm-none-linux-gnueabi-g++
> -Wall $(pkg-config --cflags --libs gstreamer-0.10) audio-player.cpp
> audio-player.h -lz
> /root/CodeSourcery/Sourcery_G++_Lite/bin/../arm-none-linux-gnueabi/libc/usr/lib/crt1.o:
> In function `_start':
> init.c:(.text+0x30): undefined reference to `main'
> collect2: ld returned 1 exit status
> [linux-devkit]:~/myTest_host/audio-player>

A compiler doesn't need you to specify the include files on the command
line. That's what the include search paths are for. You should likely
have something more like.

arm-none-linux-gnueabi-g++ -Wall $(pkg-config --cflags gstreamer-0.10)
audio-player.cpp -o audio-player $(pkg-config --libs gstreamer-0.10)

The question is unrelated to gstreamer, you would likely have been able
to find the answer to this via google.


More information about the gstreamer-devel mailing list