Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

less-579 will not compile under Windows #126

Closed
jftuga opened this issue Feb 17, 2021 · 12 comments
Closed

less-579 will not compile under Windows #126

jftuga opened this issue Feb 17, 2021 · 12 comments

Comments

@jftuga
Copy link

jftuga commented Feb 17, 2021

To compile , I am using:

"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
nmake /f Makefile.wnm
  • less-576 will compile
  • less-577 will not

Here is the less-576 compilation error message:

lsystem.obj : error LNK2019: unresolved external symbol tty_device referenced in function lsystem
less.exe : fatal error LNK1120: 1 unresolved externals

Here is the difference in lsystem.c:

diff less-576\lsystem.c less-577\lsystem.c

121c121
<       if (__open("/dev/tty", OPEN_READ) < 0)
---
>       if (__open(tty_device(), OPEN_READ) < 0)
123c123
<       if (open("/dev/tty", OPEN_READ) < 0)
---
>       if (open(tty_device(), OPEN_READ) < 0)

In the less-579 code, I reverted these back to using "/dev/tty" and the compilation was then successful. However, I doubt this is the best fix for this problem and therefore did not submit a PR. I suspect that the tty_device() function needs to be changed, but I did not have time to further investigate.

@gwsw
Copy link
Owner

gwsw commented Feb 17, 2021

I'm not sure what you mean by "v579" -- that tag has not yet been built. In any case, this bug should be fixed in 0c08883.

@jftuga
Copy link
Author

jftuga commented Feb 17, 2021

I was testing with this:

http:https://greenwoodsoftware.com/less/less-579.tar.gz

This tarball actually includes the 0c08883 patch, but still fails to compile.

@gwsw
Copy link
Owner

gwsw commented Feb 17, 2021

Ah, sorry, I'm still in the process of preparing v579 and forgot that that had been uploaded.

Well, that's strange that you're getting that error with that code, since the call to tty_device is surrounded by

#if !MSDOS_COMPILER

MSDOS_COMPILER should be WIN32C (3) if you build with Makefile.wnm.

@jftuga
Copy link
Author

jftuga commented Feb 17, 2021

Is there anyway I can tell if that is actually set or not?

@gwsw
Copy link
Owner

gwsw commented Feb 17, 2021

You could try something like this:

   inp = dup(0);
    close(0);
+#define _XSTR(x) _STR(x)
+#define _STR(x) #x
+#warning "MSDOS_COMPILER is " _XSTR(MSDOS_COMPILER)
+#pragma message "MSDOS_COMPILER is " _XSTR(MSDOS_COMPILER)
 #if !MSDOS_COMPILER
 #if OS2
    /* The __open() system call translates "/dev/tty" to "con". */

@jftuga
Copy link
Author

jftuga commented Feb 17, 2021

That did not work but I think I found something similar:

#define STRINGIFY( L )       #L
#define MAKESTRING( M, L )   M(L)
#define STRINGIZE(X)         MAKESTRING( STRINGIFY, X )
#pragma message( "You have " STRINGIZE(MSDOS_COMPILER) )

When compiling, this was returned:

You have 3

Please let me know if my replacement is not what you are looking for.

@gwsw
Copy link
Owner

gwsw commented Feb 20, 2021

So you have MSDOS_COMPILER == 3, but the code inside #if !MSDOS_COMPILER is being compiled? That's difficult to understand.

@jftuga
Copy link
Author

jftuga commented Feb 23, 2021

I agree. I am not sure what to make of it. Do the define and pragma statements that I previously posted look OK to you?

@gwsw
Copy link
Owner

gwsw commented Feb 25, 2021

Yes they look ok, and 3 (WIN32C) is the value I would expect MSDOS_COMPILER to be set to (defined in defines.wn). I don't understand why code under #if !MSDOS_COMPILER would be compiled. That construct is used elsewhere, for example in screen.c, where it must be working.

@jftuga
Copy link
Author

jftuga commented Feb 26, 2021

Could you add something like

#if MSDOS_COMPILER == 3

I don't know / remember a lot about C preprocessor statements.

@gwsw
Copy link
Owner

gwsw commented Mar 2, 2021

Please check whether https://greenwoodsoftware.com/less/less-580.tar.gz works for you.

@jftuga
Copy link
Author

jftuga commented Mar 3, 2021

Please check whether https://greenwoodsoftware.com/less/less-580.tar.gz works for you.

Version 580 compiles:

03/03/2021  04:21 PM           327,168 less.exe
03/03/2021  04:21 PM           143,872 lesskey.exe

Version check:

.\less.exe --version
less 580 (Spencer V8 regular expressions)

Thank you for working on this with me. I really appreciate it. How did you fix it?

@gwsw gwsw closed this as completed Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants