NO

Author Topic: Unresolved external symbol error - __WinMainCRTStartup  (Read 12938 times)

megafiddle

  • Guest
Unresolved external symbol error - __WinMainCRTStartup
« on: August 20, 2011, 08:13:39 pm »
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?
« Last Edit: August 20, 2011, 08:44:59 pm by megafiddle »

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 580
    • Homepage
Re: Unresolved external symbol error - __WinMainCRTStartup
« Reply #1 on: August 20, 2011, 09:29:44 pm »
Seems you started a console project, where you need a Windows application project.
---
Stefan

Proud member of the UltraDefrag Development Team

CommonTater

  • Guest
Re: Unresolved external symbol error - __WinMainCRTStartup
« Reply #2 on: August 20, 2011, 09:57:44 pm »
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

  • Guest
Re: Unresolved external symbol error - __WinMainCRTStartup
« Reply #3 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.

CommonTater

  • Guest
Re: Unresolved external symbol error - __WinMainCRTStartup
« Reply #4 on: August 20, 2011, 11:31:31 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...
« Last Edit: August 20, 2011, 11:34:52 pm by CommonTater »

megafiddle

  • Guest
Re: Unresolved external symbol error - __WinMainCRTStartup
« Reply #5 on: August 21, 2011, 12:11:17 am »
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

  • Guest
Re: Unresolved external symbol error - __WinMainCRTStartup
« Reply #6 on: August 21, 2011, 02:55:44 am »
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?






« Last Edit: August 21, 2011, 03:00:05 am by CommonTater »

megafiddle

  • Guest
Re: Unresolved external symbol error - __WinMainCRTStartup
« Reply #7 on: August 21, 2011, 08:30:43 am »
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:
« Last Edit: August 21, 2011, 09:17:40 am by megafiddle »

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 580
    • Homepage
Re: Unresolved external symbol error - __WinMainCRTStartup
« Reply #8 on: August 21, 2011, 09:36:19 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

  • Guest
Re: Unresolved external symbol error - __WinMainCRTStartup
« Reply #9 on: August 21, 2011, 10:37:26 am »
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.

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 580
    • Homepage
Re: Unresolved external symbol error - __WinMainCRTStartup
« Reply #10 on: August 21, 2011, 11:07:25 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

  • Guest
Re: Unresolved external symbol error - __WinMainCRTStartup
« Reply #11 on: August 21, 2011, 11:17:17 am »
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?

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 580
    • Homepage
Re: Unresolved external symbol error - __WinMainCRTStartup
« Reply #12 on: August 21, 2011, 01:22:26 pm »
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

  • Guest
Re: Unresolved external symbol error - __WinMainCRTStartup
« Reply #13 on: August 21, 2011, 02:41:03 pm »
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.
« Last Edit: August 22, 2011, 06:07:15 am by megafiddle »

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 580
    • Homepage
Re: Unresolved external symbol error - __WinMainCRTStartup
« Reply #14 on: August 21, 2011, 03:20:11 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