![]() ![]() ![]() The full output from GCC is: Using built-in specs.ĬOLLECT_LTO_WRAPPER=/home/paul/xc/libexec/gcc/mips/4.9.2/lto-wrapperĬonfigured with: /home/paul/xc/mips/tmp/gcc-4.9.2/configure -prefix=/home/paul/xc -target=mips -enable-languages=c -with-newlib -without-isl -without-cloogs -disable-threads -disable-libssp -disable-libgomp -disable-libmudflap I get the same error regardless of whether I run the cross compiler under Linux (Ubuntu 14.10) or Cygwin (Windows 8). I can compile a simpler program which simply returns zero, so it’s not the case that the entire toolchain is broken, presumably just the standard library linking (I’m using newlib 2.2.0-1). I’m assuming this is a problem with the linker, as I’d expect the process to fail earlier if for example stdio.h couldn’t be found on the search path. ![]() (.text+0x24): undefined reference to `printf'Ĭollect2: error: ld returned 1 exit status However, I’m getting the following error: /tmp/ccW5mHJu.o: In function `main': Printf(" digite a nota 2 do aluno %i: ",j+1) įloat calculo(float nota1,float nota2)/xc/bin/mips-gcc -v hello.c Printf(" digite a nota 1 do aluno %i: ",j+1) Printf(" digite o RA do aluno %i: ",j+1) Printf(" 3 - calcular Media da turma n") Printf(" medias calculadas com sucesso! n") Printf(" entrada de dados cadastrada com sucesso! n") I checked the code and I didn’t find a mistake, what could it be? #include Galera I am making a code here and this giving 2 errors that are: error: ld returned 1 exit status I’m pretty sure «no such file or directory» is from not finding the dynamic linker, but there may be other reasons, too - I’m not familiar with a 64-bit system… gotta upgrade my hardware, one of these days!ĭon’t worry about «bothering» me! I’m not forced to reply unless I feel like it… Linux has got lots of error messages - every so often it coughs up one I haven’t seen before. com file or a Windows executable, say) produces «can’t execute binary file», from what I’ve seen. Maybe this is one…įWIW, a really «invalid» executable (a dos. My experience is that it works fine without it - I haven’t found a case yet where it doesn’t, but I keep expecting to. It is reasonable to think that we «need» that startup code before «printf» or other libc (or other dynamic library) functions are going to work correctly. C expects to run that «startup» code which contains the «_start» label and calls «main». This isn’t the way we’re «supposed» to do it. That’s a very confusing error, «no such file or directory», when you can see the file right there! I don’t recall who tipped me off to use the «-I» switch - it isn’t something you’re likely to «figure out» or read in the Friendly Manual. ![]() That’s the parameter we should be using to the «-I» switch - I told you «-I/lib/ld-linux.so.2» but that might not be right for your system… maybe /lib32/… or something(?). That’s the «interpreter» or «dynamic linker» which allows your program to find «printf», or anything else we’re using from a dynamic library. I suspect, on a 64-bit system, you probably have two versions - one for 64-bit and one for 32-bit. See if you can find such a file, or similar - version number might be different. That’s the file that’s not being found, I strongly suspect. Not too far from the beginning of the file (244 bytes?), you should see something like «lib/ld-linux.so.2». A hex-editor would be good, but an ordinary text editor will do. If «-nostartfiles» isn’t working for you, you can always use «main» instead of «_start». Since the location of the proper interpreter/dynamic loader may differ on your system, it may be easier to let gcc invoke the linker. «print2» is a couple bytes smaller, but I think they’re basically the same thing. Ld -o print2 print_c.o print_asm.o -lc -I/lib/ld-linux.so.2 I forgot to mention that until I actually tried it. In addition to -lc, I need to tell ld to look for «lib/ld-linux.so.2″… The «-I»(interpreter) or «-dynamic_linker» switch. ld, by default, looks for «/lib/ld-linux.so.1″… which doesn’t exist. Gcc -o print print_c.c print_asm.o -nostartfilesĪt this point, if I do what I told you (-lc), in spite of producing the output file, when I try to run it, I get «no such file of directory»(!). (I renamed the files slightly) First, assemble the. I can get a working program out of your two files in two ways. I’m running a 32-bit system, so I don’t need «-m32» or «-melf_i386». Possibly a «cascading error» from the «_start» error? I don’t know what the problem is with not being able to find «print» or «_print». The «multiple definition of ‘_start'» sounds like you’ve got that «C startup» file linked in. ![]()
0 Comments
Leave a Reply. |