Ver Mensaje Individual
  #4 (permalink)  
Antiguo 20/11/2012, 03:08
Avatar de RsG
RsG
 
Fecha de Ingreso: febrero-2008
Mensajes: 16
Antigüedad: 16 años, 2 meses
Puntos: 0
Respuesta: Fallos a la hora de coimpilar y enlazar archivos con g++

Cita:
Iniciado por Fw190 Ver Mensaje
Punto.h: Has puesto

#ifndef __EDI_PUNTO_H_
#define __EDI_PUNTO_H_

al principio, para evitar redefiniciones. Es correcto, pero es que luego lo vuelves a poner al principio de programa.cc, con lo que, al compilar, cuando llega a #include <punto.h>, te descarta la definición de la clase punto. Elimina esas dos líneas de programa.cc, y a ver qué errores te da ahora al compilar.

Saludos,
Eliminando lo que me dices tu, al menos ahora me salen otros tipos de errores a la hora de compilar Programa.cc aunque es un poco locura el resultado, solo puedo copiar una pequeña parte ya que son infinidad de errores

Código:
./Escritorio/programa.cc:18:10: nota:   no se puede convertir ‘a’ (tipo ‘punto’) al tipo ‘const char*’
In file included from /usr/include/c++/4.7/iostream:40:0,
                 from ./Escritorio/programa.cc:9:
/usr/include/c++/4.7/ostream:528:5: nota: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const char*)
/usr/include/c++/4.7/ostream:528:5: nota:   falló la deducción/sustitución del argumento de plantilla:
./Escritorio/programa.cc:18:10: nota:   no se puede convertir ‘a’ (tipo ‘punto’) al tipo ‘const char*’
In file included from /usr/include/c++/4.7/iostream:40:0,
                 from ./Escritorio/programa.cc:9:
/usr/include/c++/4.7/ostream:541:5: nota: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const signed char*)
/usr/include/c++/4.7/ostream:541:5: nota:   falló la deducción/sustitución del argumento de plantilla:
./Escritorio/programa.cc:18:10: nota:   no se puede convertir ‘a’ (tipo ‘punto’) al tipo ‘const signed char*’
In file included from /usr/include/c++/4.7/iostream:40:0,
                 from ./Escritorio/programa.cc:9:
/usr/include/c++/4.7/ostream:546:5: nota: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const unsigned char*)
/usr/include/c++/4.7/ostream:546:5: nota:   falló la deducción/sustitución del argumento de plantilla:
./Escritorio/programa.cc:18:10: nota:   no se puede convertir ‘a’ (tipo ‘punto’) al tipo ‘const unsigned char*’
usuario@ubuntu:~$ clear

usuario@ubuntu:~$ g++ ./Escritorio/programa.cc -I ./Escritorio/
In file included from ./Escritorio/punto.h:2:0,
                 from ./Escritorio/programa.cc:11:
./Escritorio/spair.h:5:7: error: redefinición de ‘class spair<T, U>’
In file included from ./Escritorio/programa.cc:10:0:
./Escritorio/spair.h:5:7: error: definición previa de ‘class spair<T, U>’
./Escritorio/programa.cc: En la función ‘int main()’:
./Escritorio/programa.cc:18:10: error: no hay coincidencia para ‘operator<<’ en ‘std::cout << a’
./Escritorio/programa.cc:18:10: nota: los candidatos son:
In file included from /usr/include/c++/4.7/iostream:40:0,
                 from ./Escritorio/programa.cc:9:
/usr/include/c++/4.7/ostream:106:7: nota: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [con _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/include/c++/4.7/ostream:106:7: nota:   no hay una conversión conocida para el argumento 1 de ‘punto’ a ‘std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&) {aka std::basic_ostream<char>& (*)(std::basic_ostream<char>&)}’
/usr/include/c++/4.7/ostream:115:7: nota: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ios_type& (*)(std::basic_ostream<_CharT, _Traits>::__ios_type&)) [con _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>; std::basic_ostream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]
/usr/include/c++/4.7/ostream:115:7: nota:   no hay una conversión conocida para el argumento 1 de ‘punto’ a ‘std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&) {aka std::basic_ios<char>& (*)(std::basic_ios<char>&)}’
/usr/include/c++/4.7/ostream:125:7: nota: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [con _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/include/c++/4.7/ostream:125:7: nota:   no hay una conversión conocida para el argumento 1 de ‘punto’ a ‘std::ios_base& (*)(std::ios_base&)’
/usr/include/c++/4.7/ostream:164:7: nota: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [con _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/include/c++/4.7/ostream:164:7: nota:   no hay una conversión conocida para el argumento 1 de ‘punto’ a ‘long int’
/usr/include/c++/4.7/ostream:168:7: nota: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [con _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/include/c++/4.7/ostream:168:7: nota:   no hay una conversión conocida para el argumento 1 de ‘punto’ a ‘long unsigned int’
/usr/include/c++/4.7/ostream:172:7: nota: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [con _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/include/c++/4.7/ostream:172:7: nota:   no hay una conversión conocida para el argumento 1 de ‘punto’ a ‘bool’
In file included from /usr/include/c++/4.7/ostream:607:0,
                 from /usr/include/c++/4.7/iostream:40,
                 from ./Escritorio/programa.cc:9:
/usr/include/c++/4.7/bits/ostream.tcc:93:5: nota: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [con _CharT = char; _Traits = std::char_traits<char>]
/usr/include/c++/4.7/bits/ostream.tcc:93:5: nota:   no hay una conversión conocida para el argumento 1 de ‘punto’ a ‘short int’
In file included from /usr/include/c++/4.7/iostream:40:0,
                 from ./Escritorio/programa.cc:9:
.
.
.
.
.
.
.
.
Estoy trabajando con estos nuevos errores a ver si soy capaz de solucionarlos, el problema es que la compilación de Spair.cc también falla

Código:
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o: En la función `_start':
(.text+0x20): referencia a `main' sin definir
collect2: error: ld devolvió el estado de salida 1
Y la de Punto.cc también

Código:
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o: En la función `_start':
(.text+0x20): referencia a `main' sin definir
/tmp/ccxLf0AK.o: En la función `punto::punto(int, int)':
punto.cc:(.text+0x1a): referencia a `spair<int, int>::spair()' sin definir
punto.cc:(.text+0x2b): referencia a `spair<int, int>::SetAbscisa(int)' sin definir
punto.cc:(.text+0x3c): referencia a `spair<int, int>::SetOrdenada(int)' sin definir
collect2: error: ld devolvió el estado de salida 1
Siempre esas referencias que no se como quitar de ahí.

Gracias por la ayuda, soy bastante novato en esto y sigo trabajando en aprender!