open-watcom / open-watcom-v2

Open Watcom V2.0 - Source code repository, Wiki, Latest Binary build, Archived builds including all installers for download.
Other
959 stars 157 forks source link

sdkddkver.h not found #770

Closed danielmarschall closed 2 years ago

danielmarschall commented 2 years ago

Hello,

I am building a project which uses the Photoshop SDK which contains following code:

#if MSWindows
#if !defined(_WIN32_WINNT)
#define _WIN32_WINNT 0x601 // minimal deployment is Windows 7
#endif
#include <sdkddkver.h> // for WINVER
#endif

sdkddkver.h is not existing on my computer. In OpenWatcom 1.9 , I simply created an empty sdkddkver.h file in my project directory and it worked. In OpenWatcom 2.0, this does not work. The file will not be found, even if it is in my project directory. I tried adding ".\" to the library search path of the C-compiler settings, but it is still not found. What can I do (except for commenting out the line in the Photoshop SDK)?

Thank you for your help

danielmarschall commented 2 years ago

Update: I found out that I can put the file in the upper directory (adding "..\" to the search path), and it works. But the path ".\" does not work. If I write "..\wpj\" (this is my project directory), then it doesn't work either.

Path (does not work) $(%watcom)\h;$(%watcom)\h\nt;..\telegraphics_common\adobeplugin;..\telegraphics_common\tt;$(%PSAPI)\Pica_sp;$(%PSAPI)\Photoshop;$(%PSAPI)\General;.\

Path (does not work): $(%watcom)\h;$(%watcom)\h\nt;..\telegraphics_common\adobeplugin;..\telegraphics_common\tt;$(%PSAPI)\Pica_sp;$(%PSAPI)\Photoshop;$(%PSAPI)\General;..\wpj\

Path (works if file is moved one directory up) $(%watcom)\h;$(%watcom)\h\nt;..\telegraphics_common\adobeplugin;..\telegraphics_common\tt;$(%PSAPI)\Pica_sp;$(%PSAPI)\Photoshop;$(%PSAPI)\General;..\


Very weird: If I move the file in a sub-directory (e.g. dummy\sdkddkver.h), then it does NOT work! $(%watcom)\h;$(%watcom)\h\nt;..\telegraphics_common\adobeplugin;..\telegraphics_common\tt;$(%PSAPI)\Pica_sp;$(%PSAPI)\Photoshop;$(%PSAPI)\General;..\;.\dummy\

I don't understand. If I move the file one directory up, it works. If the file stays in the project directory, or is inside a subdirectory of the project, then it does not work.


Another interesting thing I found: If I add "..\wpj\" at the very beginning of the library paths (before the WATCOM header files), then symbols from units like are not found anymore!

Path: ..\wpj\;$(%watcom)\h;$(%watcom)\h\nt;..\telegraphics_common\adobeplugin;..\telegraphics_common\tt;$(%PSAPI)\Pica_sp;$(%PSAPI)\Photoshop;$(%PSAPI)\General;..\

jmalak commented 2 years ago

Thank you for your bug report.

file should be ok with OW2. It looks like something is wrong with header file aliasing. OW use filename alias pragma to work properly on 8.3 file name format filesystems. For WIN32 headers it is file _win32ials.h file which should be automaticaly included with WIN32 header files. It remap sdkddkver.h name to correct sdkddver.h file name. It ensures maping long file name to short file name for 8.3 file name format. below is content of this map file #pragma include_alias( , ) #pragma include_alias( , ) #pragma include_alias( , ) #pragma include_alias( , ) #pragma include_alias( , ) #pragma include_alias( , ) #pragma include_alias( , ) #pragma include_alias( , ) #pragma include_alias( , ) #pragma include_alias( , ) #pragma include_alias( , ) #pragma include_alias( , ) #pragma include_alias( , ) #pragma include_alias( , ) #pragma include_alias( , ) It looks like is first included header file in your source file. Try to add #include <_win32ials.h> on begining of your source file.
jmalak commented 2 years ago

Please could you give me a copy of this one source file to check.

danielmarschall commented 2 years ago

Try to add

include <_win32ials.h>

on begining of your source file.

What do you mean with "source file"? You mean the source file in the Adobe Photoshop SDK?

Since I am developing open source, I try to avoid that people need to change the Photoshop SDK files. (I want to make the build process as easy as possible, so developers can easily download and compile my source code)

I have put everything in a ZIP here: https://www.hickelsoft.de/temp/filter_foundry.zip (the file is only temporary and contains all dependencies. The project can be found at github)

Please download the ZIP, and in the folder "wpj" there is the project file. The ZIP file should contain all dependencies, so the compilation should work directly.

Thank you for your help!

negge commented 2 years ago

It sounds like you need to modify your Makefile (or other build system) to include the correct directories. I do something like this:

WATCOM ?= ~/opt/watcom
WPATH = $(WATCOM)/binl:$(WATCOM)/binw
INCLUDE = $(WATCOM)/h

CC = wcc386

INCS := <user defined paths go in here>

CFLAGS += -i=$(INCLUDE) $(foreach s,$(INCS),-i=$s)

$(BIN)/%.o: $(SRC)/%.c
        PATH=$(WPATH) INCLUDE=$(INCLUDE) $(CC) -fo=$@ $(CFLAGS) $<
danielmarschall commented 2 years ago

@negge Currently, I am using Makefiles for Visual Studio and for mingw32, these makefiles work. For OpenWatcom, I am not using a Makefile, because I want to build directly inside the IDE. So, I use the .wpj and .tgt files. For OpenWatcom 1.9 it worked, for OpenWatcom 2.0, it does not work. Do I need to do something different?

negge commented 2 years ago

Do I need to do something different?

Sorry but I don't know. I use Linux and haven't run Visual Studio since the 90s. My recollection from back then was that the project files had a way for you to specify additional include directories. Note that wcc386 needs both an INCLUDE environment variable for the system headers (the ones it pulls in) but the user defined ones must be specified with -i.

jmalak commented 2 years ago

Does Photoshop SDK support Open Watcom? I suppose you use Photoshop libraries, not to build it from source by OpenWatcom. Then you must include Photoshop header files to your application. I mean try to include

include <_win32ials.h>

before Photoshop SDK header files in your source code.

jmalak commented 2 years ago

If you want to use some SDK then it should support OpenWatcom. If not then you can use Miscrosoft VS stuff but it is not guarantie to be working because Open Watcom is not clone of Microsoft VS. OpenWatcom support most of important MS VS features, but it is not 100 % compatible.

jmalak commented 2 years ago

@negge you are right , for system headers marked by <> is used INCLUDE variable for user header files marked by "" is used -i compiler option and INCLUDE variable in this order. But there can be some problem with OW2 against OW 1.9 because there were some changes in include files search processing.

danielmarschall commented 2 years ago

The Photoshop SDK works with OpenWatcom. I already use it productively. I am compiling with OpenWatcom, because I want to support Windows 9x. The only thing that does not work is the inclusion of sdkddkver.h . If I comment out this line, everything works perfectly with the Photoshop SDK. If I create an empty dummy file, it does only work if the file is outside the project directory. I think it is a bug in OpenWatcom 2.0, because there is an unexpected behavior if I include ".\" into the search path at the beginning. Also I don't understand why "..\sdkddkver.h" will be found, but ".\sdkddkver.h" won't be found.

Since you say "<>" will only search in the INCLUDE environment variable, why is found, if I specify "-i ..\" ? I thought "-i" will only find "" and not <> ?

danielmarschall commented 2 years ago

Update: #include <_win32ials.h> won't work. I get the error E1055 Unable to open '_win32ials.h'

There is no file _win32ials in my C:\WATCOM directory.

jmalak commented 2 years ago

I tried to compile your project on my test box, but it reports missing "PITypes.h" and "PIFilter.h" files which is not available in source tree. I don't know what all is required to compile your project. I download flex and bison, but it looks like it is not enough.

jmalak commented 2 years ago

Sorry correct name is _w32ials.h and it is in h/nt subdirectory where WIN32 header files are.

danielmarschall commented 2 years ago

I tried to compile your project on my test box, but it reports missing "PITypes.h" and "PIFilter.h" files which is not available in source tree. I don't know what all is required to compile your project. I download flex and bison, but it looks like it is not enough.

The Adobe Photoshop SDK must be placed in the photoshop_sdk directory. I may not upload it to github due to copyright. My ZIP file which I uploaded above ( https://www.hickelsoft.de/temp/filter_foundry.zip ) contains everything . It is ready for compiling.

danielmarschall commented 2 years ago

I have included #include <_w32ials.h> at the beginning of every single .c and .h file and it still doesn't work: Error! E161 : Unable to open 'sdkddkver.h'

jmalak commented 2 years ago

I compiled your project sucessfuly. It is issue with OW filename aliasing. I have a workaround for OW 1.9 and fix for OW 2.0, but there is a problem with resource compiler too, I am afraid it can not be fixed in OW1.9 but I will fix it in OW 2.0 wrc.

The workaround for C/C++ compilers is as follows.

rename sdkddver.h in h/nt to sdkddkve.h and change line in _w32ials.h with sdkddkver.h name to

pragma include_alias( , )

It should fix issue for compilers, but problem with wrc need code fix.

danielmarschall commented 2 years ago

Thank you for your analysis!

I am curious, what is the problem with the resource script? My project compiled with VC++ (32/64), OpenWatcom (32) and mingw (32/64) without problems. The .res and .dll files have the correct resources.

jmalak commented 2 years ago

I get following error during build

wrc ..\win_res.rc -bt=nt -dWIN32 -d_WIN32 -d__NT__ -dWIN_ENV=1 -dINSIDE_PHOTOSHOP=1 -dMSWindows=1 -i=C:\dev\filter_foundry\;C:\dev\ow2t\rel\h;C:\dev\ow2t\rel\h\nt;..\photoshop_sdk\pluginsdk\photoshopapi\Photoshop;..\photoshop_sdk\pluginsdk\photoshopapi\Pica_sp -q -ad -r -fo=win_res.res
C:\dev\filter_foundry\photoshop_sdk\pluginsdk\photoshopapi\Photoshop\PITypes.h(40): Error! E161:  Unable to open 'sdkddkver.h'
Error(E42): Last command making (C:\dev\filter_foundry\wpj\win_res.res) returned a bad status
danielmarschall commented 2 years ago

Oh, now I notice that this error can also have its origin in "wrc". Yesterday, when I was experimenting with the include paths, I changed the C-compiler directories, but I didn't check if the "Unable to open 'sdkddkver.h'" error came from "wrc" or "wcc386"

jmalak commented 2 years ago

I have a note about setup macros for compile your application. OW has WIN32 minimal version of Windows 0x400 (Windows NT 4.0), but in Adobe Photoshop is note about minimal version of Windows 7 (0x601). That all OW stuff is compiled for Windows NT 4.0 even if Photoshop SDK is compiled for Windows 7. I don't know if there can be some binary incompatibilities due to big version difference. Maybe that you don't use anything what was changed between these versions.

danielmarschall commented 2 years ago

Thank you for the hint. I have read something about Windows 7, but I don't know why they wrote it, maybe there are a few features that require a newer Windows version.

My project is compatible with Windows NT 3.1 and Photoshop 3.0. (I love extreme backwards compatibility)

OpenWatcom 2.0 can run on Windows NT 3.1 (because GetEnvironmentStringsA is dynamically loaded), while OpenWatcom 1.9 required Windows 95 / NT 4.0

jmalak commented 2 years ago

But it is only C run-time Library compatibility. But you can compile for Windows 4.0 and above, because header files are for Windows 4.0 and above. Windows NT 3.x requires little different header files which are not implemented. Also linker is setup to link against WIN32 run-time subsystem version 4. You can not compile and link executable which will run on NT 3.x. At minimum you need to crack linker definition file to setup WIN32 subsystem version 3 in executable to be able run on NT3.x. Unfortunately header files is another story.

danielmarschall commented 2 years ago

If you set this setting, then the WIN32 subsystem version will be set to 3.1

image

The compiled binary will then have a subsystem of 3.1 , see:

image

I have just compiled following "Hello world" application with OpenWatcom 2.0 :

image

Interesting fact: If an EXE has subsystem=4.0, then it won't load on Windows NT 3.1. But if you have a DLL with subsystem=4.0, then it WILL load on Windows NT 3.1.

So, you did a wonderful job in regards backwards compatibility!

jmalak commented 2 years ago

Oh, I forgot IDE handle WIN32 subsystem version explicitly, but by default wlink.lnk not support 3.x version. OW2.0 have some fixes related to Win32s and NT3.x against OW 1.9, but it is very similar.

jmalak commented 2 years ago

wrc is now fix that your project should compile without problems

danielmarschall commented 2 years ago

I can verify that it now compiles without problems! Thank you very much.