NO

Author Topic: POLINK: error: Unresolved external symbol '_WinMainCRTStartup'  (Read 2469 times)

Offline John Z

  • Member
  • *
  • Posts: 973
Hi,

I have four batch files to build a project 1 each for compile, res, and link, then a master batch file to call each file and pass in the required information.  It all works wonderfully well from a command window.  Creates the program just as the IDE does.

Being so successful compiling and creating the final exe I then added the master bat file to the tools in the IDE.  Compile ran fine, the resource builder ran fine but the linker failed with the following message

POLINK: error: Unresolved external symbol '_WinMainCRTStartup' - referenced from '<common>'.

to restate the problem:
When I run the make_link.bat in a command window, not in the IDE, it runs fine creates the exe without any problems.
When I run the same make_link.bat from the IDE Tools menu, it fails for the error.
Code: [Select]
Searching C:\Program Files\PellesC_V12\Lib\Win64\shlwapi.lib
Searching C:\Program Files\PellesC_V12\Lib\Win64\uxtheme.lib
Searching C:\Program Files\PellesC_V12\Lib\Win64\dwmapi.lib
POLINK: error: Unresolved external symbol '_WinMainCRTStartup' - referenced from '<common>'.
POLINK: fatal error: 1 unresolved external(s).

From the command window running make_link.bat it finds crt64.lib -
Code: [Select]
Searching C:\Program Files\PellesC_V12\Lib\Win64\dwmapi.lib
Searching C:\Program Files\PellesC_V12\Lib\crt64.lib

From the IDE Tools it fails if the Tool directly executes make_link.bat and if the make_all.bat calls make_link.bat.  From the command line it works both when executed directly or when executed by make_all.bat.

weird, strange, but not wonderful -

Thoughts?

John Z

Offline Vortex

  • Member
  • *
  • Posts: 975
    • http://www.vortex.masmcode.com
Re: POLINK: error: Unresolved external symbol '_WinMainCRTStartup'
« Reply #1 on: January 23, 2025, 10:03:16 PM »
Hi John,

Could you attach the zip file containing the project files?
Code it... That's all...

Offline John Z

  • Member
  • *
  • Posts: 973
Re: POLINK: error: Unresolved external symbol '_WinMainCRTStartup'
« Reply #2 on: January 23, 2025, 10:22:52 PM »
Hi Vortex,

Can't do that there are over 40 C files and that is more than 2.3Meg, not counting .h files, resources like icons, bmp, and dll's,  etc.

I will try the batch build on a smaller project and see if I get the same issue. 

Thanks, should have done that first, but since it worked I was blinded  :(

John Z
« Last Edit: January 23, 2025, 11:14:48 PM by John Z »

Offline HellOfMice

  • Member
  • *
  • Posts: 360
  • Never be pleased, always improve
Re: POLINK: error: Unresolved external symbol '_WinMainCRTStartup'
« Reply #3 on: January 24, 2025, 02:13:15 AM »
Hi John,


Even with a response file


For linking


Quote
Echo *********************
Echo *** Linking files ***
Echo *********************
"C:\Program Files\PellesC\Bin\polink.exe" @LinkRelease.cmf


Quote
[size=78%]POLINK has the following general syntax:[/size] 
POLINK [ { filespec | @response-file | option } ... ]
 
The filespec argument specifies the name of a library (.lib or .a), a module-definition file (.def), a binary resource file (.res), or an object file (.obj or .o). Wildcards are allowed for all types except a module-definition file.
 
If you have many files or options - use a response file. It is a text file with the same format as the command line. Line feeds are treated as spaces. The name of the response file must be preceded by a @ character on the command line. The response file may use either OEM or UTF-16LE encoding (from version 5.0).
 
An option starts with the / (or -) character, may be given in upper or lower case, and can be one of the following:


I use this when MicroSoft Assembler was called "Masm", I was 30yo.... 35 yars ago I was young and nice... ::)
« Last Edit: January 24, 2025, 02:20:20 AM by HellOfMice »
--------------------------------
Kenavo

Offline John Z

  • Member
  • *
  • Posts: 973
Re: POLINK: error: Unresolved external symbol '_WinMainCRTStartup'
« Reply #4 on: January 24, 2025, 02:22:03 AM »
Hi HellOfMice,

Yes the exact same make_link.bat and the same exact response file.

Works when run in a command window, but does not work when called from the Tool menu.

The compile batch file and resources batch file both work in both cases.

Thanks,
John Z

Offline HellOfMice

  • Member
  • *
  • Posts: 360
  • Never be pleased, always improve
Re: POLINK: error: Unresolved external symbol '_WinMainCRTStartup'
« Reply #5 on: January 24, 2025, 02:25:37 AM »
COpy your batch file in another one
in the first CALL the second or make a COMMAND /C
--------------------------------
Kenavo

Offline John Z

  • Member
  • *
  • Posts: 973
Re: POLINK: error: Unresolved external symbol '_WinMainCRTStartup'
« Reply #6 on: January 24, 2025, 02:58:57 AM »
That is the basic procedure that I do.

case #1 when running using make_all.bat
make_all.bat calls make_objs.bat, then calls make_res.bat, then calls make_link.bat.

case #2 I execute make_objs.bat directly, I execute make_res.bat directly, I execute make_link.bat directly

When doing this from a command windows both cases work perfectly.

When I do it from the IDE tools make_link.bat always fails with the aforementioned error when run itself, and when run by using make_all.bat from Tools.

John Z

Offline John Z

  • Member
  • *
  • Posts: 973
Re: POLINK: error: Unresolved external symbol '_WinMainCRTStartup'
« Reply #7 on: January 24, 2025, 03:35:09 AM »
Partial solution -

When run from the Pelles TOOL IDE the WHERE command is not recognized, when run from a command window it is....easy fix then more testing....

John Z
« Last Edit: January 24, 2025, 04:41:36 AM by John Z »

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2215
Re: POLINK: error: Unresolved external symbol '_WinMainCRTStartup'
« Reply #8 on: January 24, 2025, 05:09:56 AM »
Just ECHO PATH, INCLUDE, LIB to see environment in both cases.

Useful Tool for poide
Code: [Select]
Command: C:\Windows\system32\cmd.exe
Arguments: /C SET

Also check Tools -> Options -> Folders -> Executables
« Last Edit: January 24, 2025, 06:36:53 AM by TimoVJL »
May the source be with you

Offline John Z

  • Member
  • *
  • Posts: 973
Re: POLINK: error: Unresolved external symbol '_WinMainCRTStartup'
« Reply #9 on: January 24, 2025, 06:26:58 AM »
Thanks TimoVJL.

It is fixed, builds both at the command line and from the IDE TOOL .  The problem was entirely due to the WHERE command.  Unfortunately while WHERE is very useful, it is not available when using the IDE for whatever reason.  Needed 5 commands to replace what WHERE does in one command.

However it works now, but another limitation is imposed: no spaces in the object filenames.
I'll probably write a quick replacement for WHERE in C to restore the capability of WHERE.

John Z

 :) :) :)
Got WHERE to work for both IDE and command line by using a separate cmd /c call for it.  Yes all is right again.  These 4 batch files make it very easy to build a program without extensive editing.  When cleaned up I'll post in case anyone else wishes to make use of them.  AFTER MORE TESTING of course.
 
« Last Edit: January 24, 2025, 06:43:52 AM by John Z »

Offline HellOfMice

  • Member
  • *
  • Posts: 360
  • Never be pleased, always improve
Re: POLINK: error: Unresolved external symbol '_WinMainCRTStartup'
« Reply #10 on: January 24, 2025, 06:46:42 AM »
copy the in a RAM drive under a name then compile in RAM drive
--------------------------------
Kenavo

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2215
Re: POLINK: error: Unresolved external symbol '_WinMainCRTStartup'
« Reply #11 on: January 24, 2025, 07:36:34 AM »
copy the in a RAM drive under a name then compile in RAM drive
What and why ???
Is this another one kind of "optimization" idea ?
May the source be with you

Offline HellOfMice

  • Member
  • *
  • Posts: 360
  • Never be pleased, always improve
Re: POLINK: error: Unresolved external symbol '_WinMainCRTStartup'
« Reply #12 on: January 24, 2025, 07:39:09 AM »
Why not.
Our files are not very big
--------------------------------
Kenavo

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2215
Re: POLINK: error: Unresolved external symbol '_WinMainCRTStartup'
« Reply #13 on: January 24, 2025, 08:55:08 AM »
where.exe is located at Windows\system32 and Windows\SysWOW64 folders
so keeping cmd.exe PATH variable correct in poide too, less problems to solve  ;)
May the source be with you

Offline Vortex

  • Member
  • *
  • Posts: 975
    • http://www.vortex.masmcode.com
Re: POLINK: error: Unresolved external symbol '_WinMainCRTStartup'
« Reply #14 on: January 24, 2025, 09:25:15 AM »
RAM disks are useful tools but today's NVMe drivers are very fast.
Code it... That's all...