Título: Error: Unvalid reference to Publicado por: DeIMachine en 29 Noviembre 2015, 20:28 pm Os paso la captura con el error que me sale:https://gyazo.com/dbe2919a54ef1ecaf995aa200af65bd6 (https://gyazo.com/dbe2919a54ef1ecaf995aa200af65bd6)
Quiero utilizar una funcion de la estructura Tiempo que he creado yo en una biblioteca aparte y me sale que no le hago referencia, no se que debería hacer. Saludos y gracias. Título: Re: Error: Unvalid reference to Publicado por: ivancea96 en 29 Noviembre 2015, 20:38 pm ¿La estructura Tiempo está en el mismo archivo que esMenor?
¿Haces referencia a la otra librería a la hora de linkear? Se necesitan más datos, que encima la imagen la pusiste cortada, y no se ve la linea del comando de linkeo completa. Título: Re: Error: Unvalid reference to Publicado por: DeIMachine en 29 Noviembre 2015, 20:42 pm Si. la funcion esMenor esta en la misma biblioteca que la estructura Tiempo y esta incluida en ella. En la main hago referencia #include <../ModTiempo/tiempo.h>
Título: Re: Error: Unvalid reference to Publicado por: DeIMachine en 29 Noviembre 2015, 20:43 pm Ahora pego todas las bibliotecas
Título: Re: Error: Unvalid reference to Publicado por: DeIMachine en 29 Noviembre 2015, 20:45 pm Este sería el módulo de biblioteca tiempo.
Código
Implemento esta función en otra biblioteca y aquí me salta el error: Código
Título: Re: Error: Unvalid reference to Publicado por: DeIMachine en 29 Noviembre 2015, 20:47 pm Y aquí todos los errores del codigo:
https://gyazo.com/aa039937548ff7355e5262ef0e087e11 (https://gyazo.com/aa039937548ff7355e5262ef0e087e11) Título: Re: Error: Unvalid reference to Publicado por: DeIMachine en 29 Noviembre 2015, 20:56 pm Creo que es porque no inicializo ningun valor.
Título: Re: Error: Unvalid reference to Publicado por: ivancea96 en 29 Noviembre 2015, 21:00 pm No hagas multiples post, edita el último que has hecho.
¿Compilaste el .cpp de la librería? Las librerías se trabajan así: Citar libreria.cpp compilado -> libreria.o main.cpp compilado -> main.o main.o + libreria.o compilados -> main.exe No has puesto más información, así que te dejo eso y ya dirás. Título: Re: Error: Unvalid reference to Publicado por: DeIMachine en 29 Noviembre 2015, 21:20 pm Perdona no me había enterado bien antes, no me aparece tiempo.o creo que no se ha llegado a compilar. Paso la compilacion hasta el error aqui: https://gyazo.com/223ee8af50bcadacdffce56e4e4dca83 (https://gyazo.com/223ee8af50bcadacdffce56e4e4dca83), ¿Qué es lo que puede ocurrir entonces? se compila antes la biblioteca que contiene a la otra??
Esta es toda la compilacion: C:\Windows\system32\cmd.exe /C mingw32-make.exe -j 8 -e -f Makefile "----------Building project:[ ModHerramientas - Debug ]----------" mingw32-make.exe[1]: Entering directory 'C:/Users/Guillermo/Desktop/trabajos/ModHerramientas' mingw32-make.exe[1]: Leaving directory 'C:/Users/Guillermo/Desktop/trabajos/ModHerramientas' mingw32-make.exe[1]: Entering directory 'C:/Users/Guillermo/Desktop/trabajos/ModHerramientas' g++ -c "C:/Users/Guillermo/Desktop/trabajos/ModHerramientas/herramientas.cpp" -g -O0 -Wall -o ./Debug/herramientas.cpp.o -I. -I. g++ -o ./Debug/ModHerramientas @"ModHerramientas.txt" -L. ./Debug/herramientas.cpp.o: In function `ordenar(Tiempo*, int)': C:/Users/Guillermo/Desktop/trabajos/ModHerramientas/herramientas.cpp:21: undefined reference to `esMenor(Tiempo, Tiempo)' ./Debug/herramientas.cpp.o: In function `mostrar(Tiempo)': C:/Users/Guillermo/Desktop/trabajos/ModHerramientas/herramientas.cpp:40: undefined reference to `hora(Tiempo)' C:/Users/Guillermo/Desktop/trabajos/ModHerramientas/herramientas.cpp:40: undefined reference to `hora(Tiempo)' C:/Users/Guillermo/Desktop/trabajos/ModHerramientas/herramientas.cpp:41: undefined reference to `milesima(Tiempo)' C:/Users/Guillermo/Desktop/trabajos/ModHerramientas/herramientas.cpp:41: undefined reference to `segundo(Tiempo)' C:/Users/Guillermo/Desktop/trabajos/ModHerramientas/herramientas.cpp:41: undefined reference to `minuto(Tiempo)' C:/Users/Guillermo/Desktop/trabajos/ModHerramientas/herramientas.cpp:41: undefined reference to `hora(Tiempo)' ./Debug/herramientas.cpp.o: In function `mostrar(Tiempo const*, int)': C:/Users/Guillermo/Desktop/trabajos/ModHerramientas/herramientas.cpp:57: undefined reference to `hora(Tiempo)' C:/Users/Guillermo/Desktop/trabajos/ModHerramientas/herramientas.cpp:57: undefined reference to `hora(Tiempo)' C:/Users/Guillermo/Desktop/trabajos/ModHerramientas/herramientas.cpp:58: undefined reference to `milesima(Tiempo)' C:/Users/Guillermo/Desktop/trabajos/ModHerramientas/herramientas.cpp:58: undefined reference to `segundo(Tiempo)' C:/Users/Guillermo/Desktop/trabajos/ModHerramientas/herramientas.cpp:58: undefined reference to `minuto(Tiempo)' C:/Users/Guillermo/Desktop/trabajos/ModHerramientas/herramientas.cpp:58: undefined reference to `hora(Tiempo)' collect2.exe: error: ld returned 1 exit status mingw32-make.exe[1]: *** [Debug/ModHerramientas] Error 1 mingw32-make.exe: *** [All] Error 2 ModHerramientas.mk:78: recipe for target 'Debug/ModHerramientas' failed mingw32-make.exe[1]: Leaving directory 'C:/Users/Guillermo/Desktop/trabajos/ModHerramientas' Makefile:4: recipe for target 'All' failed ====13 errors, 0 warnings==== Título: Re: Error: Unvalid reference to Publicado por: ivancea96 en 29 Noviembre 2015, 21:26 pm ¿Puedes pasar el makefile?
De todos modos, para que veas el procedimiento: (https://i.gyazo.com/cdf983decbadd606d86f0be7bbf4d313.png) (https://i.gyazo.com/b84791567e6f235284711ceab742059d.png) Título: Re: Error: Unvalid reference to Publicado por: DeIMachine en 29 Noviembre 2015, 21:38 pm Compilando desde consola me salta este error:
https://gyazo.com/6537c560794c390e48b400f9e4bc0842 (https://gyazo.com/6537c560794c390e48b400f9e4bc0842) En el makefile del workspace me pone esto: .PHONY: clean All All: @echo "----------Building project:[ ModHerramientas - Debug ]----------" @cd "ModHerramientas" && "$(MAKE)" -f "ModHerramientas.mk" clean: @echo "----------Cleaning project:[ ModHerramientas - Debug ]----------" @cd "ModHerramientas" && "$(MAKE)" -f "ModHerramientas.mk" clean Y este es el mk de herramientas project: ## ## Auto Generated makefile by CodeLite IDE ## any manual changes will be erased ## ## Debug ProjectName :=ModHerramientas ConfigurationName :=Debug WorkspacePath := "C:\Users\Guillermo\Desktop\trabajos" ProjectPath := "C:\Users\Guillermo\Desktop\trabajos\ModHerramientas" IntermediateDirectory :=./Debug OutDir := $(IntermediateDirectory) CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=Guillermo Date :=29/11/2015 CodeLitePath :="C:\Program Files\CodeLite" LinkerName :=g++ SharedObjectLinkerName :=g++ -shared -fPIC ObjectSuffix :=.o DependSuffix :=.o.d PreprocessSuffix :=.o.i DebugSwitch :=-gstab IncludeSwitch :=-I LibrarySwitch :=-l OutputSwitch :=-o LibraryPathSwitch :=-L PreprocessorSwitch :=-D SourceSwitch :=-c OutputFile :=$(IntermediateDirectory)/$(ProjectName) Preprocessors := ObjectSwitch :=-o ArchiveOutputSwitch := PreprocessOnlySwitch :=-E ObjectsFileList :="ModHerramientas.txt" PCHCompileFlags := MakeDirCommand :=makedir RcCmpOptions := RcCompilerName :=windres LinkOptions := IncludePath := $(IncludeSwitch). $(IncludeSwitch). IncludePCH := RcIncludePath := Libs := ArLibs := LibPath := $(LibraryPathSwitch). ## ## Common variables ## AR, CXX, CC, AS, CXXFLAGS and CFLAGS can be overriden using an environment variables ## AR := ar rcus CXX := g++ CC := gcc CXXFLAGS := -g -O0 -Wall $(Preprocessors) CFLAGS := -g -O0 -Wall $(Preprocessors) ASFLAGS := AS := as ## ## User defined environment variables ## CodeLiteDir:=C:\Program Files\CodeLite Objects0=$(IntermediateDirectory)/herramientas.cpp$(ObjectSuffix) $(IntermediateDirectory)/main.cpp$(ObjectSuffix) Objects=$(Objects0) ## ## Main Build Targets ## .PHONY: all clean PreBuild PrePreBuild PostBuild MakeIntermediateDirs all: $(OutputFile) $(OutputFile): $(IntermediateDirectory)/.d $(Objects) @$(MakeDirCommand) $(@D) @echo "" > $(IntermediateDirectory)/.d @echo $(Objects0) > $(ObjectsFileList) $(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions) MakeIntermediateDirs: @$(MakeDirCommand) "./Debug" $(IntermediateDirectory)/.d: @$(MakeDirCommand) "./Debug" PreBuild: ## ## Objects ## $(IntermediateDirectory)/herramientas.cpp$(ObjectSuffix): herramientas.cpp $(IntermediateDirectory)/herramientas.cpp$(DependSuffix) $(CXX) $(IncludePCH) $(SourceSwitch) "C:/Users/Guillermo/Desktop/trabajos/ModHerramientas/herramientas.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/herramientas.cpp$(ObjectSuffix) $(IncludePath) $(IntermediateDirectory)/herramientas.cpp$(DependSuffix): herramientas.cpp @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/herramientas.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/herramientas.cpp$(DependSuffix) -MM "herramientas.cpp" $(IntermediateDirectory)/herramientas.cpp$(PreprocessSuffix): herramientas.cpp @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/herramientas.cpp$(PreprocessSuffix) "herramientas.cpp" $(IntermediateDirectory)/main.cpp$(ObjectSuffix): main.cpp $(IntermediateDirectory)/main.cpp$(DependSuffix) $(CXX) $(IncludePCH) $(SourceSwitch) "C:/Users/Guillermo/Desktop/trabajos/ModHerramientas/main.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/main.cpp$(ObjectSuffix) $(IncludePath) $(IntermediateDirectory)/main.cpp$(DependSuffix): main.cpp @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/main.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/main.cpp$(DependSuffix) -MM "main.cpp" $(IntermediateDirectory)/main.cpp$(PreprocessSuffix): main.cpp @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/main.cpp$(PreprocessSuffix) "main.cpp" -include $(IntermediateDirectory)/*$(DependSuffix) ## ## Clean ## clean: $(RM) -r ./Debug/ El de tiempo: ## ## Auto Generated makefile by CodeLite IDE ## any manual changes will be erased ## ## Debug ProjectName :=ModTiempo ConfigurationName :=Debug WorkspacePath := "C:\Users\Guillermo\Desktop\trabajos" ProjectPath := "C:\Users\Guillermo\Desktop\trabajos\ModTiempo" IntermediateDirectory :=./Debug OutDir := $(IntermediateDirectory) CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=Guillermo Date :=29/11/2015 CodeLitePath :="C:\Program Files\CodeLite" LinkerName :=g++ SharedObjectLinkerName :=g++ -shared -fPIC ObjectSuffix :=.o DependSuffix :=.o.d PreprocessSuffix :=.o.i DebugSwitch :=-gstab IncludeSwitch :=-I LibrarySwitch :=-l OutputSwitch :=-o LibraryPathSwitch :=-L PreprocessorSwitch :=-D SourceSwitch :=-c OutputFile :=$(IntermediateDirectory)/$(ProjectName) Preprocessors := ObjectSwitch :=-o ArchiveOutputSwitch := PreprocessOnlySwitch :=-E ObjectsFileList :="ModTiempo.txt" PCHCompileFlags := MakeDirCommand :=makedir RcCmpOptions := RcCompilerName :=windres LinkOptions := IncludePath := $(IncludeSwitch). $(IncludeSwitch). IncludePCH := RcIncludePath := Libs := ArLibs := LibPath := $(LibraryPathSwitch). ## ## Common variables ## AR, CXX, CC, AS, CXXFLAGS and CFLAGS can be overriden using an environment variables ## AR := ar rcus CXX := g++ CC := gcc CXXFLAGS := -g -O0 -Wall $(Preprocessors) CFLAGS := -g -O0 -Wall $(Preprocessors) ASFLAGS := AS := as ## ## User defined environment variables ## CodeLiteDir:=C:\Program Files\CodeLite Objects0=$(IntermediateDirectory)/tiempo.cpp$(ObjectSuffix) Objects=$(Objects0) ## ## Main Build Targets ## .PHONY: all clean PreBuild PrePreBuild PostBuild MakeIntermediateDirs all: $(OutputFile) $(OutputFile): $(IntermediateDirectory)/.d $(Objects) @$(MakeDirCommand) $(@D) @echo "" > $(IntermediateDirectory)/.d @echo $(Objects0) > $(ObjectsFileList) $(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions) MakeIntermediateDirs: @$(MakeDirCommand) "./Debug" $(IntermediateDirectory)/.d: @$(MakeDirCommand) "./Debug" PreBuild: ## ## Objects ## $(IntermediateDirectory)/tiempo.cpp$(ObjectSuffix): tiempo.cpp $(IntermediateDirectory)/tiempo.cpp$(DependSuffix) $(CXX) $(IncludePCH) $(SourceSwitch) "C:/Users/Guillermo/Desktop/trabajos/ModTiempo/tiempo.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/tiempo.cpp$(ObjectSuffix) $(IncludePath) $(IntermediateDirectory)/tiempo.cpp$(DependSuffix): tiempo.cpp @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/tiempo.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/tiempo.cpp$(DependSuffix) -MM "tiempo.cpp" $(IntermediateDirectory)/tiempo.cpp$(PreprocessSuffix): tiempo.cpp @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/tiempo.cpp$(PreprocessSuffix) "tiempo.cpp" -include $(IntermediateDirectory)/*$(DependSuffix) ## ## Clean ## clean: $(RM) -r ./Debug/ Título: Re: Error: Unvalid reference to Publicado por: ivancea96 en 29 Noviembre 2015, 21:43 pm ¿Tienes la librería agregada al proyecto?
Título: Re: Error: Unvalid reference to Publicado por: DeIMachine en 29 Noviembre 2015, 21:47 pm He pasado lo que acabo de compilar en consola arriba, tengo dos proyectos distintos pero la libreria de una la uso en otro, hay algun problema en eso??
El proyecto modtiempo y modherramientas estan en la misma carpeta, con utilizar esto en el modulo de herrmientas debería de bastar no?? #include "../ModTiempo/tiempo.h" |