Cygwin's gcc doesn't generate output files [SOLVED]

Programming, for all ages and all languages.
Post Reply
User avatar
AndrewAPrice
Member
Member
Posts: 2303
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Cygwin's gcc doesn't generate output files [SOLVED]

Post 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.
Last edited by AndrewAPrice on Wed Jul 18, 2007 1:39 am, edited 1 time in total.
My OS is Perception.
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post 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.
User avatar
AndrewAPrice
Member
Member
Posts: 2303
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

even just

Code: Select all

gcc main.cpp
prints nothing to the console, nor does it generate any files.
My OS is Perception.
User avatar
AndrewAPrice
Member
Member
Posts: 2303
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post 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?
My OS is Perception.
User avatar
AndrewAPrice
Member
Member
Posts: 2303
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post 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").
My OS is Perception.
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post 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.
Author of COBOS
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Post by df »

easier than messing with cygwin dll's, just run the cygwin shell., its not that hard.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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.
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Re: Cygwin's gcc doesn't generate output files

Post 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.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: Cygwin's gcc doesn't generate output files

Post 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.
User avatar
AndrewAPrice
Member
Member
Posts: 2303
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

I've added [SOLVED] to the subject, since people are still posting here and I've solved the problem.
My OS is Perception.
Post Reply