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

"-L" parameter on Windows 11 #102

Open
lacroiro opened this issue Feb 17, 2025 · 4 comments
Open

"-L" parameter on Windows 11 #102

lacroiro opened this issue Feb 17, 2025 · 4 comments
Assignees

Comments

@lacroiro
Copy link

I cannot get the "-L" parameter to work on Windows 11. The "-I" parameter for header file seems to work but not the "-L" parameter.

I was trying out CJIT with IBM MQ and compiling/running one of their sample programs called amqsbcg0.c.

Per CJIT docs, the command should be:

cjit -I"D:\Program Files\IBM\MQ\tools\c\include" -lmqm -L"D:\Program Files\IBM\MQ\bin64" amqsbcg0.c -- TEST.Q1 MQWT1

But when I run that command, I get the following error:

CJIT v0.16.0 by Dyne.org
Library not found: mqm.dll
tcc: error: undefined symbol 'MQINQMP'
tcc: error: undefined symbol 'MQCONNX'
tcc: error: undefined symbol 'MQOPEN'
tcc: error: undefined symbol 'MQCRTMH'
tcc: error: undefined symbol 'MQGET'
tcc: error: undefined symbol 'MQDLTMH'
tcc: error: undefined symbol 'MQCLOSE'
tcc: error: undefined symbol 'MQDISC'
cjit_exec: TCC linker error
Library functions missing.

I have the correct path and file name:

C:\temp\CJIT> dir "D:\Program Files\IBM\MQ\bin64\mqm.dll"
 Volume in drive D is Pgms
 Volume Serial Number is 5C60-0E7D

 Directory of D:\Program Files\IBM\MQ\bin64

2022-10-06   01:00 AM            47,592 mqm.dll
               1 File(s)         47,592 bytes
               0 Dir(s)  91,495,485,440 bytes free

If I copy the 'mqm.dll' file to the same directory as the source code then change the command to the following then it works:

cjit -I"D:\Program Files\IBM\MQ\tools\c\include" -lmqm amqsbcg0.c -- TEST.Q1 MQWT1

Am I doing something wrong or is there a bug in CJIT?

Any pointers would be helpful.

later
Roger

@jaromil
Copy link
Member

jaromil commented Feb 18, 2025

Hi @lacroiro ! thanks for your feedback!

In various experiments on this issue, I also met this problem and my conclusion is that it is a Windows OS restriction, that of limiting the runtime link of libraries only to certain directories, like C:/Windows/System etc. plus the current one where the executed program is located (in this case CJIT itself).

I may still be wrong about this assumption, but that's how far I got, thinking that it may be too invasive of a solution to copy cjit.exe and DLLs found into the current directory before execution, which is an implicit modification of the filesystem state which I'd like to avoid.

I am very happy if you find the time to experiment a bit further and share your findings.

ciao

@jaromil jaromil self-assigned this Feb 18, 2025
@lacroiro
Copy link
Author

I've never had this problem with Visual Studio or GCC on Windows. Maybe it has something to do with dealing only with the DLL rather than the LIB file. For Visual Studio or GCC on Windows, you point the compiler/linker to the LIB and not the DLL.

I have both Visual Studio and TDM-GCC installed and decided to do the same test with GCC on Windows.

The LIB files are located in D:\Program Files\IBM\MQ\tools\Lib64\ directory and the DLL files are located in the D:\Program Files\IBM\MQ\bin64\ directory.

First, I did the following command pointing to the LIB directory:
gcc -m64 -O -I"D:\Program Files\IBM\MQ\tools\c\include" -o amqsbcg0.exe amqsbcg0.c -lmqm -L"D:\Program Files\IBM\MQ\tools\Lib64"
And then ran amqsbcg0.exe and it worked fine as expected.

Next, I did the following command pointing to the DLL directory:
gcc -m64 -O -I"D:\Program Files\IBM\MQ\tools\c\include" -o amqsbcg0.exe amqsbcg0.c -lmqm -L"D:\Program Files\IBM\MQ\bin64"
And then ran amqsbcg0.exe and it worked fine. I was really surprised that this worked.

So, clearly, it is not a Windows 11 permission issue.

later
Roger

@lacroiro
Copy link
Author

I just played around with the '-v' parameter and I noticed that CJIT is not including the '-L' directory.

C:\CJIT\cjit.exe -v -I"D:\Program Files\IBM\MQ\tools\c\include" -lmqm -L"D:\Program Files\IBM\MQ\bin64" amqsbcg0.c -- TEST.Q1 MQWT1

and the output is:

CJIT v0.16.2 (c) 2024-2025 Dyne.org foundation
Build system: Windows
Target platform: x86-64 code generator
Target system: WIN64
Library paths (2)
+ C:\temp\MQ_src
+ C:\Windows\SysWOW64

CJIT does not appear to add the '-L' path to its own library paths.

The other weird thing I noticed that when use the '-v' parameter, CJIT does not compile & run the C source code.

The manpage says:

-v
Prints the version number of cjit. It's helpful for verifying the specific version you're working with, especially when troubleshooting or reporting issues: always include the version output. It can also be quickly added to any commandline combination to show the internal state of cjit, for instance include and library paths configured, cflags and libraries linked.

But that last sentence does not appear to be true.

I get the same output if just type "cjit -v" on the command line.

C:\CJIT\cjit.exe -v
CJIT v0.16.2 (c) 2024-2025 Dyne.org foundation
Build system: Windows
Target platform: x86-64 code generator
Target system: WIN64
Library paths (2)
+ C:\temp\MQ_src
+ C:\Windows\SysWOW64

later
Roger

@jaromil
Copy link
Member

jaromil commented Feb 20, 2025

Many thanks Roger! I don't have enough experience nor any other toolchain on win11 to try so this troubleshooting is very helpful and now I guess the fix should be easy. I will first make sure that -L works on windows and then also make sure that -v doesn't interrupts the execution of the command.

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