No Executable, Looks like we don't have a C Compiler!

186 views
Skip to first unread message

Outnull

unread,
Apr 26, 2022, 11:41:24 AM4/26/22
to The Ring Programming Language
Hello -

I am trying to compile but am getting an error. I installed Visual Studio Community 2022 and the following components. Am I missing something?

MSVC v143 VS 2022 C+ + x64/x86 build tool...
C+ + CMake tools for Windows
C++ Clang Compiler for Windows (13.0.0)

Thank you.
6518-Parallels Desktop-Tuesday26-1039.png
6518-Parallels Desktop-Tuesday26-1039 2.png

Mahmoud Fayed

unread,
Apr 26, 2022, 12:06:48 PM4/26/22
to The Ring Programming Language
Hello

Ring uses this batch file to find Visual Studio : https://github.com/ring-lang/ring/blob/master/language/src/locatevc.bat

If the used version doesn't exist in the batch file, Just add it

Greetings,
Mahmoud

Outnull

unread,
Apr 26, 2022, 1:00:57 PM4/26/22
to The Ring Programming Language
Ok, so after some investigating I count that the locative.bat file was not updated to look for Visual Studio Community 2022, so I added the following lines.

if exist "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat" (
    set VSCMD_DEBUG=3
    echo Found Visual Studio Community 2022
    echo Ring build target is: %ringbuildtarget%
    echo Start directory is: %cd%
    set VSCMD_START_DIR=%cd%
    call "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat" -arch=%ringbuildtarget%
    exit /b
)


 Then, I installed Desktop development with C++ in Visual Studio Community Edition 2022. Now, my program compiles but I get an error when I run it. If I run it interactively by double-clicking, a console window flashes open and then closes immediately. If I run it from the command line, I can see the error: Line 2 Error (R38) Runtime Error in loading the dynamic library! In loadlib () in file test.ring. 

This is all that I have in my script. It looks like there is an error loading ring_odbc.dll, which is strange, since I don't think my basic test should be using anything from there.

load "stdlib.ring"

? "Testing..."

? date()

sleep(20)



Thank you.


6518-Parallels Desktop-Tuesday26-1155.png
6518-Parallels Desktop-Tuesday26-1200.png
6518-Parallels Desktop-Tuesday26-1156.png

Outnull

unread,
Apr 26, 2022, 1:04:52 PM4/26/22
to The Ring Programming Language
By the way, the program runs normally as expected via Debug and Run from the Program menu. So not sure why the compiled exe does not work.

Mahmoud Fayed

unread,
Apr 26, 2022, 1:43:47 PM4/26/22
to The Ring Programming Language
Hello

>> "Ok, so after some investigating I count that the locative.bat file was not updated to look for Visual Studio Community 2022, so I added the following lines."

Ring 1.16 is released in October 2021 - That's why visual studio 2022 is not included in the batch file

>> "so I added the following lines."

Fell free to send a pull request in GitHub : https://github.com/ring-lang/ring

>> "It looks like there is an error loading ring_odbc.dll, which is strange,"

Using load "stdlib.ring" uses some classes that need odbc, mysql, postgresql, sqlite, etc

To avoid this, use load "stdlibcore.ring"

>> "By the way, the program runs normally as expected via Debug and Run from the Program menu. So not sure why the compiled exe does not work."

Because Ring can access ring/bin folder files which contains all of the runtime files.

Greetings,
Mahmoud

Outnull

unread,
Apr 26, 2022, 3:37:47 PM4/26/22
to The Ring Programming Language
Hello Mahmoud, 

Thanks for your help! So, does that mean that compiling does not include all of the necessary runtime files? I thought the idea behind compiling an exe was to have a standalone application that included all dependencies in a single file. I compiled as a console application. Is there another option I should have used so that all required files were linked into the resultant exe file?

Really loving ring so far. Keep up the good work!

Thank you.

Outnull

unread,
Apr 26, 2022, 3:52:27 PM4/26/22
to The Ring Programming Language
Also, I tried to compile again using the Ring2EXE (Distribute Application - Use All Runtime) option hoping that would include all dependencies, but I still got an error. This option created a target/windows folder with a bunch of files including my executable. This time it failed to load a different dll file: Library File ring_sqlite.dll

Line 2 Error (R38) Runtime Error in loading the dynamic library!

So if I want to build an EXE that contains everything required for the program to run in a single executable file, how would I do that?

Thank you.

Mahmoud Fayed

unread,
Apr 26, 2022, 5:01:21 PM4/26/22
to The Ring Programming Language
Hello

>> "thought the idea behind compiling an exe was to have a standalone application that included all dependencies in a single file."

If your application is a console application that doesn't use any of the extensions (that needs dll files)
then you can use -static option when using Ring2EXE to have standalone executable file that doesn't need (ring.dll)

if you are using extensions, then Ring 1.16 support using them through the dynamic version that need dll files
building everything using the static version of the libraries to avoid dll files can be done if you know c/c++ and have the time to do that
But we don't support this feature.

>> "So if I want to build an EXE that contains everything required for the program to run in a single executable file, how would I do that?"

Read this chapter in the documentation : https://ring-lang.github.io/doc1.16/distribute_ring2exe.html

Greetings,
Mahmoud

Mounir IDRASSI

unread,
Apr 27, 2022, 4:05:21 AM4/27/22
to The Ring Programming Language
Hi,

I had similar need as Outnull and so I modified Ring to embed the extensions I needed (OpenSSL and libui mainly). This allows me to develop native Windows GUI applications using Ring without any runtime dependencies.
If others are interested, I can share my modified version.

Cheers,
Mounir

Outnull

unread,
Apr 27, 2022, 8:52:25 AM4/27/22
to The Ring Programming Language
Hello Mounir, 

That would be very helpful! I guess this was my misunderstanding, but I don't think the documentation on this is very clear either. Generally speaking, my experience with other languages that build executables has been that they include whatever is necessary to run by themselves as a single file. Based on my new understanding of how Ring does it, I now have the following questions:

  1. How do I know which libraries I can use in a standalone compiled exe and which ones I cannot?
  2. If I use a library/extension that cannot be compiled into the final exe and needs to be distributed as a separate DLL, where must I place that DLL? Does it just sit alongside the exe or can I put it anywhere on the machine? Do I have to instruct my Ring program on where to search for required files?
  3. The documentation says: "use “-dist” option and “-allruntime” to include all libraries"  which I understood as, all required files would be embedded into the final exe. I guess that isn't the case, so Mounir I think this where your solution would be very helpful if you are willing to share it. Does this mean I could use any of the libraries/extensions that I want to and Ring will build them into the final exe?

Thanks everyone. 

Mounir IDRASSI

unread,
Apr 28, 2022, 7:16:28 PM4/28/22
to The Ring Programming Language
Hi,

I have published my build of Ring that comes with builtin extensions that don't require external dependencies. I called it MonoRing (from monolithic) and the binary distribution is available at https://github.com/idrassi/MonoRing/releases.
The builtin extensions are:
  • cJson
  • ConsoleColors
  • Curl
  • httplib
  • internet
  • libui
  • odbc
  • OpenSSL
  • sqlite
  • threads
  • winapi
  • wincreg
  • zip
All other extensions are excluded for now.

Concerning your questions:
  1. You should avoid loading stdlib.ring since it automatically loads many extensions and thus forces the deployment of their dlls. If you do this, then only the dlls of the extensions you are using are needed at runtime...but for extensions the list is long.
  2. For deployment, it is enough to place the dll on the same location as the exe.
  3. Ring doesn't embed external dlls in the final exe. That's why I created MonoRing. But it doesn't support all extensions: only those I listed above are supported for now. I'm planning to add others but Qt will never be part of the MonoRing list because of restriction of Qt static linking and its licensing issues. Do you have any specific extension in mind?

Mansour Ayouni

unread,
Apr 28, 2022, 7:36:48 PM4/28/22
to Mounir IDRASSI, The Ring Programming Language
Hello Mounir,
Thank you for this contribution!
Best,
Mansour

--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ring-lang/9349a263-5449-4d70-8e85-b03d49948605n%40googlegroups.com.

Mahmoud Fayed

unread,
Apr 28, 2022, 8:43:50 PM4/28/22
to The Ring Programming Language
Hello Mounir

>> "I have published my build of Ring that comes with builtin extensions that don't require external dependencies."

Added to Ring website - News section
Also added to the Resources section

Keep up the GREAT WORK :D

Greetings,
Mahmoud
Message has been deleted

Outnull

unread,
Apr 29, 2022, 9:27:58 AM4/29/22
to The Ring Programming Language
Hey Mounir, 

This is awesome! Thanks a lot for sharing. I think it would be great if the Ring team officially supported its own monolithic build as well but am very grateful that you've had the idea, done the work and shared it with us. Good job and thank you.

عزالدين رمال

unread,
Apr 30, 2022, 2:40:42 AM4/30/22
to The Ring Programming Language
hello mounir
Do I understand from what you said that all the RSI functions in the OpenSSL library work with the Monoring version
Thanks 

Mounir IDRASSI

unread,
Apr 30, 2022, 12:50:38 PM4/30/22
to The Ring Programming Language
Hi Azzeddine,

Yes, all RSA functions in OpenSSL extension work natively with MonoRing. I use it to create standalone executable for crypto calculations without the need of OpenSSL dll.
Reply all
Reply to author
Forward
0 new messages