lua-users home
lua-l archive

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


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.