Can't compile anything

Discussions Regarding Software

Moderator: Moderators

knightlain
Baby Hen
Posts: 18
Joined: Mon Feb 07, 2011 16:43

Can't compile anything

Post by knightlain » Mon Feb 21, 2011 5:12

Well, I am on Sabayon x86-64, and my problem is that after installing certain packages I can't compile anything because I have errors like this support.h:21: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
support.h:26: aviso: el tipo de dato por defecto es ‘int’ en la declaración de ‘gchar’
support.h:26: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
support.h:34: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
support.h:38: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
support.h:41: error: expected ‘)’ before ‘*’ token
support.c:19: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
support.c:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
support.c:49: aviso: el tipo de dato por defecto es ‘int’ en la declaración de ‘gchar’
support.c:49: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
support.c:56: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
support.c:76: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
support.c:100: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token

What could be, it happens me with all my packages.

wolfden
Sharecropper
Posts: 9051
Joined: Sat Jan 14, 2006 0:55
Location: Midwest USA
Contact:

Re: Can't compile anything

Post by wolfden » Mon Feb 21, 2011 5:49

gonna need more info, what commands are you using? what package manager? what certain packages did you install to cause problems? What version of Sabayon?

knightlain
Baby Hen
Posts: 18
Joined: Mon Feb 07, 2011 16:43

Re: Can't compile anything

Post by knightlain » Tue Feb 22, 2011 4:13

I installed mostly development packages buy using Entropy, I am on sabayon 5.4 and also, I have sabayon-limbo, when I try to compile anything, this error occurs

knightlain
Baby Hen
Posts: 18
Joined: Mon Feb 07, 2011 16:43

Re: Can't compile anything

Post by knightlain » Thu Feb 24, 2011 6:53

Sorry for the double post but I have no idea about what to do, what I have found, is that when using g++ I can compile and also, when I use gcc on codeblocks it works, but it doesn't on console mode.

wolfden
Sharecropper
Posts: 9051
Joined: Sat Jan 14, 2006 0:55
Location: Midwest USA
Contact:

Re: Can't compile anything

Post by wolfden » Thu Feb 24, 2011 8:20

you haven't provided enough info for anyone to help

micia
Sagely Hen
Posts: 2718
Joined: Wed Nov 26, 2008 16:41
Contact:

Re: Can't compile anything

Post by micia » Thu Feb 24, 2011 19:26

As wolfden said, just provide a simple c file with some code that gives you problems and specify exactly the commands you run to compile it with their output, otherwise it could be anything, from a corrupted installation, to an error in the commands you are running, to a gremlin that hides in the case of your PC :mrgreen:

knightlain
Baby Hen
Posts: 18
Joined: Mon Feb 07, 2011 16:43

Re: Can't compile anything

Post by knightlain » Thu Feb 24, 2011 23:44

An example code

#include <iostream>

using namespace std;

int main()
{
cout << "This is a test" << endl;
return 0;
}
}/tmp/ccD7usVZ.o: In function `main':
/home/knightlain/Proyectos/Programacion/lachicaquemegusta/main.cpp:7: undefined reference to `std::cout'
/home/knightlain/Proyectos/Programacion/lachicaquemegusta/main.cpp:7: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/home/knightlain/Proyectos/Programacion/lachicaquemegusta/main.cpp:7: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/home/knightlain/Proyectos/Programacion/lachicaquemegusta/main.cpp:7: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccD7usVZ.o: In function `__static_initialization_and_destruction_0':
/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.4/include/g++-v4/iostream:72: undefined reference to `std::ios_base::Init::Init()'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.4/include/g++-v4/iostream:72: undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccD7usVZ.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld devolvió el estado de salida 1

It throws me an error when I try to compile a c++ file, I think it should not, and it happens that when I compile with codeblcoks there are no problems. I think I need to fix so I can use emerge to install and compile portage files.

micia
Sagely Hen
Posts: 2718
Joined: Wed Nov 26, 2008 16:41
Contact:

Re: Can't compile anything

Post by micia » Fri Feb 25, 2011 0:13

here is what I do:

Code: Select all

[email protected] ~/test $ cat main.cpp
#include <iostream>

using namespace std;

int main()
{
cout << "This is a test" << endl;
return 0;
}

[email protected] ~/test $ g++ main.cpp -o test
[email protected] ~/test $ ./test
This is a test
It all seems good to me, isn't it?

knightlain
Baby Hen
Posts: 18
Joined: Mon Feb 07, 2011 16:43

Re: Can't compile anything

Post by knightlain » Fri Feb 25, 2011 1:00

It works with g++ but it doesn't in Gcc, by the way, here is my package list.
Last edited by knightlain on Fri Feb 25, 2011 1:11, edited 1 time in total.

micia
Sagely Hen
Posts: 2718
Joined: Wed Nov 26, 2008 16:41
Contact:

Re: Can't compile anything

Post by micia » Fri Feb 25, 2011 1:09

GCC should not be used directly to compile C++ programs, since it can compile the code but it can't link it. GCC is called by G++ as needed to compile your sources.

Post Reply