-   Programming (
-   -   Problems compiling sigc++ programs (

siminone 10-24-2004 06:05 AM

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 -I/usr/include/sigc++-1.0

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

The soucefile is as follows:


// Copyright 1999 Karl Nelson.

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

using namespace SigC;

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

  Signal1<void,const string &> printer;


  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


Mara 10-24-2004 09:15 AM

It's a C++ program, so compile with g++ instead of gcc.

siminone 10-24-2004 02:02 PM

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.

Mara 10-24-2004 02:38 PM

One thing is to add 'using namespace std' somewhere at the beginning. Check if it helps.

siminone 10-24-2004 06:31 PM

thanks for help given Mara.

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

g++ -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!!!

All times are GMT -5. The time now is 04:17 PM.