Jump to content
chrisjn52

Cygwin compilation problem

Recommended Posts

Yes, I want to be able to compile for Win32 but I have been putting off due to imminent replacement of my aging PC. However, I decided to give it a try anyway and loaded the required MingW & CygWin toolchains and followed the guide here but I get this error message:

c:\Temp\Win32Demo\Demo>make
      0 [main] make 5128 child_info_fork::abort: c:\cygwin\bin\cygiconv-2.dll: L
oaded to different address: parent(0x2F0000) != child(0x440000)
make: fork: Resource temporarily unavailable

Any ideas?

Share this post


Link to post
Share on other sites

This looks like a cygwin dll version problem. Either you have a mismatch between the compiler or make and your cygwin dll versions, or the various dll version do not match.

Look for old left over versions of the cygwin dlls in your windows and system32 directories.

Share this post


Link to post
Share on other sites

I'm using Win7. I checked for additional files in Windows folders but none were found. However, I found the answer in this post here and the make progresses further after using the the following rebaseall command in dash:

$ ./rebaseall -b 0x5fe50000

 The make then failed with the following:

Compiling ../uGFX/src/gfx.c
make: i686-pc-mingw32-gcc: Command not found

This was fixed by renaming the compiler executable name in the Makefile thus:

#ARCH     = i686-pc-mingw32-
ARCH     = i686-w64-mingw32-

Unfortunately the Linker now fails as shown below:

Linking .build/Demo.exe
/cygdrive/c/Users/Chris/AppData/Local/Temp/cc9tSOjS.ltrans0.ltrans.o:cc9tSOjS.lt
rans0.o:(.text+0x2380): multiple definition of `main'
/usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/libmingw32.a(lib32_libmingw32_a-
crt0_c.o):/usr/src/debug/mingw64-i686-runtime-4.0.6-1/crt/crt0_c.c:17: first defined here
/usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o): In function `main':
/usr/src/debug/mingw64-i686-runtime-4.0.6-1/crt/crt0_c.c:18: undefined reference to `WinMain@16'
collect2: error: ld returned 1 exit status
make: *** [../uGFX/tools/gmake_scripts/compiler_gcc.mk:284: .build/Demo.exe] Error 1

Could this issue be related to my Cygwin/MingW installation in some way?

Share this post


Link to post
Share on other sites

You need to add the flags to the compiler that tell it it is a console application. I think it is something like "--console" but i cant remember the specifics. 

The difference between the -pc compiler and the -w compiler is exactly this. The -pc compiler assumes a console application, the -w compiler assumes a windows application.

Unfortunately cygwin has recently stopped supplying the console based compiler.

Share this post


Link to post
Share on other sites

I tried with -mconsole switch to no avail. I'm using GCC 4.9.2 which may be an issue according to this  unless I am mistaken?

$ i686-w64-mingw32-gcc --version
i686-w64-mingw32-gcc (GCC) 4.9.2

How do I downgrade GCC to avoid this, (I have been unsuccessful in finding a package and method thus far).

Share this post


Link to post
Share on other sites

The other way of getting around that linking error is to rename main() to WinMain(). It is your compiler runtime startup that is incorrect (ie the wrong compiler binary for this job). It is looking to create a pure win32 application rather than a console application but the above may enable you to work around it.

It is not a question of the version number of the compiler but rather its builtin runtime support.

By the way, this topic really doesn't belong under "Development and Feedback", it should really have been under the support topic. Now it is here though we will just resolve the problem here.

 

Share this post


Link to post
Share on other sites

I have now managed to compile and link the Demo to a console application which runs perfectly.

In order to get it to work I renamed main() to Winmain(), whereupon it still failed with an undefined reference to `WinMain@16'. After renaming the function back to main() the code then linked without error. 

Incidentally, as you can see from the top post, I intended to reply to Joel in the Spinbox Widget thread in "Support" but I must have posted back to "Development and Feedback" inadvertently

Share this post


Link to post
Share on other sites
2 hours ago, chrisjn52 said:

In order to get it to work I renamed main() to Winmain(), whereupon it still failed with an undefined reference to `WinMain@16'. After renaming the function back to main() the code then linked without error. 

That sounds like a make clean wound have fixed it ;)

 

2 hours ago, chrisjn52 said:

Incidentally, as you can see from the top post, I intended to reply to Joel in the Spinbox Widget thread in "Support" but I must have posted back to "Development and Feedback" inadvertently

Nope, actually I just took that post out of the spinbox widget thread (the first post in this topic was the last one there) and created a new topic out of if because it is in no way related to the spin box widget at all.

Share this post


Link to post
Share on other sites
Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×