Page 1 of 1
Cygwin's gcc doesn't generate output files [SOLVED]
Posted: Sat Jul 14, 2007 6:05 pm
by AndrewAPrice
I've switched from DJGPP to Cygwin (for ELF support without recompiling binutils) and I've tried
Code: Select all
g++ -c main.cpp -nostdlib -fno-builtin -fno-rtti -fno-exceptions
and
Code: Select all
gcc -c main.cpp -nostdlib -fno-builtin -fno-rtti -fno-exceptions
Neither produce any errors or warning messages, neither do they they produce any sort of output file in my working directory.
Posted: Sat Jul 14, 2007 6:45 pm
by frank
Well it should produce a main.o file. Anyways I don't think that cygwin GCC supports elf right out of the box. I think you will have to build a cross compiler.
Posted: Sun Jul 15, 2007 12:07 am
by AndrewAPrice
even just
prints nothing to the console, nor does it generate any files.
Posted: Sun Jul 15, 2007 12:23 am
by AndrewAPrice
I worked it out.. I have to open the shell manually and then cd to /cygdrive/c/[window's path]
EDIT: This is getting complicated.. How do other people who use Cygwin do it?
Posted: Sun Jul 15, 2007 2:54 am
by AndrewAPrice
Okay, I have it.. I have my build.bat, which calls bash with my shell script. My shell script cd's (in Cygwin format) to my where my .cpp files are it builds fine. I've also notice I don't need to add _ to my assembly labels anymore (I can just use "call main" instead of "call _main" and "extern ICanSeeThisFromC" instead of "extern _ICanSeeThisFromC").
Posted: Mon Jul 16, 2007 12:37 am
by os64dev
copy the cygwin1.dll from <cygwin>/bin to windows directory and problem is gone. I have had the problem also several times. Another solution is to remove the cygwin1.dll from the windows directory. If it exists there.
Posted: Tue Jul 17, 2007 6:01 am
by df
easier than messing with cygwin dll's, just run the cygwin shell., its not that hard.
Posted: Tue Jul 17, 2007 3:28 pm
by pcmattman
I think they want to run these in a batch program, which wouldn't be able to use the Cygwin shell.
A better idea is to have at the start of your batch script
Code: Select all
set PATH=[i]path to cygwin dlls[/i];%PATH%
That way you don't have to change your environment or copy the DLL into your Windows directory.
I'm pretty sure (80%) this works.
Re: Cygwin's gcc doesn't generate output files
Posted: Tue Jul 17, 2007 5:21 pm
by jnc100
MessiahAndrw wrote:I've switched from DJGPP to Cygwin (for ELF support without recompiling binutils)
The gcc that comes with cygwin produces pe-i386 object files. The binutils can understand various object types (including elf) as input, but can only target the i386pe emulation. You need a cross compiler to target elf from cygwin.
pcmattman wrote:A better idea is to have at the start of your batch script
Code: Select all
set PATH=[i]path to cygwin dlls[/i];%PATH%
Or just add it to your default windows path from system properties, environment variables. I think its under 'advanced system settings' if you're on vista. Works for me. [hint]You could even use a makefile instead of a batch file.[/hint]
Regards,
John.
Re: Cygwin's gcc doesn't generate output files
Posted: Tue Jul 17, 2007 9:19 pm
by pcmattman
jnc100 wrote:Or just add it to your default windows path from system properties, environment variables.
Once you start doing that for multiple compiler setups it starts getting dangerous. I used to do that for DJGPP and on my switch to Cygwin I kept calling the DJGPP binaries thanks to the PATH setup.
I think it is a good idea but for maximum portability (and relative ease of use) it's easier to do it via a batch/make file.
Posted: Wed Jul 18, 2007 1:40 am
by AndrewAPrice
I've added [SOLVED] to the subject, since people are still posting here and I've solved the problem.