Unresolved external symbol error - __WinMainCRTStartup

Started by megafiddle, August 20, 2011, 08:13:39 PM

Previous topic - Next topic

megafiddle

Greetings all.

I am trying to switch over to Pelles from Borland 4.52.

Having some problems getting started. A win32 program that ran fine with
the Borland IDE is giving me the following build errors:

POLINK: warning: No object files specified; libraries used.
POLINK: error: Unresolved external symbol '__WinMainCRTStartup'.
POLINK: fatal error: 1 unresolved external(s).

My entry point is WinMain.
I probably didn't set up something properly. What should I begin checking?

Stefan Pendl

Seems you started a console project, where you need a Windows application project.
---
Stefan

Proud member of the UltraDefrag Development Team

CommonTater

Go into....

Project -> Project options -> Compiler and check "Enable Microsoft extensions" and "Enable Pelles C extensions" ....

Also as Stephan pointed ou  if you have WinMain instead of Main ... make sure your linker (same dialog) is set to subsystem windows ... not console. 

The best way to prevent these little annoyances is  to use the file-> new -> project and pick a project type from  the dialog there.  It will preset many of these switches for you.

megafiddle

It was a windows32 application, not console.

"Enable Microsoft extensions" and "Enable Pelles C extensions" didn't make any difference.

Using  "file-> new -> project" seems to create some kind of "starter program".
How do I get my my source file in there instead? I can't seem to find anything in
the menus to do that.

CommonTater

#4
Quote from: megafiddle on August 20, 2011, 10:21:08 PM
It was a windows32 application, not console.

"Enable Microsoft extensions" and "Enable Pelles C extensions" didn't make any difference.

Using  "file-> new -> project" seems to create some kind of "starter program".
How do I get my my source file in there instead? I can't seem to find anything in
the menus to do that.


Go back into the new project dialog... scroll down... You will see "win32 program" ... not the wizard... start a project there, set the paths etc as you need them... then when POIDE shows you the empty project, exit POIDE, copy your files into the project folder and then relaunch POIDE and right click on the empty project in the treeview... you will see, "Add files to project"... select your files and add them.

You may have to make some changes in the project options pane, but it should work.

The extensions should be enabled... and, depending on your code you may need "Define Compatibility Names" as well.

I'm thinking you're tripping over differences between IDEs and settings... be patient, Pelles C does take a little bit of getting used to.

Also note that Borland has some pretty non-standard stuff in their libraries and compiler... so you may have to do some fixing up on your code to get it to work...

megafiddle

Ok, it's getting there.

The Win32 Application Wizard was truncated in the new project window and looked like
a Win32 application (Win32 Applicati...), so I was selecting the wizard.

I have the right one now, Win32 Program EXE.
Still same error, though.

This is apparently not a common problem. Do others normally use something other than WinMain?

CommonTater

#6
You're right it's not a common error and I think I've only seen it once...

Open your .ppj (project) file in notepad and  copy and paste it in a message here, please...

One other thing to try... Project -> Update all depencencies...

The error isn't because of WinMain... it's in the startup code ... the linker may not be finding your libraries folder...  If you open Tools -> Options -> Folders and click "use defaults"  does it go away?







megafiddle

#7
I appreciate the help. I'm going to try the latest version of Pelles again.
I've already tried them both, though.

Tools -> Options -> Folders and click "use defaults" didn't work either.

project file:

#
# PROJECT FILE generated by "Pelles C for Windows, version 6.00".
# WARNING! DO NOT EDIT THIS FILE.
#

POC_PROJECT_VERSION = 6.00#
POC_PROJECT_TYPE = 0#
POC_PROJECT_OUTPUTDIR = output#
POC_PROJECT_RESULTDIR = .#
POC_PROJECT_ARGUMENTS = #
CC = pocc.exe#
AS = poasm.exe#
RC = porc.exe#
LINK = polink.exe#
SIGN = posign.exe#
CCFLAGS = -Tx86-coff -Ot -W1 -Ze -Gz#
ASFLAGS = -AIA32 -Gz#
RCFLAGS = -r#
LINKFLAGS = -machine:ix86 -subsystem:windows kernel32.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib advapi32.lib delayimp.lib#
SIGNFLAGS = -location:CU -store:MY -timeurl:http://timestamp.verisign.com/scripts/timstamp.dll -errkill#
INCLUDE = $(PellesCDir)\Include\Win;$(PellesCDir)\Include#
LIB = $(PellesCDir)\Lib\Win;$(PellesCDir)\Lib#

mbz10.exe:
   $(LINK) $(LINKFLAGS) -out:"$@" $**

.OTHERFILES: \
   E:\C\mandelzoom\mbz18b.cpp

.SILENT:

Stefan Pendl

Quote from: megafiddle on August 21, 2011, 08:30:43 AM
.OTHERFILES: \
   E:\C\mandelzoom\mbz18b.cpp

Are you sure that this file is a pure ANSI C file and not a real C++ file?

C is not C++, but C++ allows using C code through the extern C method.

A pure C compiler like PellesC does not support C++.
---
Stefan

Proud member of the UltraDefrag Development Team

megafiddle

Aside from using the API and GDI functions, structures, etc, I believe everything is C.
( I assume the API and GDI stuff is C also ).

It will not compile at all with a .c extension - pages of errors.

Compiles Ok with a .cpp extension.

Stefan Pendl

Quote from: megafiddle on August 21, 2011, 10:37:26 AM
Compiles Ok with a .cpp extension.

So Borland supports C++, whereas Pelles does not support C++.

Your source code is not C, but C++, which is a different language and has nothing to do with C.
---
Stefan

Proud member of the UltraDefrag Development Team

megafiddle

That does seem to be the problem.

I removed all the application specific code, and it worked.

With just WinMain and the callback procedure, no problems.

What am I looking for in my code?
I've never used C++, at least not intentionally.

Could it be definition or declaration?

Stefan Pendl

Quote from: megafiddle on August 21, 2011, 11:17:17 AM
What am I looking for in my code?
I've never used C++, at least not intentionally.

Could it be definition or declaration?

Without the code it is hard to tell what must be done to make this work.

Any way to attach the source code or the entire project?

You can use Project => ZIP files... to create an archive containing all the project files.
---
Stefan

Proud member of the UltraDefrag Development Team

megafiddle

#13
I have no doubt I'm doing something wrong.

The source file is about 1000 lines. But here are the global declarations to start with.
I am still working on parts as I can still run it with Borland. I can post more or all of it,
as soon as I get some minor bugs out (not related to this problem). Just in case someone
wants to try compiling and running it, better to have it bug free.

I moved the declarations to an attachment to save space here.

Stefan Pendl

Quote from: megafiddle on August 21, 2011, 02:41:03 PM
The source file is about 1000 lines. But here are the global declarations to start with.
I am still working on parts as I can still run it with Borland. I can post more or all of it,
as soon as I get some minor bugs out (not related to this problem). Just in case someone
wants to try compiling and running it, better to have it bug free.

Attach the source code to the message and don't post it inside the message.

Bugs or not is irrelevant, since you are not able to compile it anyways, you are not getting to the stage of running the program.
---
Stefan

Proud member of the UltraDefrag Development Team