LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-24-2004, 06:05 AM   #1
siminone
LQ Newbie
 
Registered: Oct 2004
Posts: 3

Rep: Reputation: 0
Problems compiling sigc++ programs


HI, apoplogies in advance if question is obvious, i'm new to linux programming.

I have been playing around with the Y Windows Demo and tried to compile a source file supplied with it.

Unfortunately, I errors and they were all to do with sigc++. Y Windows uses sigc++1.0 and there are test files supplied with it. I tried compiling these and I got errors. I used the following command to compile the test source file.

gcc hello_world.cc -I/usr/include/sigc++-1.0

I got the following errors


hello_world.cc:11: error: syntax error before `&' token
hello_world.cc: In function `void print(...)':
hello_world.cc:12: error: `cout' undeclared (first use this function)
hello_world.cc:12: error: (Each undeclared identifier is reported only once for each function it appears in.)
hello_world.cc:12: error: `str' undeclared (first use this function)
hello_world.cc: In function `int main()':
hello_world.cc:16: error: ISO C++ forbids declaration of `type name' with no type
hello_world.cc:16: error: syntax error before `&' token
hello_world.cc:18: error: `printer' undeclared (first use this function)
hello_world.cc:18: error: invalid conversion from `void (*)(...)' to `void (*)()'
hello_world.cc:18: error: initializing argument 1 of `SigC::Slot0<R> SigC::slot(R (*)()) [with R = void]'


The soucefile is as follows:

Code:
// Copyright 1999 Karl Nelson.

#include <iostream>
#include <string>
#include <sigc++/signal_system.h>

#ifdef SIGC_CXX_NAMESPACES
using namespace SigC;
#endif

void print(const string &str) 
  {cout << str;}

main()
  {
   Signal1<void,const string &> printer;

   printer.connect(slot(print));

   printer("hello world\n");
  }
I have Mandrake 10.0 and using gcc 3.3.2. I hope I have supplyed enough details.

Thanks in advance

Alza
 
Old 10-24-2004, 09:15 AM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,533

Rep: Reputation: 148Reputation: 148
It's a C++ program, so compile with g++ instead of gcc.
 
Old 10-24-2004, 02:02 PM   #3
siminone
LQ Newbie
 
Registered: Oct 2004
Posts: 3

Original Poster
Rep: Reputation: 0
I used g++ and it comes up with the same errors.

I am sure it is to do with using the lastest version of gcc and and older version of sigc++.

I've tried -std=c99 which I understand is the standard in which it is compiled in (which could be an earlier version of gcc?) but i get a warning and it does not work. I've checked the man file and can't find any flags that compile to that of previous versions.
 
Old 10-24-2004, 02:38 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,533

Rep: Reputation: 148Reputation: 148
One thing is to add 'using namespace std' somewhere at the beginning. Check if it helps.
 
Old 10-24-2004, 06:31 PM   #5
siminone
LQ Newbie
 
Registered: Oct 2004
Posts: 3

Original Poster
Rep: Reputation: 0
thanks for help given Mara.

I managed to get it working with the following command which I got from the sigc++ site:

g++ example1.cc -o eg1 `pkg-config --cflags --libs sigc++-1.2`

The only problem now is figuring out how to compile the Y Win Source code file now I know Sigc++ isn't mucked up!!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GTKmm and SigC stonehurstX11 Programming 4 05-04-2005 02:17 PM
sigc.dll not found fatrandy13 Linux - Software 1 04-02-2005 01:47 PM
sigc++-2.0 paul62 Linux - Software 0 10-01-2004 10:51 AM
problems with lilo.conf and compiling c programs javadi82 Linux - Newbie 3 11-02-2003 03:16 PM
Have anyone experimented problems compiling programs in rh9? mkaman Red Hat 2 10-31-2003 10:41 AM


All times are GMT -5. The time now is 07:06 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration