NO

Author Topic: Everything OK with VSE, a disaster with Pelles C !?  (Read 5548 times)

znort

  • Guest
Everything OK with VSE, a disaster with Pelles C !?
« on: May 13, 2014, 12:10:35 PM »
Hello. I searched the forum, but I was surprised ??? not to find any post describing a situation similar to the one that I have encountered, thus I am asking for some help.

Over the years I developed a large project in plain C.
I remained focused on my project and didn't feel any need to change developing tools, or OS and I was pretty satisfied of my HW too. It's so that I remained stuck to Visual C++ 6.0 Pro and XP until a couple of months ago, when, approaching the end of support for XP, I decided it was really time for a change.
I thus made a big leap to Win 8.1 and renewed my HW, which is now several times faster than my old PC's. However the old VC 6.0, is no more compatible with the new HW and OS, and I had to find new tools for development.
I could import my old project in VS Express 2013 introducing only minor changes to the code and to the project settings, I could build it, well... getting a long list of warnings, but at the end the executable runs smoothly in the new machines. I was surprised! :D

The only problem with VS Express is that it doesn't support resource editing.  >:(

Searching for a solution I found Pelles C and gave it a try.
The good news is that P. C can read my .rc file and I was able to edit it and bring it back in VSE and compile it.
I also liked the style and essence of P. C, which is very close to the old VS style which I was used to.
I wandered why not to use P. C for everything, but here comes the bad news: I was unable to build my project with P. C!  :(
In order to find all the necessary definitions I had to use the VSE include files, in place of the  include files that come with P. C., but even doing so I was unable to compile my files.
At first I get a warning saying that there are duplicate symbols in the include files, later I get a long list of errors. The most common is error #2002 (invalid combination of types), but also #1050 (redeclaration of macro) and even some syntax errors!
Another inconvenience is that Pelles C build stops at the first file that it cannot compile, thus it's also hard for me to predict all the problems that I may encounter.
The situation seems hopeless, but I wonder if there is perhaps some trick to overcome all these problems. Is there a compatibility mode that I can enable? A particular combination of compiler settings that I can use?
Otherwise the least resistance path for me would be to go for VSE and use Pelles C just for resource editing, like I said above, although I don't quite like it.  :-\

Thank you for reading so far and thanks to whom of you can give me useful suggestions.

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: Everything OK with VSE, a disaster with Pelles C !?
« Reply #1 on: May 13, 2014, 12:58:01 PM »
Could you specify which definitions you miss? (that are not in std PellesC headers).
Maybe a short program (an hello world) that use the definitions you miss.
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

znort

  • Guest
Re: Everything OK with VSE, a disaster with Pelles C !?
« Reply #2 on: May 13, 2014, 05:54:39 PM »
Thanks for replying frankie.
I have to say that in the meantime I made some progress.
In fact everything originated from the missing definition of _MAX_PATH
but, instead of including the corresponding VS include file (which then starts a long chain) I directly defined it as a numeric constant (260).
I commented out another include file that I used only for debug purposes (crtdbg.h).
In this way I could compile everything with the standard Pelles C include files (i.e. without the VS files).

The problem at this point is with the linker!

I get the following unresolved symbols:

POLINK: error: Unresolved external symbol '__imp__InvalidateRect@12'.
POLINK: error: Unresolved external symbol '__imp__UpdateWindow@4'.
POLINK: error: Unresolved external symbol '_gc_warning'.
POLINK: error: Unresolved external symbol '__imp__Sleep@4'.
POLINK: error: Unresolved external symbol '@GC_debug_malloc@12'.
POLINK: error: Unresolved external symbol '__imp__DialogBoxParamA@20'.
POLINK: error: Unresolved external symbol '__imp__MessageBoxA@16'.
POLINK: error: Unresolved external symbol '__imp__SetDlgItemTextA@12'.
POLINK: error: Unresolved external symbol '__imp__SendDlgItemMessageA@20'.
POLINK: error: Unresolved external symbol '__imp__EndDialog@8'.
POLINK: error: Unresolved external symbol '__imp__GetDlgItemTextA@16'.
POLINK: error: Unresolved external symbol '__imp__ReleaseDC@8'.
POLINK: error: Unresolved external symbol '__imp__DeleteDC@4'.
POLINK: error: Unresolved external symbol '__imp__PostQuitMessage@4'.
POLINK: error: Unresolved external symbol '__imp__GetSystemMetrics@4'.
POLINK: error: Unresolved external symbol '__imp__GetClientRect@8'.
POLINK: error: Unresolved external symbol '__imp__SetScrollInfo@16'.
POLINK: error: Unresolved external symbol '__imp__GetDC@4'.
POLINK: error: Unresolved external symbol '__imp__CreateCompatibleDC@4'.
POLINK: error: Unresolved external symbol '__imp__CreateCompatibleBitmap@12'.
POLINK: error: Unresolved external symbol '__imp__SelectObject@8'.
POLINK: error: Unresolved external symbol '__imp__GetStockObject@4'.
POLINK: error: Unresolved external symbol '__imp__PatBlt@24'.
POLINK: error: Unresolved external symbol '__imp__SetBkMode@8'.
POLINK: error: Unresolved external symbol '__imp__BeginPaint@8'.
POLINK: error: Unresolved external symbol '__imp__BitBlt@36'.
POLINK: error: Unresolved external symbol '__imp__EndPaint@8'.
POLINK: error: Unresolved external symbol '__imp__DefWindowProcA@16'.
POLINK: error: Unresolved external symbol '__imp__TextOutA@20'.
POLINK: error: Unresolved external symbol '__imp__GetTextMetricsA@8'.
POLINK: error: Unresolved external symbol '__imp__SetTextColor@8'.
POLINK: error: Unresolved external symbol '@GC_debug_malloc_atomic@12'.
POLINK: error: Unresolved external symbol '@GC_debug_free@4'.
POLINK: error: Unresolved external symbol '__imp__FillRect@12'.
POLINK: error: Unresolved external symbol '__imp__MoveToEx@16'.
POLINK: error: Unresolved external symbol '__imp__LineTo@12'.
POLINK: error: Unresolved external symbol '__imp__GetTextExtentPoint32A@16'.
POLINK: error: Unresolved external symbol '__imp__Polyline@12'.
POLINK: error: Unresolved external symbol '__imp__CreateSolidBrush@4'.
POLINK: error: Unresolved external symbol '__imp__DeleteObject@4'.
POLINK: error: Unresolved external symbol '__imp__Polygon@12'.
POLINK: error: Unresolved external symbol '__imp__CreatePen@12'.
POLINK: error: Unresolved external symbol '__imp__MessageBeep@4'.
POLINK: error: Unresolved external symbol '__CrtCheckMemory'.
POLINK: error: Unresolved external symbol '_leggiParametriCCI'.
POLINK: error: Unresolved external symbol '@GC_debug_realloc@16'.
POLINK: error: Unresolved external symbol '_GC_default_warn_proc'.
POLINK: error: Unresolved external symbol '__imp__LoadIconA@8'.
POLINK: error: Unresolved external symbol '__imp__LoadCursorA@8'.
POLINK: error: Unresolved external symbol '__imp__RegisterClassExA@4'.
POLINK: error: Unresolved external symbol '__imp__CreateWindowExA@48'.
POLINK: error: Unresolved external symbol '__imp__ShowWindow@8'.
POLINK: error: Unresolved external symbol '@GC_set_warn_proc@4'.
POLINK: error: Unresolved external symbol '__imp__TranslateMessage@4'.
POLINK: error: Unresolved external symbol '__imp__DispatchMessageA@4'.
POLINK: error: Unresolved external symbol '__imp__GetMessageA@16'.
POLINK: error: Unresolved external symbol '_GC_quiet'.
POLINK: error: Unresolved external symbol '__imp__GetSystemTimeAsFileTime@4'.
POLINK: error: Unresolved external symbol '_main'.
POLINK: error: Unresolved external symbol '_RtlUnwind@16'.
POLINK: error: Unresolved external symbol '__imp__InitializeCriticalSection@4'.
POLINK: error: Unresolved external symbol '__imp__DeleteCriticalSection@4'.
POLINK: error: Unresolved external symbol '__imp__EnterCriticalSection@4'.
POLINK: error: Unresolved external symbol '__imp__LeaveCriticalSection@4'.
POLINK: error: Unresolved external symbol '__imp__CloseHandle@4'.
POLINK: error: Unresolved external symbol '__imp__GetLastError@0'.
POLINK: error: Unresolved external symbol '__imp__TlsAlloc@0'.
POLINK: error: Unresolved external symbol '__imp__TlsSetValue@8'.
POLINK: error: Unresolved external symbol '__imp__GetCurrentThreadId@0'.
POLINK: error: Unresolved external symbol '__imp__TlsGetValue@4'.
POLINK: error: Unresolved external symbol '__imp__TlsFree@4'.
POLINK: error: Unresolved external symbol '__imp__SetLastError@4'.
POLINK: error: Unresolved external symbol '__imp__HeapCreate@12'.
POLINK: error: Unresolved external symbol '__imp__HeapDestroy@4'.
POLINK: error: Unresolved external symbol '__imp__HeapAlloc@12'.
POLINK: error: Unresolved external symbol '__imp__HeapReAlloc@16'.
POLINK: error: Unresolved external symbol '__imp__HeapFree@12'.
POLINK: error: Unresolved external symbol '__imp__HeapSize@12'.
POLINK: error: Unresolved external symbol '__imp__HeapValidate@12'.
POLINK: error: Unresolved external symbol '__imp__GetStartupInfoA@4'.
POLINK: error: Unresolved external symbol '__imp__GetFileType@4'.
POLINK: error: Unresolved external symbol '__imp__GetStdHandle@4'.
POLINK: error: Unresolved external symbol '__imp__GetCurrentProcess@0'.
POLINK: error: Unresolved external symbol '__imp__DuplicateHandle@28'.
POLINK: error: Unresolved external symbol '__imp__SetHandleCount@4'.
POLINK: error: Unresolved external symbol '__imp__GetCommandLineA@0'.
POLINK: error: Unresolved external symbol '__imp__GetModuleFileNameA@12'.
POLINK: error: Unresolved external symbol '__imp__GetEnvironmentStrings@0'.
POLINK: error: Unresolved external symbol '__imp__FreeEnvironmentStringsA@4'.
POLINK: error: Unresolved external symbol '__imp__OutputDebugStringA@4'.
POLINK: error: Unresolved external symbol '__imp__UnhandledExceptionFilter@4'.
POLINK: error: Unresolved external symbol '__imp__GetConsoleMode@8'.
POLINK: error: Unresolved external symbol '__imp__GetConsoleOutputCP@0'.
POLINK: error: Unresolved external symbol '__imp__WriteFile@20'.
POLINK: error: Unresolved external symbol '__imp__SetStdHandle@8'.
POLINK: error: Unresolved external symbol '__imp__DeleteFileA@4'.
POLINK: error: Unresolved external symbol '__imp__ReadFile@20'.
POLINK: error: Unresolved external symbol '__imp__GetConsoleCP@0'.
POLINK: error: Unresolved external symbol '__imp__SetFilePointer@16'.
POLINK: error: Unresolved external symbol '__imp__ExitProcess@4'.
POLINK: error: Unresolved external symbol '__imp__SetConsoleCtrlHandler@8'.
POLINK: error: Unresolved external symbol '__imp__MultiByteToWideChar@24'.
POLINK: error: Unresolved external symbol '__imp__VirtualAlloc@16'.
POLINK: error: Unresolved external symbol '__imp__VirtualQuery@12'.
POLINK: error: Unresolved external symbol '__imp__WideCharToMultiByte@32'.
POLINK: error: Unresolved external symbol '__imp__CreateFileA@28'.
POLINK: error: Unresolved external symbol '__imp__CreateEventW@16'.
POLINK: error: Unresolved external symbol '__imp__SetEvent@4'.
POLINK: error: Unresolved external symbol '__imp__GetSystemTime@4'.
POLINK: error: Unresolved external symbol '__imp__GetTimeZoneInformation@4'.
POLINK: error: Unresolved external symbol '__imp__SetEndOfFile@4'.
POLINK: error: Unresolved external symbol '__imp__WaitForSingleObject@8'.
POLINK: fatal error: 112 unresolved external(s).

The required libraries however are apparently in the linker list, so perhaps I have not defined correctly the calling conventions. I am currently investigating this issue, but obviously suggestions are welcome!

Did someone of you already passed through this?

czerny

  • Guest
Re: Everything OK with VSE, a disaster with Pelles C !?
« Reply #3 on: May 13, 2014, 06:09:32 PM »
In fact everything originated from the missing definition of _MAX_PATH
Use MAX_PATH!
POLINK: error: Unresolved external symbol '__imp__InvalidateRect@12'.
Your project seems to be a gui project. Have you setup your project as a 'windows' project, not a 'console' project?
Look at the subsystem typ at the project linker page.

znort

  • Guest
Re: Everything OK with VSE, a disaster with Pelles C !?
« Reply #4 on: May 13, 2014, 06:31:53 PM »
Yes czerny, it's a GUI project, however setting the 'windows' type in subsystem doesn't change the result, I always get those 112 undefined symbols. This is using the multithreaded library option, they reduce to 99 with the single threaded library. Hmm...
I hope to solve this issue sooner or later, I really wanted to make some comparison also on the executables which come out from VSE or Pelles C.

czerny

  • Guest
Re: Everything OK with VSE, a disaster with Pelles C !?
« Reply #5 on: May 13, 2014, 06:45:05 PM »
Make a little test project which shows one of your errors and post it here!

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: Everything OK with VSE, a disaster with Pelles C !?
« Reply #6 on: May 13, 2014, 07:25:08 PM »
Pelles C doesn't include the libraries that match the included header files, so you need to specify them as linker options.
---
Stefan

Proud member of the UltraDefrag Development Team

znort

  • Guest
Re: Everything OK with VSE, a disaster with Pelles C !?
« Reply #7 on: May 13, 2014, 11:52:34 PM »
They are already specified Stefan. As I said this project compiles, links and executes without problems in VSE, and I used the same library list also for Pelles C, but what's good for VSE, for some reason is wrong for P. C, but I haven't figured out yet what. :-\

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: Everything OK with VSE, a disaster with Pelles C !?
« Reply #8 on: May 14, 2014, 09:52:10 AM »
Make a test:
Create a new project from File-->New-->Project
Select From "Empty Projects" Win32 Program (EXE)
Choose files location and project name.
In the project directory put acopy of your sources and headers.
Now from the project pane on the left rigth click on the project
From the pop-up menu select "Add files to project ..."
Select and include all sources.
Now compile the project.

P.S. From the errors you listed there should be a big mess in project options. You said that you changed the subsystem from console to Windows, but the linker is looking for "_main" entry point.
Check that in the project-->options-->linker the box "Libraries and object files" contains at least these libraries:
Code: [Select]
kernel32.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib advapi32.lib delayimp.libMoreover in project-->options-->Compiler "Calling convention" should be set to __stdcall and in Options you should have checked "Enable Microsoft Extensions" (but the last should be OK or you would get a lump of errors including "Windows.h").
« Last Edit: May 14, 2014, 10:55:58 AM by frankie »
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Everything OK with VSE, a disaster with Pelles C !?
« Reply #9 on: May 14, 2014, 10:08:06 AM »
First check that that you have correct library path PellesC\lib;PellesC\lib\Win

Compiling individual source files are possible with Add-In ScrCompile here

EDIT: gc static lib 7.4.0
« Last Edit: May 14, 2014, 02:01:17 PM by TimoVJL »
May the source be with you

znort

  • Guest
Re: Everything OK with VSE, a disaster with Pelles C !?
« Reply #10 on: May 14, 2014, 01:06:27 PM »
Well, I would not say that there is a “big mess in project options”, but rather something that must be corrected. It looks like I almost made it here, but not yet completely.

Thanks to TimoVJL, who suggested me to check the library paths, because one path was wrong (Win64 instead of Win, well I am on a 64 bit machine, but this is still a 32 bit project!).
After correcting this the great part of symbols were solved. A few symbols remained: the calls to the garbage collector, a trivial problem of  missing path.

After this all symbols were solved, but I still got the error LIBCMT.lib not found.
This library is not in the Pelles C directories. Thus I added a path to the VS libraries.

This is still not enough for final success, as now I get these errors:
POLINK: warning: Unrecognized option 'EDITANDCONTINUE'; ignored.
POLINK: fatal error: Invalid or corrupt object 'gcLib.lib(misc.obj)'.
The object which is found corrupt is the library of the garbage collector, and is the same that I use with VS. ???

I also changed the calling convention to __stdcall, it was set to __fastcall, but this seems to have no effect on the final result. Same thing also in changing the single threaded or multithreaded option for libraries.

What do you think?

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: Everything OK with VSE, a disaster with Pelles C !?
« Reply #11 on: May 15, 2014, 11:20:06 PM »
You can't always use the VS libraries in other compilers.
In addition you will get duplicate libraries, so the Pelles folders must always be first.

I think extracting a DEF file from the lib would just solve the problem too, without the need to include the VS paths.
---
Stefan

Proud member of the UltraDefrag Development Team