lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> [...] I'm not sure I understand your problem properly, what do you mean by "C script" and "calls the header files"?[...]

 

Most of the app’s source files are Lua files, but one is .c. The file written in C has a bunch of “#include” statements like #include “iup.h” and it contains some global variables. The actual app code, beyond setting up includes and some globals, is in the Lua files.

 

I’ve since downloaded and installed the .h header files for Lua 5.1 (the app uses this version and the code uses “getn” a lot, which was depreciated in later versions of Lua), IUP, CD, and IM like in the Makefile included in the app’s source files, added the “include” and “Lua51” directories to the “path” section of Environment Variables, but VSCode still can’t find them. I wrote some more about the Makefile stuff here: https://www.reddit.com/r/lua/comments/q5coda/trouble_getting_lua_and_iup_working_with_vscode/

 

> [...] what are you trying to debug, your app's source code (in C/C++) or the Lua code that run inside your host app?

VSCode [...]

 

I  don’t know which one I’m supposed to debug. I’m just trying to get VSCode to do something right and find the .h files. I tried using debug on the C file, but that didn’t work. I tried running the app’s main Lua file with the iuplua interpreter but that gives me errors too. I tried to compile, but that doesn’t work. I tried using the app’s Makefile after making some adjustments (the folder structures of the library files I downloaded weren’t the same. There were no folders called “lib”), but nothing can find the .h files.

 

> [...] if your app contains native code, you should use the library packages, either static or dynamic, but not

the binary ones. [..]

 

The C file contains #include <windows.h>. Does that mean it contains “native code”?

 

Thanks

 

From: nerditation
Sent: Saturday, October 16, 2021 9:41 AM
To: lua-l@lists.lua.org
Subject: Re: I Can't Get Lua 5.1 and IUP 3.30 to Work With VSCode and GCC on Windows 10 x64

 

On 2021/10/7 11:58, Kaz wrote:

> Hello,

>

 

hello,

 

 

> [...] that uses mostly Lua scripts and one C script that calls the header files. [...]

 

I'm not sure I understand your problem properly, what do you mean by "C script" and "calls the header files"?

 

 

> [...] to update IUP in order to use some new features as well as be able to compile and debug the code in VSCode [...]

 

what are you trying to debug, your app's source code (in C/C++) or the Lua code that run inside your host app?

 

 

> [...]

> Does anyone know how I can get all this stuff working together?

> [...]

 

 

if your app is written entirely in Lua (that is, you just need a Lua interpreter with iup included), you

can simply download `iup-3.30-Lua54_Win64_bin.zip` and use `lua54.exe` or `wlua54.exe` to run Lua code.

 

the `,xxxx_bin.zip` package is sufficient to run Lua code that depends on iuplua, cdlua, imlua, etc, but it

doesn't contain header files, and all the libraries are built as dynamic libraries.

 

if your app contains native code, you should use the library packages, either static or dynamic, but not

the binary ones.

 

since you mentioned vscode and gcc, I would assume you have your toolchain already set up. then you may try

the following configuration for a bare minimal sample project with Lua and IUP support.

 

note I will use Lua 5.4 as an example, you can change to other version, the configuration for the editor

and compiler is the same.

 

 

1. you need 3 libraries: `lua`, `iup`, and `iuplua`.

 

   if you want static linking, download `lua-5.4.2_Win64_mingw6_lib.zip`, `iup-3.30_Win64_mingw6_lib.zip`,

   and `iup-3.30-Lua54_Win64_mingw6_lib.zip`, or whatever version you prefer, note the `_mingw6_lib` suffix.

 

   if you prefer dynamic linking, just choose the packages with `_dllw6_lib` suffix.

 

2. extract all the files from the packages into a single subdirectory, say `static` or `dynamic`

 

3. in `.vscode/c_cpp_properties.json`:

 

```json

{

  "configurations": [

    {

      "name": "mingw64-static-link"

      ,"includePath": [

        "${default}"

        ,"${workspaceFolder}/static/include"

      ]

      ,"compilerPath": "g++.exe"

      ,"intelliSenseMode": "windows-gcc-x64"

      ,"compilerArgs": [

        "-I${workspaceFolder}/static/include"

        ,"-L${workspaceFolder}/static"

        ,"-liuplua54"

        ,"-llua54"

        ,"-liup"

        ,"-liupcontrols"

        ,"-lgdi32"

        ,"-lcomctl32"

        ,"-lcomdlg32"

        ,"-lole32"

        ,"-luuid"

      ]

    }

    ,{

      "name": "mingw64-dynamic-link"

      ,"includePath": [

        "${default}"

        ,"${workspaceFolder}/dynamic/include"

      ]

      ,"compilerPath": "g++.exe"

      ,"intelliSenseMode": "windows-gcc-x64"

      ,"compilerArgs": [

        "-I${workspaceFolder}/dynamic/include"

        ,"-L${workspaceFolder}/dynamic"

        ,"-llua54"

      ]

    }

  ]

  ,"version": 4

}

```

4. if you are using static linking, in `src/main.cpp`, don't forget to add `iuplua_open`,

   `iupcontrolslua_open`, etc, into the `package.preload` table so that Lua code have access to IUP.

 

   for dynamic linking, Lua will load the necessary dll files automatically, as long the required

   libraries are in the PATH environment or in the same directory of the executable.

 

5. make sure `src/main.cpp` is active in the editor, press "Ctrl + Shift + P" and search for the command

   "C/C++: Build and Debug Active File". this command will generate a `.vscode/tasks.json` configuration

   based on the configuration in the `.vscode/c_cpp_properties.json` file. you may review and modify the

   task configuration to suit your need.

 

if all goes well, you will get an exe file and be able to debug it using gdb.